Skip to content

Commit

Permalink
Refactor tests to the new method
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander De la Marche committed Mar 25, 2022
1 parent b4a319f commit 78e3da0
Show file tree
Hide file tree
Showing 4 changed files with 1,587 additions and 182 deletions.
23 changes: 3 additions & 20 deletions tests/PdfGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,27 @@
namespace Dreadnip\ChromePdfBundle\Test;

use Dreadnip\ChromePdfBundle\Service\PdfGenerator;
use Dreadnip\ChromePdfBundle\Test\WebServer\WebServerManager;
use HeadlessChromium\BrowserFactory;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

/**
* @covers Dreadnip\ChromePdfBundle\Service\PdfGenerator
*/
class PdfGeneratorTest extends TestCase
{
public function testPdfGeneration(): void
{
$webserver = new WebServerManager(__DIR__);
$webserver->start();

$request = new Request([], [], [], [], [], [
'SERVER_ADDR' => 'localhost',
'SERVER_PORT' => 45066,
],[]);

$requestStack = new RequestStack();
$requestStack->push($request);

$browserFactory = new BrowserFactory('/usr/bin/chromium');

// create a generator
$generator = new PdfGenerator($browserFactory, $requestStack, __DIR__ . '/');
$generator = new PdfGenerator($browserFactory);

$html = '<html><head></head><body>This is a test!</body></html>';
$html = file_get_contents('tests/test_source.html');

$path = __DIR__ . '/test.pdf';

$generator->generate($html, $path);
$generator->generate($html, $path, [], []);

$this->assertFileExists($path);

$webserver->quit();
unlink($path);
}
}
88 changes: 0 additions & 88 deletions tests/WebServer/WebServerManager.php

This file was deleted.

74 changes: 0 additions & 74 deletions tests/WebServer/WebServerReadinessTrait.php

This file was deleted.

1,584 changes: 1,584 additions & 0 deletions tests/test_source.html

Large diffs are not rendered by default.

0 comments on commit 78e3da0

Please sign in to comment.