Skip to content

Commit

Permalink
better unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spipu committed Feb 2, 2023
1 parent 17f53d1 commit 9718fd4
Show file tree
Hide file tree
Showing 56 changed files with 218 additions and 140 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [5.2.7](https://github.com/spipu/html2pdf/compare/v5.2.6...v5.2.7) - 2023-02-02

* fix phunit compatibility

## [5.2.6](https://github.com/spipu/html2pdf/compare/v5.2.5...v5.2.6) - 2023-01-28

* add support of PHP 8.1 and PHP 8.2
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
bootstrap="./src/Tests/bootstrap.php"
bootstrap="./src/Tests/CrossVersionCompatibility/bootstrap.php"
colors="true"
backupGlobals="false"
backupStaticAttributes="false"
Expand Down
2 changes: 1 addition & 1 deletion src/Html2Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function getVersionAsArray()
return array(
'major' => 5,
'minor' => 2,
'revision' => 6
'revision' => 7
);
}

Expand Down
9 changes: 2 additions & 7 deletions src/Tests/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
namespace Spipu\Html2Pdf\Tests;

use Spipu\Html2Pdf\Html2Pdf;

if (HTML2PDF_PHPUNIT_VERSION === 9) {
require_once 'CrossVersionCompatibility/PhpUnit9/AbstractTestCase.php';
} else {
require_once 'CrossVersionCompatibility/PhpUnit5/AbstractTestCase.php';
}
use Spipu\Html2Pdf\Tests\CrossVersionCompatibility\AbstractTestCase;

