Skip to content

Commit 87039f7

Browse files
committed
adjusting test
1 parent 97f2c69 commit 87039f7

File tree

1 file changed

+48
-18
lines changed

1 file changed

+48
-18
lines changed

tests/database/Mvc/Model/ToArrayCest.php

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626

2727
use function date;
2828
use function getOptionsMysql;
29+
use function phpversion;
2930
use function uniqid;
31+
use function version_compare;
32+
33+
use const PHP_VERSION;
3034

3135
class ToArrayCest
3236
{
@@ -309,24 +313,50 @@ public function mvcModelToArrayExecuteColumnNotInColumnMap(DatabaseTester $I)
309313
$result->next();
310314
$result->rewind();
311315

312-
$expected = [
313-
[
314-
'id' => '4',
315-
'cst_id' => '1',
316-
'status_flag' => '0',
317-
'title' => $title,
318-
'total' => '111.26',
319-
'created_at' => $date,
320-
],
321-
[
322-
'id' => '5',
323-
'cst_id' => '2',
324-
'status_flag' => '1',
325-
'title' => $title,
326-
'total' => '222.19',
327-
'created_at' => $date,
328-
],
329-
];
316+
/**
317+
* This needs to be here because of how PDO works in PHP 8.0 vs 8.1+
318+
*/
319+
if (version_compare(PHP_VERSION, '8.1.0', '<')) {
320+
// PHP 8.0.x
321+
$expected = [
322+
[
323+
'id' => '4',
324+
'cst_id' => '1',
325+
'status_flag' => '0',
326+
'title' => $title,
327+
'total' => '111.26',
328+
'created_at' => $date,
329+
],
330+
[
331+
'id' => '5',
332+
'cst_id' => '2',
333+
'status_flag' => '1',
334+
'title' => $title,
335+
'total' => '222.19',
336+
'created_at' => $date,
337+
],
338+
];
339+
} else {
340+
// PHP 8.1.x+
341+
$expected = [
342+
[
343+
'id' => 4,
344+
'cst_id' => 1,
345+
'status_flag' => 0,
346+
'title' => $title,
347+
'total' => 111.26,
348+
'created_at' => $date,
349+
],
350+
[
351+
'id' => 5,
352+
'cst_id' => 2,
353+
'status_flag' => 1,
354+
'title' => $title,
355+
'total' => 222.19,
356+
'created_at' => $date,
357+
],
358+
];
359+
}
330360
$actual = $result->toArray();
331361
$I->assertSame($expected, $actual);
332362
}

0 commit comments

Comments
 (0)