You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DataProviders get called before the execution of the first test, which leads to issues if we wanna check for a tight timespan.
To illustrate the issue:
class TimespanTest extends TestCase
{
public function testWaitFor1Minute(): void
{
sleep(60);
}
/**
* @dataProvider timespanProvider
*/
public function testIsInTimespan(string $before, string $after): void
{
$now = (new \DateTime())->format('Y-m-d H:i:s');
self::assertLessThan($now, $before);
self::assertGreaterThan($now, $after);
}
public function timespanProvider(): array
{
$format = "Y-m-d H:i:s";
$oneMinuteBeforeNow = (new \DateTime())->sub(new \DateInterval('PT1M'))->format($format);
$oneMinuteAfterNow = (new \DateTime())->add(new \DateInterval('PT1M'))->format($format);
return [
[$oneMinuteBeforeNow, $oneMinuteAfterNow]
];
}
}
In my opinion this should not result in a failing test. And i do not see any benefit in executing all the data providers of the whole project beforehand.
The text was updated successfully, but these errors were encountered:
DataProviders get called before the execution of the first test, which leads to issues if we wanna check for a tight timespan.
To illustrate the issue:
In my opinion this should not result in a failing test. And i do not see any benefit in executing all the data providers of the whole project beforehand.
The text was updated successfully, but these errors were encountered: