Skip to content

Commit

Permalink
Updated to php8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianKresse committed Dec 3, 2020
1 parent 48387de commit 453e553
Show file tree
Hide file tree
Showing 36 changed files with 240 additions and 282 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,34 @@ jobs:
- name: Install dependencies
run: composer update --dev --no-interaction --prefer-dist --no-progress --no-suggest --ansi

- name: Run phpunit
run: |
./vendor/bin/phpunit
testsPhp8:
name: Run PHP Unit tests (>= 8.0)
runs-on: ubuntu-20.04
strategy:
matrix:
php: ['8.0']
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install mupdf and imagemagick
run: sudo apt-get install mupdf-tools imagemagick

- name: Install php
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"

- name: Upgrade phpunit
run: composer require --dev --with-all-dependencies "phpunit/phpunit=^9.0"

- name: Install dependencies
run: composer update --dev --no-interaction --prefer-dist --no-progress --no-suggest --ansi

- name: Run phpunit
run: |
./vendor/bin/phpunit
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor
/phpstan.phar
/composer.phar
/tests/visual/**/compare/
/tests/visual/**/compare/
/**/.phpunit.result.cache
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
},
"require": {
"php": "^5.6 || ^7.0",
"php": "^5.6 || ^7.0 || ^8.0",
"ext-zlib": "*"
},
"conflict": {
Expand Down
67 changes: 34 additions & 33 deletions composer.lock

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

11 changes: 3 additions & 8 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<phpunit backupGlobals="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php">
<php>
<!--Path to the autoload file that should be used. Use a composer autoloader by default-->
Expand All @@ -26,10 +27,4 @@
<directory>./tests/visual</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src/</directory>
</whitelist>
</filter>
</phpunit>
7 changes: 6 additions & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

error_reporting(E_ALL);
if (version_compare(PHP_VERSION, '8.0', '>=')) {
// required for tcpdf
error_reporting(E_ALL & ~E_DEPRECATED);
} else {
error_reporting(E_ALL);
}
ini_set('display_errors', 1);

// if in travis scope
Expand Down
8 changes: 2 additions & 6 deletions tests/functional/FpdfTplTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,19 @@ public function testGetTemplateSizeResizedByHeight()
], $size);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testGetTemplateSizeWithZeroWidth()
{
$pdf = new FpdfTpl();
$tplId = $pdf->beginTemplate(100, 200);
$this->expectException(\InvalidArgumentException::class);
$pdf->getTemplateSize($tplId, 0);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testGetTemplateSizeWithZeroHeight()
{
$pdf = new FpdfTpl();
$tplId = $pdf->beginTemplate(100, 200);
$this->expectException(\InvalidArgumentException::class);
$pdf->getTemplateSize($tplId, null, 0);
}

Expand Down
7 changes: 3 additions & 4 deletions tests/functional/FpdiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PHPUnit\Framework\TestCase;
use setasign\Fpdi\Fpdi;
use setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException;
use setasign\Fpdi\PdfParser\PdfParser;
use setasign\Fpdi\PdfParser\StreamReader;
use setasign\Fpdi\PdfParser\Type\PdfNull;
Expand Down Expand Up @@ -81,13 +82,11 @@ public function testImportedPageInTemplate()
$this->assertEquals($expectedStream, $tplAObject->getUnfilteredStream());
}

/**
* @expectedException \setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException
* @expectedExceptionCode \setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException::COMPRESSED_XREF
*/
public function testBehaviourOnCompressedXref()
{
$pdf = new Fpdi('P', 'pt');
$this->expectException(CrossReferenceException::class);
$this->expectExceptionCode(CrossReferenceException::COMPRESSED_XREF);
$pdf->setSourceFile(__DIR__ . '/../_files/pdfs/compressed-xref.pdf');
}

Expand Down
12 changes: 3 additions & 9 deletions tests/functional/FpdiTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,19 @@ public function testGetTemplateSizeResizedByHeight()
], $size);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testGetTemplateSizeWithZeroWidth()
{
$pdf = new Fpdi();
$pdf->setSourceFile(__DIR__ . '/../_files/pdfs/boxes/All2.pdf');
$this->expectException(\InvalidArgumentException::class);
$pdf->getTemplateSize($pdf->importPage(1), 0);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testGetTemplateSizeWithZeroHeight()
{
$pdf = new Fpdi();
$pdf->setSourceFile(__DIR__ . '/../_files/pdfs/boxes/All2.pdf');
$this->expectException(\InvalidArgumentException::class);
$pdf->getTemplateSize($pdf->importPage(1), null, 0);
}

Expand Down Expand Up @@ -141,13 +137,11 @@ public function testImportPageWithSameMeaningBoxParameters()
$this->assertEquals($idA, $idB);
}

/**
* @expectedException InvalidArgumentException
*/
public function testImportPageWithInvalidBoxParameter()
{
$pdf = new Fpdi();
$pdf->setSourceFile(__DIR__ . '/../_files/pdfs/boxes/All2.pdf');
$this->expectException(\InvalidArgumentException::class);
$pdf->importPage(1, 'CropsBox');
}
}
Loading

0 comments on commit 453e553

Please sign in to comment.