@@ -64,7 +64,7 @@ public function setUp(): void {
6464 $ err ->errorInfo ; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
6565 $ err_code = $ err_data [1 ];
6666 $ translator ->rollback ();
67- $ message = sprintf (
67+ $ message = sprintf (
6868 'Error occurred while creating tables or indexes...<br />Query was: %s<br /> ' ,
6969 var_export ( $ query , true )
7070 );
@@ -112,37 +112,24 @@ public function setUp(): void {
112112 }
113113 }
114114
115- private function assertQuery ( $ sql ) {
116- $ retval = $ this ->engine ->query ( $ sql );
117- $ this ->assertEquals (
118- '' ,
119- $ this ->engine ->get_error_message ()
120- );
121- $ this ->assertNotFalse (
122- $ retval
123- );
124-
125- return $ retval ;
126- }
127-
128- public function testGreatestLeast () {
115+ public function testGreatestLeast () {
129116 $ q = <<<'QUERY'
130117SELECT GREATEST('a', 'b') letter;
131118QUERY;
132119
133120 $ result = $ this ->assertQuery ( $ q );
134121 $ actual = $ this ->engine ->get_query_results ();
135- $ this ->assertEquals (1 , count ( $ actual ));
136- $ this ->assertEquals ('b ' , $ actual [0 ]->letter );
122+ $ this ->assertEquals ( 1 , count ( $ actual ) );
123+ $ this ->assertEquals ( 'b ' , $ actual [0 ]->letter );
137124
138125 $ q = <<<'QUERY'
139126SELECT LEAST('a', 'b') letter;
140127QUERY;
141128
142129 $ result = $ this ->assertQuery ( $ q );
143130 $ actual = $ this ->engine ->get_query_results ();
144- $ this ->assertEquals (1 , count ( $ actual ));
145- $ this ->assertEquals ('a ' , $ actual [0 ]->letter );
131+ $ this ->assertEquals ( 1 , count ( $ actual ) );
132+ $ this ->assertEquals ( 'a ' , $ actual [0 ]->letter );
146133
147134 $ q = <<<'QUERY'
148135SELECT GREATEST(2, 1.5) num;
@@ -224,8 +211,6 @@ public function testLikeEscapingParenAfterLike() {
224211 $ this ->assertEquals ( 'visible_meta_key_40 ' , $ last );
225212 }
226213
227- // https://github.com/WordPress/sqlite-database-integration/issues/19
228-
229214 public function testLikeEscapingWithConcatFunction () {
230215 $ q = <<<'QUERY'
231216SELECT DISTINCT meta_key FROM wp_postmeta WHERE meta_key NOT BETWEEN '_' AND '_z' AND meta_key NOT LIKE CONCAT('\_', '%') ORDER BY meta_key LIMIT 30
@@ -239,6 +224,8 @@ public function testLikeEscapingWithConcatFunction() {
239224 $ this ->assertEquals ( 'visible_meta_key_30 ' , $ last );
240225 }
241226
227+ // https://github.com/WordPress/sqlite-database-integration/issues/19
228+
242229 public function testHavingWithoutGroupBy () {
243230
244231 $ q = <<<'QUERY'
@@ -370,6 +357,7 @@ public function testExpiredTransients() {
370357 self ::assertLessThan ( time (), $ row ->option_timeout );
371358 }
372359 }
360+
373361 public function testDeleteExpiredNonSiteTransients () {
374362
375363 $ now = time ();
@@ -425,7 +413,7 @@ public function testDeleteExpiredNonSiteTransients() {
425413 $ count_unexpired = 0 ;
426414 foreach ( $ actual as $ row ) {
427415 if ( str_starts_with ( $ row ->option_name , '_transient ' ) ) {
428- $ count_unexpired ++;
416+ $ count_unexpired ++;
429417 $ this ->assertGreaterThan ( $ now , $ row ->option_timeout );
430418 }
431419 }
@@ -491,7 +479,7 @@ public function testRecoverSerialized() {
491479 $ this ->assertEquals ( $ obj , $ unserialized );
492480
493481 $ obj ['two ' ] ++;
494- $ obj ['pi ' ] *= 2 ;
482+ $ obj ['pi ' ] *= 2 ;
495483 $ option_value = serialize ( $ obj );
496484 $ option_value_escaped = $ this ->engine ->get_pdo ()->quote ( $ option_value );
497485 /* Note well: this is heredoc not nowdoc */
@@ -514,7 +502,36 @@ public function testRecoverSerialized() {
514502 $ this ->assertEquals ( $ option_value , $ retrieved_string );
515503 $ unserialized = unserialize ( $ retrieved_string );
516504 $ this ->assertEquals ( $ obj , $ unserialized );
505+ }
506+
507+ public function testShowColumns () {
508+
509+ $ query = 'SHOW COLUMNS FROM wp_posts ' ;
510+ $ this ->assertQuery ( $ query );
511+
512+ $ actual = $ this ->engine ->get_query_results ();
513+ foreach ( $ actual as $ row ) {
514+ $ this ->assertIsObject ( $ row );
515+ $ this ->assertTrue ( property_exists ( $ row , 'Field ' ) );
516+ $ this ->assertTrue ( property_exists ( $ row , 'Type ' ) );
517+ $ this ->assertTrue ( property_exists ( $ row , 'Null ' ) );
518+ $ this ->assertTrue ( ( 'NO ' === $ row ->Null ) || ( 'YES ' === $ row ->Null ) );
519+ $ this ->assertTrue ( property_exists ( $ row , 'Key ' ) );
520+ $ this ->assertTrue ( property_exists ( $ row , 'Default ' ) );
521+ }
522+ }
523+
524+ private function assertQuery ( $ sql ) {
525+ $ retval = $ this ->engine ->query ( $ sql );
526+ $ this ->assertEquals (
527+ '' ,
528+ $ this ->engine ->get_error_message ()
529+ );
530+ $ this ->assertNotFalse (
531+ $ retval
532+ );
517533
534+ return $ retval ;
518535 }
519536
520537}
0 commit comments