Skip to content

Commit

Permalink
Tweak One Test
Browse files Browse the repository at this point in the history
Fluke failure in CI push.
  • Loading branch information
oleibman committed Jan 15, 2025
1 parent 098b848 commit 51f774c
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions tests/PhpSpreadsheetTests/Document/PropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,16 @@ public function testSetCreator(): void
*/
public function testSetCreated(null|int $expectedCreationTime, null|int|string $created): void
{
$expectedCreationTime = $expectedCreationTime ?? $this->startTime;

$this->properties->setCreated($created);
if ($expectedCreationTime === null) {
do {
// loop to avoid rare situation where timestamp changes
$expectedCreationTime = (float) (new DateTime())->format('U');
$this->properties->setCreated($created);
$endTime = (float) (new DateTime())->format('U');
} while ($expectedCreationTime !== $endTime);
} else {
$this->properties->setCreated($created);
}
self::assertEquals($expectedCreationTime, $this->properties->getCreated());
}

Expand All @@ -78,9 +85,16 @@ public function testSetModifier(): void
*/
public function testSetModified(mixed $expectedModifiedTime, null|int|string $modified): void
{
$expectedModifiedTime = $expectedModifiedTime ?? $this->startTime;

$this->properties->setModified($modified);
if ($expectedModifiedTime === null) {
do {
// loop to avoid rare situation where timestamp changes
$expectedModifiedTime = (float) (new DateTime())->format('U');
$this->properties->setModified($modified);
$endTime = (float) (new DateTime())->format('U');
} while ($expectedModifiedTime !== $endTime);
} else {
$this->properties->setModified($modified);
}
self::assertEquals($expectedModifiedTime, $this->properties->getModified());
}

Expand Down

0 comments on commit 51f774c

Please sign in to comment.