Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Dec 3, 2023
1 parent 2f73f89 commit 46f2d28
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 56 deletions.
13 changes: 7 additions & 6 deletions phpunit.xml.dist
@@ -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
@@ -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
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
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
Expand Up @@ -42,6 +42,5 @@
->args([
new Parameter('nucleos_dompdf.options'),
])

;
};
2 changes: 1 addition & 1 deletion tests/BundleIntegrationTest.php
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
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
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
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
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
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

0 comments on commit 46f2d28

Please sign in to comment.