Skip to content

Commit

Permalink
Added test for "PdfDocument::isLink()" function.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentmuller committed Jul 31, 2024
1 parent dce7a20 commit e61b3a7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Added test for `PdfDocument::isLink()` function.
- Reworked `putFonts` function of `PdfDocument` class.
- Added test for `PdfEnumDefaultInterface`.
- Removed covers class attribute.
Expand Down
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions tests/PdfDocPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,21 @@

namespace fpdf;

use PHPUnit\Framework\Attributes\DataProvider;

class PdfDocPropertiesTest extends AbstractPdfDocTestCase
{
public static function getIsLinks(): \Generator
{
yield [null, false];
yield ['', false];
yield [0, false];
yield [-1, false];

yield ['link', true];
yield [1, true];
}

public function testAddPageClosed(): void
{
self::expectException(PdfException::class);
Expand Down Expand Up @@ -144,6 +157,13 @@ public function testHttpEncode(): void
$doc->output(PdfDestination::DOWNLOAD, '¢FAKE¢');
}

#[DataProvider('getIsLinks')]
public function testIsLink(string|int|null $link, bool $expected): void
{
$actual = PdfDocument::isLink($link);
self::assertSame($expected, $actual);
}

public function testLastHeight(): void
{
$doc = $this->createDocument();
Expand Down

0 comments on commit e61b3a7

Please sign in to comment.