Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tools #541

Merged
merged 2 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage>
<include>
<directory suffix=".php">./src/</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage/>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
</php>
Expand All @@ -13,4 +9,9 @@
<directory>./tests/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src/</directory>
</include>
</source>
</phpunit>
8 changes: 7 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.14.2@3538fe1955d47f6ee926c0769d71af6db08aa488"/>
<files psalm-version="5.16.0@2897ba636551a8cb61601cc26f6ccfbba6c36591">
<file src="src/DependencyInjection/Configuration.php">
<UndefinedMethod>
<code>children</code>
</UndefinedMethod>
</file>
</files>
4 changes: 1 addition & 3 deletions src/Exception/PdfException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@

use Exception;

final class PdfException extends Exception
{
}
final class PdfException extends Exception {}
4 changes: 1 addition & 3 deletions src/NucleosDompdfBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@

use Symfony\Component\HttpKernel\Bundle\Bundle;

final class NucleosDompdfBundle extends Bundle
{
}
final class NucleosDompdfBundle extends Bundle {}
1 change: 0 additions & 1 deletion src/Resources/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@
->args([
new Parameter('nucleos_dompdf.options'),
])

;
};
2 changes: 1 addition & 1 deletion tests/BundleIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public function testStartup(): void

$client->request('GET', '/test');

static::assertSame(200, $client->getResponse()->getStatusCode());
self::assertSame(200, $client->getResponse()->getStatusCode());
}
}
4 changes: 2 additions & 2 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testDefaultOptions(): void
],
];

static::assertSame($expected, $config);
self::assertSame($expected, $config);
}

public function testOptions(): void
Expand All @@ -51,6 +51,6 @@ public function testOptions(): void
],
];

static::assertSame($expected, $config);
self::assertSame($expected, $config);
}
}
5 changes: 3 additions & 2 deletions tests/Event/OutputEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ final class OutputEventTest extends TestCase
public function testEvent(): void
{
$dompdf = $this->createMock(Dompdf::class);

/** @noinspection HtmlRequiredAltAttribute */
/** @noinspection HtmlUnknownTarget */
$html = "<h1>Foo</h1>Bar <b>baz</b><img src='img/foo'>";

$event = new OutputEvent($dompdf, $html);

static::assertSame($dompdf, $event->getPdf());
static::assertSame($html, $event->getHtml());
self::assertSame($dompdf, $event->getPdf());
self::assertSame($html, $event->getHtml());
}
}
7 changes: 4 additions & 3 deletions tests/Event/StreamEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ public function testEvent(): void
{
$dompdf = $this->createMock(Dompdf::class);
$filename = 'file.pdf';

/** @noinspection HtmlRequiredAltAttribute */
/** @noinspection HtmlUnknownTarget */
$html = "<h1>Foo</h1>Bar <b>baz</b><img src='img/foo'>";

$event = new StreamEvent($dompdf, $filename, $html);

static::assertSame($dompdf, $event->getPdf());
static::assertSame($filename, $event->getFilename());
static::assertSame($html, $event->getHtml());
self::assertSame($dompdf, $event->getPdf());
self::assertSame($filename, $event->getFilename());
self::assertSame($html, $event->getHtml());
}
}
6 changes: 3 additions & 3 deletions tests/Factory/DompdfFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testCreate(): void

$options = $dompdf->getOptions();

static::assertSame(100, $options->getDpi());
self::assertSame(100, $options->getDpi());
}

public function testCreateWithOptions(): void
Expand All @@ -43,7 +43,7 @@ public function testCreateWithOptions(): void

$options = $dompdf->getOptions();

static::assertSame('foo', $options->getTempDir());
static::assertSame(200, $options->getDpi());
self::assertSame('foo', $options->getTempDir());
self::assertSame(200, $options->getDpi());
}
}
63 changes: 32 additions & 31 deletions tests/Wrapper/DompdfWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

