From 38f5efc4f0b4fa9c9ac650f80b91f7a01571dfb4 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Mon, 9 Oct 2023 19:19:47 +0200 Subject: [PATCH] [BUGFIX] Make a flaky test not timing-sensitive anymore (#2211) Also clean up another test and make the timing-related tests more strict. Fixes #2130 --- .../NewsRowInitializeNewTest.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Tests/Unit/Backend/FormDataProvider/NewsRowInitializeNewTest.php b/Tests/Unit/Backend/FormDataProvider/NewsRowInitializeNewTest.php index 8aad9a9806..3b5d5e05eb 100644 --- a/Tests/Unit/Backend/FormDataProvider/NewsRowInitializeNewTest.php +++ b/Tests/Unit/Backend/FormDataProvider/NewsRowInitializeNewTest.php @@ -11,6 +11,8 @@ use GeorgRinger\News\Backend\FormDataProvider\NewsRowInitializeNew; use GeorgRinger\News\Domain\Model\Dto\EmConfiguration; +use TYPO3\CMS\Core\Context\Context; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\BaseTestCase; class NewsRowInitializeNewTest extends BaseTestCase @@ -37,7 +39,7 @@ public function dateTimeIsFilled(): void 'command' => 'new', 'tableName' => 'tx_news_domain_model_news', 'databaseRow' => [ - 'datetime' => $GLOBALS['EXEC_TIME'], + 'datetime' => GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp'), ], ]; @@ -58,12 +60,8 @@ public function dateTimeIsNotFilledIfSetInExtensionManagerConfiguration(): void 'command' => 'new', 'tableName' => 'tx_news_domain_model_news', ]; - $expected = [ - 'command' => 'new', - 'tableName' => 'tx_news_domain_model_news', - ]; - self::assertEquals($expected, $mockedProvider->addData($result)); + self::assertSame($result, $mockedProvider->addData($result)); } /** @@ -91,10 +89,6 @@ public function archiveTimeIsFilled(): void ], ]; - $expected = $result; - $expected['databaseRow']['datetime'] = $GLOBALS['EXEC_TIME']; - $expected['databaseRow']['archive'] = strtotime('+10 days'); - - self::assertEquals($expected, $provider->addData($result)); + self::assertSame(strtotime('+10 days'), $provider->addData($result)['databaseRow']['archive']); } }