Skip to content

Commit

Permalink
Merge pull request #312 from garak/test-php8
Browse files Browse the repository at this point in the history
test on PHP 8
  • Loading branch information
alexpozzi authored May 12, 2023
2 parents da11c2d + ac7be9e commit d12fbf7
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 31 deletions.
13 changes: 9 additions & 4 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 @@ -27,18 +27,23 @@ jobs:
composer_option: '--prefer-lowest'
env:
SYMFONY_DEPRECATIONS_HELPER: max[self]=0
- description: 'PHP 8.0'
php: '8.0'
- description: 'PHP 8.1'
php: '8.1'
- description: 'Dev deps'
php: '7.4'
php: '8.2'
dev: true
name: PHP ${{ matrix.php }} tests (${{ matrix.description }})
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- run: |
phpenv config-rm xdebug.ini || true
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins symfony/flex 1.*
- 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 Down
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
failOnWarning="true"
>
<php>
<server name="SYMFONY_PHPUNIT_VERSION" value="7.5" />
<server name="SYMFONY_PHPUNIT_VERSION" value="8.5" />
</php>

<testsuites>
Expand All @@ -28,4 +28,4 @@
</exclude>
</whitelist>
</filter>
</phpunit>
</phpunit>
4 changes: 2 additions & 2 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ConfigurationTest extends TestCase
/**
* @dataProvider dataForProcessedConfiguration
*/
public function testProcessedConfiguration($configs, $expectedConfig)
public function testProcessedConfiguration($configs, $expectedConfig): void
{
$processor = new Processor();
$configuration = new Configuration();
Expand All @@ -20,7 +20,7 @@ public function testProcessedConfiguration($configs, $expectedConfig)
$this->assertEquals($expectedConfig, $config);
}