/**
* Class AbstractTest
*/
abstract class AbstractTest extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\AbstractTestCase
abstract class AbstractTest extends AbstractTestCase
{
/**
* Get the object to test
Expand Down
13 changes: 13 additions & 0 deletions src/Tests/CrossVersionCompatibility/AbstractTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;

if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class AbstractTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\AbstractTestCase
{
}
} else {
abstract class AbstractTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\AbstractTestCase
{
}
}
13 changes: 13 additions & 0 deletions src/Tests/CrossVersionCompatibility/CssConverterTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;

if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class CssConverterTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\CssConverterTestCase
{
}
} else {
abstract class CssConverterTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\CssConverterTestCase
{
}
}
13 changes: 13 additions & 0 deletions src/Tests/CrossVersionCompatibility/ExceptionFormatterTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;

if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class ExceptionFormatterTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\ExceptionFormatterTestCase
{
}
} else {
abstract class ExceptionFormatterTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\ExceptionFormatterTestCase
{
}
}
13 changes: 13 additions & 0 deletions src/Tests/CrossVersionCompatibility/HtmlTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;

if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class HtmlTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\HtmlTestCase
{
}
} else {
abstract class HtmlTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\HtmlTestCase
{
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;

use Spipu\Html2Pdf\Html2Pdf;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;

use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\CssConverter;

abstract class CssConverterTestCase extends \PHPUnit_Framework_TestCase
abstract class CssConverterTestCase extends PHPUnit_Framework_TestCase
{
/**
* @var CssConverter
*/
protected $cssConverter;

public function setUp()
protected function setUp()
{
$this->cssConverter = new CssConverter();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
* @copyright 2017 Laurent MINGUET
*/

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;

abstract class ExceptionFormatterTestCase extends \PHPUnit_Framework_TestCase
use PHPUnit_Framework_TestCase;

abstract class ExceptionFormatterTestCase extends PHPUnit_Framework_TestCase
{
}
5 changes: 3 additions & 2 deletions src/Tests/CrossVersionCompatibility/PhpUnit5/HtmlTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
* @copyright 2017 Laurent MINGUET
*/

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;

use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\Parsing\Html;

abstract class HtmlTestCase extends \PHPUnit_Framework_TestCase
abstract class HtmlTestCase extends PHPUnit_Framework_TestCase
{
/**
* @var Html
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;

use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\CssConverter;
use Spipu\Html2Pdf\SvgDrawer;

abstract class SvgDrawerTestCase extends \PHPUnit_Framework_TestCase
abstract class SvgDrawerTestCase extends PHPUnit_Framework_TestCase
{
/**
* @var SvgDrawer
*/
protected $svgDrawer;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* @copyright 2017 Laurent MINGUET
*/

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;

use Spipu\Html2Pdf\Parsing\Node;
use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\Parsing\TagParser;

abstract class TagParserTestCase extends \PHPUnit_Framework_TestCase
abstract class TagParserTestCase extends PHPUnit_Framework_TestCase
{
/**
* @var TagParser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
* @copyright 2017 Laurent MINGUET
*/

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5;

use PHPUnit_Framework_TestCase;
use Spipu\Html2Pdf\Parsing\TextParser;

abstract class TextParserTestCase extends \PHPUnit_Framework_TestCase
abstract class TextParserTestCase extends PHPUnit_Framework_TestCase
{
/**
* @var TextParser
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;

use PHPUnit\Framework\TestCase;
use Spipu\Html2Pdf\Html2Pdf;

abstract class AbstractTestCase extends \PHPUnit\Framework\TestCase
abstract class AbstractTestCase extends TestCase
{
use \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\AssertContains;
use AssertContains;

/**
* @var Html2Pdf
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;

use PHPUnit\Framework\TestCase;
use Spipu\Html2Pdf\CssConverter;

abstract class CssConverterTestCase extends \PHPUnit\Framework\TestCase
abstract class CssConverterTestCase extends TestCase
{
/**
* @var CssConverter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
* @copyright 2017 Laurent MINGUET
*/

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;

abstract class ExceptionFormatterTestCase extends \PHPUnit\Framework\TestCase
use PHPUnit\Framework\TestCase;

abstract class ExceptionFormatterTestCase extends TestCase
{
use \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\AssertContains;
use AssertContains;
}
5 changes: 3 additions & 2 deletions src/Tests/CrossVersionCompatibility/PhpUnit9/HtmlTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
* @copyright 2017 Laurent MINGUET
*/

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;

use PHPUnit\Framework\TestCase;
use Spipu\Html2Pdf\Parsing\Html;

abstract class HtmlTestCase extends \PHPUnit\Framework\TestCase
abstract class HtmlTestCase extends TestCase
{
/**
* @var Html
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;

use PHPUnit\Framework\TestCase;
use Spipu\Html2Pdf\CssConverter;
use Spipu\Html2Pdf\SvgDrawer;

abstract class SvgDrawerTestCase extends \PHPUnit\Framework\TestCase
abstract class SvgDrawerTestCase extends TestCase
{
/**
* @var SvgDrawer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
* @copyright 2017 Laurent MINGUET
*/

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;

use PHPUnit\Framework\TestCase;
use Spipu\Html2Pdf\Parsing\TagParser;

abstract class TagParserTestCase extends \PHPUnit\Framework\TestCase
abstract class TagParserTestCase extends TestCase
{
/**
* @var TagParser
Expand Down
5 changes: 0 additions & 5 deletions src/Tests/CrossVersionCompatibility/PhpUnit9/TestCase.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
* @copyright 2017 Laurent MINGUET
*/

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;
namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9;

use PHPUnit\Framework\TestCase;
use Spipu\Html2Pdf\Parsing\TextParser;

abstract class TextParserTestCase extends \PHPUnit\Framework\TestCase
abstract class TextParserTestCase extends TestCase
{
/**
* @var TextParser
Expand Down
13 changes: 13 additions & 0 deletions src/Tests/CrossVersionCompatibility/SvgDrawerTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;

if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class SvgDrawerTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\SvgDrawerTestCase
{
}
} else {
abstract class SvgDrawerTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\SvgDrawerTestCase
{
}
}
13 changes: 13 additions & 0 deletions src/Tests/CrossVersionCompatibility/TagParserTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;

if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class TagParserTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\TagParserTestCase
{
}
} else {
abstract class TagParserTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\TagParserTestCase
{
}
}
13 changes: 13 additions & 0 deletions src/Tests/CrossVersionCompatibility/TextParserTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Spipu\Html2Pdf\Tests\CrossVersionCompatibility;

if (HTML2PDF_PHPUNIT_VERSION === 9) {
abstract class TextParserTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit9\TextParserTestCase
{
}
} else {
abstract class TextParserTestCase extends \Spipu\Html2Pdf\Tests\CrossVersionCompatibility\PhpUnit5\TextParserTestCase
{
}
}
13 changes: 13 additions & 0 deletions src/Tests/CrossVersionCompatibility/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

require_once __DIR__ . '/../../../vendor/autoload.php';

if (!class_exists('PHPUnit_Framework_TestCase') && version_compare(phpversion(), '7.1') >= 0) {
class PHPUnit_Framework_TestCase extends PHPUnit\Framework\TestCase
{
}

define('HTML2PDF_PHPUNIT_VERSION', 9);
} else {
define('HTML2PDF_PHPUNIT_VERSION', 5);
}
Loading

0 comments on commit 9718fd4

Please sign in to comment.