-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added compatibility with PHPUnit 9.0
- Loading branch information
1 parent
c002749
commit 2a26c9e
Showing
46 changed files
with
541 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/Tests/CrossVersionCompatibility/PhpUnit5/AbstractTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility; | ||
|
||
use Spipu\Html2Pdf\Html2Pdf; | ||
|
||
abstract class AbstractTestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Html2Pdf | ||
*/ | ||
protected $html2pdf; | ||
|
||
/** | ||
* Executed before each test | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', [0, 0, 0, 0]); | ||
$this->html2pdf->pdf->SetTitle('PhpUnit Test'); | ||
} | ||
|
||
/** | ||
* Executed after each test | ||
*/ | ||
protected function tearDown() | ||
{ | ||
$this->html2pdf->clean(); | ||
$this->html2pdf = null; | ||
} | ||
|
||
public function expectException($exception) | ||
{ | ||
if (method_exists(\PHPUnit_Framework_TestCase::class, 'setExpectedException')) { | ||
$this->setExpectedException($exception); | ||
} | ||
} | ||
|
||
public function expectExceptionMessage($message, $exception = null) | ||
{ | ||
if (method_exists(\PHPUnit_Framework_TestCase::class, 'expectExceptionMessage')) { | ||
parent::expectExceptionMessage($message); | ||
} elseif (method_exists(\PHPUnit_Framework_TestCase::class, 'setExpectedException')) { | ||
$this->setExpectedException($exception, $message); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Tests/CrossVersionCompatibility/PhpUnit5/CssConverterTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility; | ||
|
||
use Spipu\Html2Pdf\CssConverter; | ||
|
||
abstract class CssConverterTestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var CssConverter | ||
*/ | ||
protected $cssConverter; | ||
|
||
public function setUp() | ||
{ | ||
$this->cssConverter = new CssConverter(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Tests/CrossVersionCompatibility/PhpUnit5/ExceptionFormatterTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
/** | ||
* Html2Pdf Library - Tests | ||
* | ||
* HTML => PDF converter | ||
* distributed under the OSL-3.0 License | ||
* | ||
* @package Html2pdf | ||
* @author Laurent MINGUET <[email protected]> | ||
* @copyright 2017 Laurent MINGUET | ||
*/ | ||
|
||
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility; | ||
|
||
abstract class ExceptionFormatterTestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Tests/CrossVersionCompatibility/PhpUnit5/HtmlTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* Html2Pdf Library - Tests | ||
* | ||
* HTML => PDF converter | ||
* distributed under the OSL-3.0 License | ||
* | ||
* @package Html2pdf | ||
* @author Laurent MINGUET <[email protected]> | ||
* @copyright 2017 Laurent MINGUET | ||
*/ | ||
|
||
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility; | ||
|
||
use Spipu\Html2Pdf\Parsing\Html; | ||
|
||
abstract class HtmlTestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Html | ||
*/ | ||
protected $object; | ||
|
||
protected function setUp() | ||
{ | ||
$textParser = $this->getMockBuilder('Spipu\Html2Pdf\Parsing\TextParser') | ||
->disableOriginalConstructor() | ||
->setMethods(['prepareTxt']) | ||
->getMock(); | ||
|
||
$textParser | ||
->expects($this->any()) | ||
->method('prepareTxt') | ||
->will($this->returnCallback([$this, 'mockPrepareTxt'])); | ||
|
||
$this->object = new Html($textParser); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Tests/CrossVersionCompatibility/PhpUnit5/SvgDrawerTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility; | ||
|
||
use Spipu\Html2Pdf\CssConverter; | ||
use Spipu\Html2Pdf\SvgDrawer; | ||
|
||
abstract class SvgDrawerTestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var SvgDrawer | ||
*/ | ||
protected $svgDrawer; | ||
|
||
public function setUp() | ||
{ | ||
$myPdf = $this->createMock('Spipu\Html2Pdf\MyPdf'); | ||
|
||
$cssConverter = new CssConverter(); | ||
|
||
$this->svgDrawer = new SvgDrawer($myPdf, $cssConverter); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/Tests/CrossVersionCompatibility/PhpUnit5/TagParserTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* Html2Pdf Library - Tests | ||
* | ||
* HTML => PDF converter | ||
* distributed under the OSL-3.0 License | ||
* | ||
* @package Html2pdf | ||
* @author Laurent MINGUET <[email protected]> | ||
* @copyright 2017 Laurent MINGUET | ||
*/ | ||
|
||
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility; | ||
|
||
use Spipu\Html2Pdf\Parsing\Node; | ||
use Spipu\Html2Pdf\Parsing\TagParser; | ||
|
||
abstract class TagParserTestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var TagParser | ||
*/ | ||
protected $parser; | ||
|
||
protected function setUp() | ||
{ | ||
$textParser = $this->getMockBuilder('Spipu\Html2Pdf\Parsing\TextParser') | ||
->disableOriginalConstructor() | ||
->setMethods(['prepareTxt']) | ||
->getMock(); | ||
|
||
$textParser | ||
->expects($this->any()) | ||
->method('prepareTxt') | ||
->will($this->returnCallback([$this, 'mockPrepareTxt'])); | ||
|
||
$this->parser = new TagParser($textParser); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Tests/CrossVersionCompatibility/PhpUnit5/TextParserTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Html2Pdf Library - Tests | ||
* | ||
* HTML => PDF converter | ||
* distributed under the OSL-3.0 License | ||
* | ||
* @package Html2pdf | ||
* @author Laurent MINGUET <[email protected]> | ||
* @copyright 2017 Laurent MINGUET | ||
*/ | ||
|
||
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility; | ||
|
||
use Spipu\Html2Pdf\Parsing\TextParser; | ||
|
||
abstract class TextParserTestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var TextParser | ||
*/ | ||
protected $parser; | ||
|
||
protected function setUp() | ||
{ | ||
$this->parser = new TextParser(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/Tests/CrossVersionCompatibility/PhpUnit9/AbstractTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility; | ||
|
||
use Spipu\Html2Pdf\Html2Pdf; | ||
|
||
abstract class AbstractTestCase extends \PHPUnit\Framework\TestCase | ||
{ | ||
use \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\AssertContains; | ||
|
||
/** | ||
* @var Html2Pdf | ||
*/ | ||
protected $html2pdf; | ||
|
||
/** | ||
* Executed before each test | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->html2pdf = new Html2Pdf('P', 'A4', 'fr', true, 'UTF-8', [0, 0, 0, 0]); | ||
$this->html2pdf->pdf->SetTitle('PhpUnit Test'); | ||
} | ||
|
||
/** | ||
* Executed after each test | ||
*/ | ||
protected function tearDown(): void | ||
{ | ||
$this->html2pdf->clean(); | ||
$this->html2pdf = null; | ||
} | ||
|
||
public function expectExceptionMessage($message, $exception = null): void | ||
{ | ||
// Yes, we ignore $exception | ||
parent::expectExceptionMessage($message); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Tests/CrossVersionCompatibility/PhpUnit9/AssertContains.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9; | ||
|
||
trait AssertContains | ||
{ | ||
public static function assertContains($needle, $haystack, string $message = ''): void | ||
{ | ||
if (is_string($haystack)) { | ||
parent::assertStringContainsString($needle, $haystack, $message); | ||
} else { | ||
parent::assertContains($needle, $haystack, $message); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Tests/CrossVersionCompatibility/PhpUnit9/CssConverterTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility; | ||
|
||
use Spipu\Html2Pdf\CssConverter; | ||
|
||
abstract class CssConverterTestCase extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var CssConverter | ||
*/ | ||
protected $cssConverter; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->cssConverter = new CssConverter(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Tests/CrossVersionCompatibility/PhpUnit9/ExceptionFormatterTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* Html2Pdf Library - Tests | ||
* | ||
* HTML => PDF converter | ||
* distributed under the OSL-3.0 License | ||
* | ||
* @package Html2pdf | ||
* @author Laurent MINGUET <[email protected]> | ||
* @copyright 2017 Laurent MINGUET | ||
*/ | ||
|
||
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility; | ||
|
||
abstract class ExceptionFormatterTestCase extends \PHPUnit\Framework\TestCase | ||
{ | ||
use \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\AssertContains; | ||
} |
Oops, something went wrong.