Skip to content

Commit 5b4032e

Browse files
committed
Reflect SQLite < 3.33.0 edge case behavior in tests
1 parent 9875394 commit 5b4032e

File tree

1 file changed

+53
-34
lines changed

1 file changed

+53
-34
lines changed

tests/WP_SQLite_Driver_Metadata_Tests.php

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -251,51 +251,70 @@ public function testCheckTable() {
251251
$result
252252
);
253253

254+
/**
255+
* With SQLite < 3.33.0, the integrity check operation doesn't throw
256+
* an error for missing tables. Let's reflect this in the assertions.
257+
*/
258+
$is_strict_integrity_check_supported = version_compare( $this->engine->get_sqlite_version(), '3.33.0', '>=' );
259+
254260
// A missing table.
255-
$result = $this->assertQuery( 'CHECK TABLE missing' );
256-
$this->assertEquals(
257-
array(
258-
(object) array(
259-
'Table' => 'wp.missing',
260-
'Op' => 'check',
261-
'Msg_type' => 'Error',
262-
'Msg_text' => "Table 'missing' doesn't exist",
263-
),
264-
(object) array(
265-
'Table' => 'wp.missing',
266-
'Op' => 'check',
267-
'Msg_type' => 'status',
268-
'Msg_text' => 'Operation failed',
269-
),
261+
$result = $this->assertQuery( 'CHECK TABLE missing' );
262+
$expected = array(
263+
(object) array(
264+
'Table' => 'wp.missing',
265+
'Op' => 'check',
266+
'Msg_type' => 'Error',
267+
'Msg_text' => "Table 'missing' doesn't exist",
268+
),
269+
(object) array(
270+
'Table' => 'wp.missing',
271+
'Op' => 'check',
272+
'Msg_type' => 'status',
273+
'Msg_text' => 'Operation failed',
270274
),
271-
$result
272275
);
273276

277+
if ( ! $is_strict_integrity_check_supported ) {
278+
$expected = array();
279+
}
280+
281+
$this->assertEquals( $expected, $result );
282+
274283
// One good and one missing table.
275-
$result = $this->assertQuery( 'CHECK TABLE t1, missing' );
276-
$this->assertEquals(
277-
array(
284+
$result = $this->assertQuery( 'CHECK TABLE t1, missing' );
285+
$expected = array(
286+
(object) array(
287+
'Table' => 'wp.t1',
288+
'Op' => 'check',
289+
'Msg_type' => 'status',
290+
'Msg_text' => 'OK',
291+
),
292+
(object) array(
293+
'Table' => 'wp.missing',
294+
'Op' => 'check',
295+
'Msg_type' => 'Error',
296+
'Msg_text' => "Table 'missing' doesn't exist",
297+
),
298+
(object) array(
299+
'Table' => 'wp.missing',
300+
'Op' => 'check',
301+
'Msg_type' => 'status',
302+
'Msg_text' => 'Operation failed',
303+
),
304+
);
305+
306+
if ( ! $is_strict_integrity_check_supported ) {
307+
$expected = array(
278308
(object) array(
279309
'Table' => 'wp.t1',
280310
'Op' => 'check',
281311
'Msg_type' => 'status',
282312
'Msg_text' => 'OK',
283313
),
284-
(object) array(
285-
'Table' => 'wp.missing',
286-
'Op' => 'check',
287-
'Msg_type' => 'Error',
288-
'Msg_text' => "Table 'missing' doesn't exist",
289-
),
290-
(object) array(
291-
'Table' => 'wp.missing',
292-
'Op' => 'check',
293-
'Msg_type' => 'status',
294-
'Msg_text' => 'Operation failed',
295-
),
296-
),
297-
$result
298-
);
314+
);
315+
}
316+
317+
$this->assertEquals( $expected, $result );
299318
}
300319

301320
public function testOptimizeTable() {

0 commit comments

Comments
 (0)