Skip to content

Commit f0c357f

Browse files
author
Alexandre Guidet
committed
Merge branch 'dsinn-fix-race-condition-in-test' into hotfix-3.7.1
2 parents 58bde49 + 3228973 commit f0c357f

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

tests/Command/UpDownCommandTest.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,26 +224,34 @@ public function testDownOnly()
224224
$command = self::$application->find('migrate:status');
225225
$commandTester = new CommandTester($command);
226226

227-
$currentDate = date('Y-m-d H:i:s');
227+
$currentTime = time();
228+
$validDates = array();
229+
foreach (range(-1, 1) as $i) {
230+
$validDates[] = date('Y-m-d H:i:s', $currentTime + $i);
231+
}
232+
$dateRegex = '(' . implode('|', $validDates) . ') *';
228233

229234
$commandTester->execute(array(
230235
'command' => $command->getName(),
231236
'env' => 'testing'
232237
));
233238

234-
$expected =<<<EXPECTED
239+
$expected =<<<'EXPECTED'
235240
connected
236241
+----+---------+---------------------+-------------+
237242
| id | version | applied at | description |
238243
+----+---------+---------------------+-------------+
239-
| 0 | | $currentDate | migration |
244+
| 0 | | DATE_REGEX | migration |
240245
| 1 | | | migration |
241-
| 2 | | $currentDate | migration |
246+
| 2 | | DATE_REGEX | migration |
242247
+----+---------+---------------------+-------------+
243248

244249
EXPECTED;
245250

246-
$this->assertEquals($expected, $commandTester->getDisplay());
251+
$pattern = '/^' . preg_quote($expected, '/') . '$/';
252+
$pattern = preg_replace('/DATE_REGEX */', $dateRegex, $pattern);
253+
254+
$this->assertRegExp($pattern, $commandTester->getDisplay());
247255

248256
}
249257

0 commit comments

Comments
 (0)