Skip to content

Commit 738a6a9

Browse files
Merge remote-tracking branch 'origin/MAGETWO-87353' into BorgPR-4-18
2 parents 7ee2c5f + 923411b commit 738a6a9

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

dev/tests/integration/testsuite/Magento/Cms/Model/BlockTest.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Cms\Model\BlockFactory;
1010
use Magento\Framework\ObjectManagerInterface;
1111
use Magento\Framework\Stdlib\DateTime\DateTime;
12+
use Magento\Framework\Stdlib\DateTime\Timezone;
1213
use Magento\TestFramework\Helper\Bootstrap;
1314
use PHPUnit\Framework\TestCase;
1415

@@ -81,18 +82,26 @@ public function testGetByIdentifier(array $blockData)
8182
*/
8283
public function testUpdateTime(array $blockData)
8384
{
85+
8486
# Prepare and save the temporary block
85-
$tempBlock = $this->blockFactory->create();
87+
$beforeTimestamp = $this->objectManager->get(DateTime::class)->timestamp();
88+
$tempBlock = $this->blockFactory->create();
8689
$tempBlock->setData($blockData);
8790
$this->blockResource->save($tempBlock);
8891

8992
# Load previously created block and compare identifiers
90-
$storeId = reset($blockData['stores']);
91-
$block = $this->blockIdentifier->execute($blockData['identifier'], $storeId);
92-
$date = $this->objectManager->get(DateTime::class)->date();
93-
$this->markTestIncomplete('MAGETWO-87353: \Magento\Cms\Model\BlockTest::testUpdateTime randomly fails on CI. '
94-
. 'Invalid assertion. Application node timestamp may significantly differ from DB node.');
95-
$this->assertEquals($date, $block->getUpdateTime());
93+
$storeId = reset($blockData['stores']);
94+
$block = $this->blockIdentifier->execute($blockData['identifier'], $storeId);
95+
$afterTimestamp = $this->objectManager->get(DateTime::class)->timestamp();
96+
$blockTimestamp = strtotime($block->getUpdateTime());
97+
98+
/*
99+
* This test used to fail due to a race condition @see MAGETWO-87353
100+
* The DB time would be one second older than the check time. The new check allows the DB time
101+
* to be between the test start time and right before the assertion.
102+
*/
103+
$this->assertGreaterThanOrEqual($beforeTimestamp, $blockTimestamp);
104+
$this->assertLessThanOrEqual($afterTimestamp, $blockTimestamp);
96105
}
97106

98107
/**

0 commit comments

Comments
 (0)