Skip to content

Commit

Permalink
Merge pull request #475 from KnpLabs/fix/test-8.2
Browse files Browse the repository at this point in the history
chore: add ci tests for php 8.2, bump github actions versions (with phpstan fixed)
  • Loading branch information
alexpozzi committed May 15, 2023
2 parents b66f793 + 42e629c commit 619dcfd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
- name: Validate composer.json
Expand All @@ -19,7 +19,7 @@ jobs:
name: PHP-CS-Fixer
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -32,9 +32,15 @@ jobs:
fail-fast: false
matrix:
include:
- description: 'Symfony 6.3 DEV'
php: '8.2'
symfony: '6.3.*@dev'
- description: 'Symfony 6.2'
php: '8.2'
symfony: '6.2.*'
- description: 'Symfony 6.0'
php: '8.0'
symfony: '6.0.*@dev'
php: '8.1'
symfony: '6.0.*'
- description: 'Symfony 5.0'
php: '7.3'
symfony: '5.0.*'
Expand All @@ -50,9 +56,9 @@ jobs:
name: PHP ${{ matrix.php }} tests (${{ matrix.description }})
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: composer-${{ matrix.php }}-${{ matrix.symfony }}-${{ matrix.composer_option }}
Expand All @@ -68,7 +74,7 @@ jobs:
composer config prefer-stable true
if: matrix.beta
- name: remove cs-fixer for Symfony 6
if: contains(matrix.symfony, '6.0.*@dev')
if: contains(matrix.symfony, '6.3.*@dev')
run: |
composer remove --dev friendsofphp/php-cs-fixer pedrotroller/php-cs-custom-fixer --no-update
- run: composer update --prefer-dist --no-interaction --no-progress --ansi ${{ matrix.composer_option }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ vendor
bin
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
.phpunit.cache
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
},
"require-dev": {
"phpunit/phpunit": "~7.4||~8.5",
"phpstan/phpstan": "^0.12.7",
"phpstan/phpstan-phpunit": "^0.12.6",
"phpstan/phpstan": "^1.0.0",
"phpstan/phpstan-phpunit": "^1.0.0",
"friendsofphp/php-cs-fixer": "^2.16||^3.0",
"pedrotroller/php-cs-custom-fixer": "^2.19"
},
Expand Down
9 changes: 6 additions & 3 deletions tests/Knp/Snappy/AbstractGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tests\Knp\Snappy;

use Knp\Snappy\AbstractGenerator;
use Knp\Snappy\Exception\FileAlreadyExistsException;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use InvalidArgumentException;
Expand Down Expand Up @@ -40,6 +41,7 @@ public function testAddOption(): void
try {
$r->invokeArgs($media, ['baz', 'bat']);
$this->fail($message);
// @phpstan-ignore-next-line
} catch (InvalidArgumentException $e) {
$this->anything();
}
Expand Down Expand Up @@ -82,6 +84,7 @@ public function testAddOptions(): void
try {
$r->invokeArgs($media, [['bak' => 'bam', 'bah' => 'bap', 'baz' => 'bat']]);
$this->fail($message);
// @phpstan-ignore-next-line
} catch (InvalidArgumentException $e) {
$this->anything();
}
Expand Down Expand Up @@ -542,6 +545,7 @@ public function testMergeOptions(): void
try {
$r->invokeArgs($media, [['foo' => 'ban', 'bad' => 'bah']]);
$this->fail($message);
// @phpstan-ignore-next-line
} catch (InvalidArgumentException $e) {
$this->anything();
}
Expand Down Expand Up @@ -778,11 +782,10 @@ public function testIsAssociativeArray(array $array, bool $isAssociativeArray):
$this->assertEquals($isAssociativeArray, $r->invokeArgs($generator, [$array]));
}

/**
* @expectedException Knp\Snappy\Exception\FileAlreadyExistsException
*/
public function testItThrowsTheProperExceptionWhenFileExistsAndNotOverwritting(): void
{
$this->expectException(FileAlreadyExistsException::class);

$media = $this->getMockBuilder(AbstractGenerator::class)
->setMethods([
'configure',
Expand Down
1 change: 1 addition & 0 deletions tests/Knp/Snappy/PdfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function testRemovesLocalFilesOnError(): void
$this->assertEquals(1, \count($pdf->temporaryFiles));
$this->expectException(Error::class);
\trigger_error('test error', \E_USER_ERROR);
// @phpstan-ignore-next-line See https://github.com/phpstan/phpstan/issues/7799
$this->assertFileNotExists(\reset($pdf->temporaryFiles));
}

Expand Down

0 comments on commit 619dcfd

Please sign in to comment.