Skip to content

Commit 2f4da6e

Browse files
authored
Invalid Annotation in Test Member (PHPOffice#2549)
* Invalid Annotation in Test Member PhpUnit cannot parse the `@covers` lines in FormulaTest; they result in warnings in Coverage and Deploy tests. This PR fixes them; no change log entry should be needed. * 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 41cf4eb commit 2f4da6e

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

tests/PhpWordTests/Element/FormulaTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class FormulaTest extends AbstractWebServerEmbeddedTest
3131
{
3232
/**
33-
* @covers \Formula::__construct
33+
* @covers \PhpOffice\PhpWord\Element\Formula::__construct
3434
*/
3535
public function testConstruct(): void
3636
{
@@ -40,8 +40,8 @@ public function testConstruct(): void
4040
}
4141

4242
/**
43-
* @covers \Formula::getMath
44-
* @covers \Formula::setMath
43+
* @covers \PhpOffice\PhpWord\Element\Formula::getMath
44+
* @covers \PhpOffice\PhpWord\Element\Formula::setMath
4545
*/
4646
public function testMath(): void
4747
{

tests/PhpWordTests/PhpWordTest.php

+9-2
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)