Skip to content

Commit 3bed95e

Browse files
committed
Test FOUND_ROWS() with two-digit counts and without stringified fetches
Fold the separate above-nine test into testFoundRowsWithoutSqlCalcFoundRows. The SELECT and SHOW TABLES checks now return 12 and 11 rows, which covers both the query and the query-with-params paths. The test no longer counts the setUp fixture tables, as the existing test drops them. Run the test with stringified fetches on and off. Without stringification, the old code returned 0 and emitted a warning.
1 parent cf51a68 commit 3bed95e

1 file changed

Lines changed: 24 additions & 34 deletions

File tree

‎packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Tests.php‎

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4186,97 +4186,87 @@ public function testCalcFoundRows() {
41864186
);
41874187
}
41884188

4189-
public function testFoundRowsWithoutSqlCalcFoundRowsAboveNine(): void {
4190-
$this->assertQuery( 'CREATE TABLE t (id INT)' );
4191-
$this->assertQuery( 'INSERT INTO t (id) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12)' );
4192-
for ( $i = 1; $i <= 10; $i++ ) {
4193-
$this->assertQuery( "CREATE TABLE t$i (id INT)" );
4194-
}
4195-
4196-
// SELECT
4197-
$this->assertQuery( 'SELECT * FROM t' );
4198-
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4199-
$this->assertSame( '12', $result[0]->{'FOUND_ROWS()'} );
4200-
4201-
// SHOW TABLES ("_dates", "_options", "t", and "t1" to "t10")
4202-
$this->assertQuery( 'SHOW TABLES' );
4203-
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4204-
$this->assertSame( '13', $result[0]->{'FOUND_ROWS()'} );
4205-
}
4189+
/**
4190+
* @dataProvider stringifyFetchesProvider
4191+
*/
4192+
public function testFoundRowsWithoutSqlCalcFoundRows( bool $stringify_fetches ): void {
4193+
$this->engine->setAttribute( PDO::ATTR_STRINGIFY_FETCHES, $stringify_fetches );
42064194

4207-
public function testFoundRowsWithoutSqlCalcFoundRows(): void {
42084195
$this->assertQuery( 'DROP TABLE _dates' );
42094196
$this->assertQuery( 'DROP TABLE _options' );
42104197

42114198
// CREATE TABLE
42124199
$this->assertQuery( 'CREATE TABLE t (id INT PRIMARY KEY, value TEXT, INDEX idx_value (value))' );
42134200
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4214-
$this->assertSame( '0', $result[0]->{'FOUND_ROWS()'} );
4201+
$this->assertEquals( 0, $result[0]->{'FOUND_ROWS()'} );
42154202

42164203
// INSERT
4217-
$this->assertQuery( 'INSERT INTO t (id) VALUES (1), (2), (3)' );
4204+
$this->assertQuery( 'INSERT INTO t (id) VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12)' );
42184205
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4219-
$this->assertSame( '0', $result[0]->{'FOUND_ROWS()'} );
4206+
$this->assertEquals( 0, $result[0]->{'FOUND_ROWS()'} );
42204207

42214208
// SELECT
42224209
$this->assertQuery( 'SELECT * FROM t' );
42234210
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4224-
$this->assertSame( '3', $result[0]->{'FOUND_ROWS()'} );
4211+
$this->assertEquals( 12, $result[0]->{'FOUND_ROWS()'} );
42254212

42264213
// DESCRIBE
42274214
$this->assertQuery( 'DESCRIBE t' );
42284215
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4229-
$this->assertSame( '2', $result[0]->{'FOUND_ROWS()'} );
4216+
$this->assertEquals( 2, $result[0]->{'FOUND_ROWS()'} );
42304217

42314218
// SHOW COLLATION
42324219
$this->assertQuery( 'SHOW COLLATION' );
42334220
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4234-
$this->assertSame( '8', $result[0]->{'FOUND_ROWS()'} );
4221+
$this->assertEquals( 8, $result[0]->{'FOUND_ROWS()'} );
42354222

42364223
// SHOW DATABASES
42374224
$this->assertQuery( 'SHOW DATABASES' );
42384225
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4239-
$this->assertSame( '2', $result[0]->{'FOUND_ROWS()'} );
4226+
$this->assertEquals( 2, $result[0]->{'FOUND_ROWS()'} );
42404227

42414228
// SHOW COLUMNS
42424229
$this->assertQuery( 'SHOW COLUMNS FROM t' );
42434230
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4244-
$this->assertSame( '2', $result[0]->{'FOUND_ROWS()'} );
4231+
$this->assertEquals( 2, $result[0]->{'FOUND_ROWS()'} );
42454232

42464233
// SHOW CREATE TABLE
42474234
$this->assertQuery( 'SHOW CREATE TABLE t' );
42484235
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4249-
$this->assertSame( '1', $result[0]->{'FOUND_ROWS()'} );
4236+
$this->assertEquals( 1, $result[0]->{'FOUND_ROWS()'} );
42504237

42514238
// SHOW CREATE TABLE with non-existent table
42524239
$this->assertQuery( 'SHOW CREATE TABLE non_existent_table' );
42534240
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4254-
$this->assertSame( '0', $result[0]->{'FOUND_ROWS()'} );
4241+
$this->assertEquals( 0, $result[0]->{'FOUND_ROWS()'} );
42554242

42564243
// SHOW INDEX
42574244
$this->assertQuery( 'SHOW INDEX FROM t' );
42584245
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4259-
$this->assertSame( '2', $result[0]->{'FOUND_ROWS()'} );
4246+
$this->assertEquals( 2, $result[0]->{'FOUND_ROWS()'} );
42604247

42614248
// SHOW GRANTS
42624249
$this->assertQuery( 'SHOW GRANTS' );
42634250
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4264-
$this->assertSame( '1', $result[0]->{'FOUND_ROWS()'} );
4251+
$this->assertEquals( 1, $result[0]->{'FOUND_ROWS()'} );
42654252

42664253
// SHOW TABLE STATUS
42674254
$r = $this->assertQuery( 'SHOW TABLE STATUS' );
42684255
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4269-
$this->assertSame( '1', $result[0]->{'FOUND_ROWS()'} );
4256+
$this->assertEquals( 1, $result[0]->{'FOUND_ROWS()'} );
42704257

4271-
// SHOW TABLES
4258+
// SHOW TABLES (with a two-digit count)
4259+
for ( $i = 1; $i <= 10; $i++ ) {
4260+
$this->assertQuery( "CREATE TABLE t$i (id INT)" );
4261+
}
42724262
$this->assertQuery( 'SHOW TABLES' );
42734263
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4274-
$this->assertSame( '1', $result[0]->{'FOUND_ROWS()'} );
4264+
$this->assertEquals( 11, $result[0]->{'FOUND_ROWS()'} );
42754265

42764266
// SHOW VARIABLES
42774267
$this->assertQuery( 'SHOW VARIABLES' );
42784268
$result = $this->assertQuery( 'SELECT FOUND_ROWS()' );
4279-
$this->assertSame( '2', $result[0]->{'FOUND_ROWS()'} );
4269+
$this->assertEquals( 2, $result[0]->{'FOUND_ROWS()'} );
42804270
}
42814271

42824272
public function testComplexSelectBasedOnDates() {

0 commit comments

Comments
 (0)