final class DompdfWrapperTest extends TestCase
{
private MockObject&DompdfFactoryInterface $dompdfFactory;
private DompdfFactoryInterface&MockObject $dompdfFactory;

private MockObject&EventDispatcherInterface $eventDispatcher;
private EventDispatcherInterface&MockObject $eventDispatcher;

private DompdfWrapper $dompdfWrapper;

private MockObject&Dompdf $dompdf;
private Dompdf&MockObject $dompdf;

protected function setUp(): void
{
Expand All @@ -49,21 +49,21 @@ public function testStreamHtml(): void
->willReturn($this->dompdf)
;

$this->dompdf->expects(static::once())
$this->dompdf->expects(self::once())
->method('loadHtml')
->with(static::equalTo($input))
->with(self::equalTo($input))
;
$this->dompdf->expects(static::once())
$this->dompdf->expects(self::once())
->method('render')
;
$this->dompdf->expects(static::once())
$this->dompdf->expects(self::once())
->method('stream')
->with(static::equalTo('file.pdf'))
->with(self::equalTo('file.pdf'))
;

$this->eventDispatcher->expects(static::once())
$this->eventDispatcher->expects(self::once())
->method('dispatch')
->with(static::anything(), static::equalTo(DompdfEvents::STREAM))
->with(self::anything(), self::equalTo(DompdfEvents::STREAM))
;

$this->dompdfWrapper->streamHtml($input, 'file.pdf');
Expand All @@ -74,31 +74,32 @@ public function testStreamHtmlWithImg(): void
/** @noinspection HtmlRequiredAltAttribute */
/** @noinspection HtmlUnknownTarget */
$input = "<h1>Foo</h1>Bar <b>baz</b><img src='img/foo'>";

/** @noinspection HtmlRequiredAltAttribute */
/** @noinspection HtmlUnknownTarget */
$output = "<h1>Foo</h1>Bar <b>baz</b><img src='img/foo'>";

$this->dompdfFactory
->method('create')
->with(static::equalTo(['tempDir' => 'bar']))
->with(self::equalTo(['tempDir' => 'bar']))
->willReturn($this->dompdf)
;

$this->dompdf->expects(static::once())
$this->dompdf->expects(self::once())
->method('loadHtml')
->with(static::equalTo($output))
->with(self::equalTo($output))
;
$this->dompdf->expects(static::once())
$this->dompdf->expects(self::once())
->method('render')
;
$this->dompdf->expects(static::once())
$this->dompdf->expects(self::once())
->method('stream')
->with(static::equalTo('file.pdf'))
->with(self::equalTo('file.pdf'))
;

$this->eventDispatcher->expects(static::once())
$this->eventDispatcher->expects(self::once())
->method('dispatch')
->with(static::anything(), static::equalTo(DompdfEvents::STREAM))
->with(self::anything(), self::equalTo(DompdfEvents::STREAM))
;

$this->dompdfWrapper->streamHtml($input, 'file.pdf', ['tempDir' => 'bar']);
Expand All @@ -112,9 +113,9 @@ public function testGetPdf(): void

$this->prepareOutput($input, 'BINARY_CONTENT');

$this->eventDispatcher->expects(static::once())
$this->eventDispatcher->expects(self::once())
->method('dispatch')
->with(static::anything(), static::equalTo(DompdfEvents::OUTPUT))
->with(self::anything(), self::equalTo(DompdfEvents::OUTPUT))
;

$this->dompdfWrapper->getPdf($input, ['tempDir' => 'bar']);
Expand All @@ -128,9 +129,9 @@ public function testGetPdfWithError(): void

$this->prepareOutput($input);

$this->eventDispatcher->expects(static::once())
$this->eventDispatcher->expects(self::once())
->method('dispatch')
->with(static::anything(), static::equalTo(DompdfEvents::OUTPUT))
->with(self::anything(), self::equalTo(DompdfEvents::OUTPUT))
;

$this->dompdfWrapper->getPdf($input);
Expand All @@ -143,16 +144,16 @@ public function testGetStreamResponse(): void
->willReturn($this->dompdf)
;

$this->dompdf->expects(static::once())
$this->dompdf->expects(self::once())
->method('loadHtml')
->with(static::equalTo('<h1>Title</h1>'))
->with(self::equalTo('<h1>Title</h1>'))
;
$this->dompdf->expects(static::once())
$this->dompdf->expects(self::once())
->method('render')
;
$this->dompdf->expects(static::once())
$this->dompdf->expects(self::once())
->method('stream')
->with(static::equalTo('file.pdf'))
->with(self::equalTo('file.pdf'))
;

$response = $this->dompdfWrapper->getStreamResponse('<h1>Title</h1>', 'file.pdf');
Expand All @@ -166,14 +167,14 @@ private function prepareOutput(string $input, ?string $response = null): void
->willReturn($this->dompdf)
;

$this->dompdf->expects(static::once())
$this->dompdf->expects(self::once())
->method('loadHtml')
->with(static::equalTo($input))
->with(self::equalTo($input))
;
$this->dompdf->expects(static::once())
$this->dompdf->expects(self::once())
->method('render')
;
$this->dompdf->expects(static::once())
$this->dompdf->expects(self::once())
->method('output')
->willReturn($response)
;
Expand Down
5 changes: 5 additions & 0 deletions vendor-bin/tools/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@
"phpstan/extension-installer": true
},
"bin-dir": "../../vendor/bin"
},
"extra": {
"symfony": {
"require": "6.4.*"
}
}
}
Loading
Loading