Skip to content

Commit

Permalink
Fluke Failure
Browse files Browse the repository at this point in the history
PhpWordTest ran in such a way that `new PhpWord()` and `new DocInfo()` happened in different seconds. Almost impossible, but easy enough to prevent.
  • Loading branch information
oleibman committed Jan 15, 2024
1 parent c609fa3 commit f92acf1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/PhpWordTests/PhpWordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace PhpOffice\PhpWordTests;

use BadMethodCallException;
use DateTimeImmutable;
use PhpOffice\PhpWord\Metadata\DocInfo;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Settings;
Expand All @@ -35,8 +36,14 @@ class PhpWordTest extends \PHPUnit\Framework\TestCase
*/
public function testConstruct(): void
{
$phpWord = new PhpWord();
self::assertEquals(new DocInfo(), $phpWord->getDocInfo());
do {
$dtStart = new DateTimeImmutable();
$startSecond = $dtStart->format('s');
$phpWord = new PhpWord();
$docInfo = new DocInfo();
$endSecond = (new DateTimeImmutable('now'))->format('s');
} while ($startSecond !== $endSecond);
self::assertEquals($docInfo, $phpWord->getDocInfo());
self::assertEquals(Settings::DEFAULT_FONT_NAME, $phpWord->getDefaultFontName());
self::assertEquals(Settings::DEFAULT_FONT_SIZE, $phpWord->getDefaultFontSize());
}
Expand Down

0 comments on commit f92acf1

Please # to comment.