Skip to content

Commit

Permalink
[BUGFIX] Make a flaky test not timing-sensitive anymore (#2211)
Browse files Browse the repository at this point in the history
Also clean up another test and make the timing-related tests
more strict.

Fixes #2130
  • Loading branch information
oliverklee authored Oct 9, 2023
1 parent 6141a04 commit 38f5efc
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions Tests/Unit/Backend/FormDataProvider/NewsRowInitializeNewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'),
],
];

Expand All @@ -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));
}

/**
Expand Down Expand Up @@ -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']);
}
}

0 comments on commit 38f5efc

Please sign in to comment.