Skip to content

Commit

Permalink
better unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spipu committed Apr 3, 2022
1 parent c402630 commit 1bfc9bc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ php:
- 7.3
- 7.4
- 8.0
- 8.1

before_script:
- composer selfupdate
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Html2Pdf

Html2Pdf is a HTML to PDF converter written in PHP, and compatible with PHP **5.6** to **8.0**.
Html2Pdf is a HTML to PDF converter written in PHP, and compatible with PHP **5.6** to **8.1**.

It allows the conversion of valid HTML in PDF format, to generate documents like invoices, documentation, ...

Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"tecnickcom/tcpdf": "^6.3"
},
"require-dev": {
"phpunit/phpunit": "^5.0",
"phake/phake": "^2.0"
"phpunit/phpunit": "^5.0"
},
"suggest": {
"fagundes/zff-html2pdf": "if you need to integrate Html2Pdf with Zend Framework 2 (zf2)",
Expand Down
18 changes: 7 additions & 11 deletions src/Tests/Html2PdfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,26 @@

namespace Spipu\Html2Pdf\Tests;

use Phake;
use Spipu\Html2Pdf\Html2Pdf;

/**
* Class Html2PdfTest
*/
class Html2PdfTest extends AbstractTest
{
public function testExtensionTag()
{
$tag = Phake::mock('Spipu\Html2Pdf\Tag\TagInterface');
Phake::when($tag)->getName()->thenReturn('test_tag');
$tag = $this->createMock('Spipu\Html2Pdf\Tag\TagInterface');
$tag->expects($this->any())->method('getName')->willReturn('test_tag');
$tag->expects($this->exactly(4))->method('open');
$tag->expects($this->exactly(2))->method('close');

$extension = Phake::mock('Spipu\Html2Pdf\Extension\ExtensionInterface');
Phake::when($extension)->getName()->thenReturn('test');
Phake::when($extension)->getTags()->thenReturn(array($tag));
$extension = $this->createMock('Spipu\Html2Pdf\Extension\ExtensionInterface');
$extension->expects($this->any())->method('getName')->willReturn('test');
$extension->expects($this->any())->method('getTags')->willReturn(array($tag));

$object = $this->getObject();

$object->addExtension($extension);
$object->writeHTML('<div><test_tag>Hello</test_tag></div>');

Phake::verify($tag, Phake::times(4))->open;
Phake::verify($tag, Phake::times(2))->close;
}

public function testSecurityGood()
Expand Down
3 changes: 1 addition & 2 deletions src/Tests/SvgDrawerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Spipu\Html2Pdf\Tests;

use Phake;
use Spipu\Html2Pdf\CssConverter;
use Spipu\Html2Pdf\SvgDrawer;

Expand All @@ -18,7 +17,7 @@ class SvgDrawerTest extends \PHPUnit_Framework_TestCase

public function setUp()
{
$myPdf = Phake::mock('Spipu\Html2Pdf\MyPdf');
$myPdf = $this->createMock('Spipu\Html2Pdf\MyPdf');

$cssConverter = new CssConverter();

Expand Down

0 comments on commit 1bfc9bc

Please sign in to comment.