Skip to content

Commit

Permalink
Invalid Annotation in Test Member (PHPOffice#2549)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
oleibman authored Jan 15, 2024
1 parent 41cf4eb commit 2f4da6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions tests/PhpWordTests/Element/FormulaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class FormulaTest extends AbstractWebServerEmbeddedTest
{
/**
* @covers \Formula::__construct
* @covers \PhpOffice\PhpWord\Element\Formula::__construct
*/
public function testConstruct(): void
{
Expand All @@ -40,8 +40,8 @@ public function testConstruct(): void
}

/**
* @covers \Formula::getMath
* @covers \Formula::setMath
* @covers \PhpOffice\PhpWord\Element\Formula::getMath
* @covers \PhpOffice\PhpWord\Element\Formula::setMath
*/
public function testMath(): void
{
Expand Down
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 2f4da6e

Please sign in to comment.