Skip to content

Commit

Permalink
added more information to PagesTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
k00ni authored Apr 29, 2024
1 parent ab1c62b commit ff83e11
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions tests/PHPUnit/Integration/PagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
class PagesDummy extends Pages
{
/**
* The purpose of this function is to bypass the tedious
* work to setup instances which lead to a valid $fonts variable.
*
* @param array<\Smalot\PdfParser\Font> $fonts
*
* @return void
Expand All @@ -60,13 +63,20 @@ class PagesTest extends TestCase
/**
* If fonts are not stored in Page instances but in the Pages instance.
*
* Pages
* | `--- Font[]
* |
* |
* `--+ Page1 (no fonts)
* `--+ ...
*
* @see https://github.com/smalot/pdfparser/pull/698
*/
public function testPullRequest698NoFontsSet(): void
{
$document = $this->createMock(Document::class);

// create a Page mock and tell PHPUnit that its setFonts has to be called once
// Create a Page mock and tell PHPUnit that its setFonts has to be called once
// otherwise an error is raised
$page1 = $this->createMock(Page::class);
$page1->expects($this->once())->method('setFonts');
Expand All @@ -80,15 +90,26 @@ public function testPullRequest698NoFontsSet(): void

$font1 = $this->createMock(Font::class);

// Preset fonts variable so we don't have to prepare all the
// prerequisites manually (like creating a Ressources instance
// with Font instances, see Pages::setupFonts())
$pages = new PagesDummy($document, $header);
$pages->setFonts([$font1]);

// we expect setFonts is called on $page1
// We expect setFonts is called on $page1, therefore no assertion here
$pages->getPages(true);
}

/**
* Dont override fonts list in Page, if available.
* Dont override fonts list in a Page instance, if available.
*
* Pages
* | `--- Font[] <=== less important than fonts in Page instance
* |
* |
* `--+ Page1
* `--- Font[] <=== must be kept
* `--+ ...
*
* @see https://github.com/smalot/pdfparser/pull/698
*/
Expand Down

0 comments on commit ff83e11

Please sign in to comment.