public function dataForProcessedConfiguration()
public function dataForProcessedConfiguration(): array
{
return [
[
Expand Down
14 changes: 7 additions & 7 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ class FunctionalTest extends TestCase
/** @var Filesystem */
private $filesystem;

public function setUp()
public function setUp(): void
{
$this->kernel = new TestKernel(uniqid(), false);

$this->filesystem = new Filesystem();
$this->filesystem->mkdir($this->kernel->getCacheDir());
}

public function tearDown()
public function tearDown(): void
{
$this->filesystem->remove($this->kernel->getCacheDir());
}

public function testServiceIsAvailableOutOfTheBox()
public function testServiceIsAvailableOutOfTheBox(): void
{
$this->kernel->setConfigurationFilename(__DIR__ . '/fixtures/config/out_of_the_box.yml');
$this->kernel->boot();
Expand All @@ -48,7 +48,7 @@ public function testServiceIsAvailableOutOfTheBox()
$this->assertEquals('wkhtmltoimage', $image->getBinary());
}

public function testChangeBinaries()
public function testChangeBinaries(): void
{
$this->kernel->setConfigurationFilename(__DIR__ . '/fixtures/config/change_binaries.yml');
$this->kernel->boot();
Expand All @@ -68,7 +68,7 @@ public function testChangeBinaries()
$this->assertEquals('/custom/binary/for/wkhtmltoimage', $image->getBinary());
}

public function testChangeTemporaryFolder()
public function testChangeTemporaryFolder(): void
{
$this->kernel->setConfigurationFilename(__DIR__ . '/fixtures/config/change_temporary_folder.yml');
$this->kernel->boot();
Expand All @@ -82,7 +82,7 @@ public function testChangeTemporaryFolder()
$this->assertEquals('/path/to/the/tmp', $image->getTemporaryFolder());
}

public function testDisablePdf()
public function testDisablePdf(): void
{
$this->kernel->setConfigurationFilename(__DIR__ . '/fixtures/config/disable_pdf.yml');
$this->kernel->boot();
Expand All @@ -93,7 +93,7 @@ public function testDisablePdf()
$this->assertTrue($container->has('knp_snappy.image'), 'The image service is available.');
}

public function testDisableImage()
public function testDisableImage(): void
{
$this->kernel->setConfigurationFilename(__DIR__ . '/fixtures/config/disable_image.yml');
$this->kernel->boot();
Expand Down
14 changes: 7 additions & 7 deletions tests/Snappy/Generator/LoggableGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class LoggableGeneratorTest extends TestCase
{
public function testGenerate()
public function testGenerate(): void
{
$internal = $this->createMock('Knp\Snappy\GeneratorInterface');
$internal
Expand All @@ -33,7 +33,7 @@ public function testGenerate()
$generator->generate('the_input_file', 'the_output_file', ['foo' => 'bar'], true);
}

public function testGenerateFromHtml()
public function testGenerateFromHtml(): void
{
$internal = $this->createMock('Knp\Snappy\GeneratorInterface');
$internal
Expand All @@ -56,7 +56,7 @@ public function testGenerateFromHtml()
$generator->generateFromHtml('<html>foo</html>', 'the_output_file', ['foo' => 'bar'], true);
}

public function testGenerateFromHtmlWithHtmlArray()
public function testGenerateFromHtmlWithHtmlArray(): void
{
$internal = $this->createMock('Knp\Snappy\GeneratorInterface');
$internal
Expand All @@ -79,7 +79,7 @@ public function testGenerateFromHtmlWithHtmlArray()
$generator->generateFromHtml(['<html>foo</html>', '<html>bar</html>'], 'the_output_file', ['foo' => 'bar'], true);
}

public function testOutput()
public function testOutput(): void
{
$internal = $this->createMock('Knp\Snappy\GeneratorInterface');
$internal
Expand All @@ -100,7 +100,7 @@ public function testOutput()
$generator->getOutput('the_input_file', ['foo' => 'bar'], true);
}

public function testOutputFromHtml()
public function testOutputFromHtml(): void
{
$internal = $this->createMock('Knp\Snappy\GeneratorInterface');
$internal
Expand All @@ -121,7 +121,7 @@ public function testOutputFromHtml()
$generator->getOutputFromHtml('<html>foo</html>', ['foo' => 'bar'], true);
}

public function testOutputFromHtmlWithHtmlArray()
public function testOutputFromHtmlWithHtmlArray(): void
{
$internal = $this->createMock('Knp\Snappy\GeneratorInterface');
$internal
Expand All @@ -142,7 +142,7 @@ public function testOutputFromHtmlWithHtmlArray()
$generator->getOutputFromHtml(['<html>foo</html>'], ['foo' => 'bar'], true);
}

public function testSetOption()
public function testSetOption(): void
{
$internal = $this->createMock('Knp\Snappy\Image');
$internal
Expand Down
6 changes: 3 additions & 3 deletions tests/Snappy/Response/JpegResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class JpegResponseTest extends TestCase
{
public function testDefaultParameters()
public function testDefaultParameters(): void
{
$response = new JpegResponse('some_binary_output');

Expand All @@ -17,14 +17,14 @@ public function testDefaultParameters()
$this->assertSame('inline; filename=output.jpg', str_replace('"', '', $response->headers->get('Content-Disposition')));
}

public function testSetDifferentMimeType()
public function testSetDifferentMimeType(): void
{
$response = new JpegResponse('some_binary_output', 'test.jpg', 'application/octet-stream');

$this->assertSame('application/octet-stream', $response->headers->get('Content-Type'));
}

public function testSetDifferentFileName()
public function testSetDifferentFileName(): void
{
$fileName = 'test.jpg';
$response = new JpegResponse('some_binary_output', $fileName);
Expand Down
6 changes: 3 additions & 3 deletions tests/Snappy/Response/PdfResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class PdfResponseTest extends TestCase
{
public function testDefaultParameters()
public function testDefaultParameters(): void
{
$response = new PdfResponse('some_binary_output');

Expand All @@ -17,14 +17,14 @@ public function testDefaultParameters()
$this->assertSame('attachment; filename=output.pdf', str_replace('"', '', $response->headers->get('Content-Disposition')));
}

public function testSetDifferentMimeType()
public function testSetDifferentMimeType(): void
{
$response = new PdfResponse('some_binary_output', 'test.pdf', 'application/octet-stream');

$this->assertSame('application/octet-stream', $response->headers->get('Content-Type'));
}

public function testSetDifferentFileName()
public function testSetDifferentFileName(): void
{
$fileName = 'test.pdf';
$response = new PdfResponse('some_binary_output', $fileName);
Expand Down
2 changes: 1 addition & 1 deletion tests/Snappy/Response/SnappyResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class SnappyResponseTest extends TestCase
{
public function testExceptionMessage()
public function testExceptionMessage(): void
{
try {
new SnappyResponse('', 'test.jpg', 'image/jpg', 'foo');
Expand Down
4 changes: 2 additions & 2 deletions tests/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TestKernel extends Kernel
*
* @param string $filename
*/
public function setConfigurationFilename($filename)
public function setConfigurationFilename($filename): void
{
$this->configurationFilename = $filename;
}
Expand All @@ -33,7 +33,7 @@ public function registerBundles(): iterable
/**
* {@inheritdoc}
*/
public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load($this->configurationFilename);
}
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/config/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ framework:
secret: ThisIsNotReallyASecretSoPleaseChangeIt
router: { resource: "%kernel.project_dir%/config/routing.yml", utf8: true }
validation: { enabled: true, enable_annotations: false }
http_method_override: false

0 comments on commit d12fbf7

Please sign in to comment.