Skip to content

Commit f92acf1

Browse files
committed
Fluke Failure
PhpWordTest ran in such a way that `new PhpWord()` and `new DocInfo()` happened in different seconds. Almost impossible, but easy enough to prevent.
1 parent c609fa3 commit f92acf1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/PhpWordTests/PhpWordTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
namespace PhpOffice\PhpWordTests;
1919

2020
use BadMethodCallException;
21+
use DateTimeImmutable;
2122
use PhpOffice\PhpWord\Metadata\DocInfo;
2223
use PhpOffice\PhpWord\PhpWord;
2324
use PhpOffice\PhpWord\Settings;
@@ -35,8 +36,14 @@ class PhpWordTest extends \PHPUnit\Framework\TestCase
3536
*/
3637
public function testConstruct(): void
3738
{
38-
$phpWord = new PhpWord();
39-
self::assertEquals(new DocInfo(), $phpWord->getDocInfo());
39+
do {
40+
$dtStart = new DateTimeImmutable();
41+
$startSecond = $dtStart->format('s');
42+
$phpWord = new PhpWord();
43+
$docInfo = new DocInfo();
44+
$endSecond = (new DateTimeImmutable('now'))->format('s');
45+
} while ($startSecond !== $endSecond);
46+
self::assertEquals($docInfo, $phpWord->getDocInfo());
4047
self::assertEquals(Settings::DEFAULT_FONT_NAME, $phpWord->getDefaultFontName());
4148
self::assertEquals(Settings::DEFAULT_FONT_SIZE, $phpWord->getDefaultFontSize());
4249
}

0 commit comments

Comments
 (0)