Upgrade tests to PhpUnit 10 (#5252)
This commit is contained in:
@@ -37,7 +37,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
abstract class AbstractRendererTest extends KernelTestCase
|
||||
abstract class AbstractRendererTestCase extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* @param class-string $classname
|
||||
@@ -19,17 +19,17 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
* @covers \App\Export\Renderer\CsvRenderer
|
||||
* @group integration
|
||||
*/
|
||||
class CsvRendererTest extends AbstractRendererTest
|
||||
class CsvRendererTest extends AbstractRendererTestCase
|
||||
{
|
||||
public function testConfiguration(): void
|
||||
{
|
||||
$sut = $this->getAbstractRenderer(CsvRenderer::class);
|
||||
|
||||
$this->assertEquals('csv', $sut->getId());
|
||||
$this->assertEquals('csv', $sut->getTitle());
|
||||
self::assertEquals('csv', $sut->getId());
|
||||
self::assertEquals('csv', $sut->getTitle());
|
||||
}
|
||||
|
||||
public function getTestModel()
|
||||
public static function getTestModel()
|
||||
{
|
||||
return [
|
||||
['400', '2437.12', ' EUR 1,947.99 ', 7, 6, 1, 2, 2]
|
||||
@@ -48,25 +48,25 @@ class CsvRendererTest extends AbstractRendererTest
|
||||
|
||||
$file = $response->getFile();
|
||||
$prefix = date('Ymd');
|
||||
$this->assertEquals('text/csv', $response->headers->get('Content-Type'));
|
||||
$this->assertEquals('attachment; filename=' . $prefix . '-Customer_Name-project_name.csv', $response->headers->get('Content-Disposition'));
|
||||
self::assertEquals('text/csv', $response->headers->get('Content-Type'));
|
||||
self::assertEquals('attachment; filename=' . $prefix . '-Customer_Name-project_name.csv', $response->headers->get('Content-Disposition'));
|
||||
|
||||
$this->assertTrue(file_exists($file->getRealPath()));
|
||||
self::assertTrue(file_exists($file->getRealPath()));
|
||||
$content = file_get_contents($file->getRealPath());
|
||||
|
||||
$this->assertStringContainsString('"' . $expectedRate . '"', $content);
|
||||
$this->assertEquals($expectedRows, substr_count($content, PHP_EOL));
|
||||
$this->assertEquals($expectedDescriptions, substr_count($content, 'activity description'));
|
||||
$this->assertEquals($expectedUser1, substr_count($content, ',"kevin",'));
|
||||
$this->assertEquals($expectedUser3, substr_count($content, ',"hello-world",'));
|
||||
$this->assertEquals($expectedUser2, substr_count($content, ',"foo-bar",'));
|
||||
self::assertStringContainsString('"' . $expectedRate . '"', $content);
|
||||
self::assertEquals($expectedRows, substr_count($content, PHP_EOL));
|
||||
self::assertEquals($expectedDescriptions, substr_count($content, 'activity description'));
|
||||
self::assertEquals($expectedUser1, substr_count($content, ',"kevin",'));
|
||||
self::assertEquals($expectedUser3, substr_count($content, ',"hello-world",'));
|
||||
self::assertEquals($expectedUser2, substr_count($content, ',"foo-bar",'));
|
||||
|
||||
ob_start();
|
||||
$response->sendContent();
|
||||
$content2 = ob_get_clean();
|
||||
|
||||
$this->assertEquals($content, $content2);
|
||||
$this->assertFalse(file_exists($file->getRealPath()));
|
||||
self::assertEquals($content, $content2);
|
||||
self::assertFalse(file_exists($file->getRealPath()));
|
||||
|
||||
$all = [];
|
||||
$rows = str_getcsv($content2, PHP_EOL);
|
||||
|
||||
@@ -27,7 +27,7 @@ use Twig\Environment;
|
||||
* @covers \App\Export\Renderer\HtmlRenderer
|
||||
* @group integration
|
||||
*/
|
||||
class HtmlRendererTest extends AbstractRendererTest
|
||||
class HtmlRendererTest extends AbstractRendererTestCase
|
||||
{
|
||||
public function testConfiguration(): void
|
||||
{
|
||||
@@ -38,8 +38,8 @@ class HtmlRendererTest extends AbstractRendererTest
|
||||
$this->createMock(ActivityStatisticService::class)
|
||||
);
|
||||
|
||||
$this->assertEquals('html', $sut->getId());
|
||||
$this->assertEquals('print', $sut->getTitle());
|
||||
self::assertEquals('html', $sut->getId());
|
||||
self::assertEquals('print', $sut->getTitle());
|
||||
}
|
||||
|
||||
public function testRender(): void
|
||||
@@ -79,21 +79,21 @@ class HtmlRendererTest extends AbstractRendererTest
|
||||
|
||||
$content = $response->getContent();
|
||||
|
||||
$this->assertStringContainsString('<h2 id="doc-title" contenteditable="true"', $content);
|
||||
$this->assertStringContainsString('<h3 class="card-title" id="doc-summary" contenteditable="true" data-original="Summary">Summary</h3>', $content);
|
||||
$this->assertEquals(1, substr_count($content, 'id="export-summary"'));
|
||||
$this->assertEquals(1, substr_count($content, 'id="export-records"'));
|
||||
$this->assertEquals(1, substr_count($content, 'id="summary-project"'));
|
||||
$this->assertEquals(1, substr_count($content, 'id="summary-activity"'));
|
||||
self::assertStringContainsString('<h2 id="doc-title" contenteditable="true"', $content);
|
||||
self::assertStringContainsString('<h3 class="card-title" id="doc-summary" contenteditable="true" data-original="Summary">Summary</h3>', $content);
|
||||
self::assertEquals(1, substr_count($content, 'id="export-summary"'));
|
||||
self::assertEquals(1, substr_count($content, 'id="export-records"'));
|
||||
self::assertEquals(1, substr_count($content, 'id="summary-project"'));
|
||||
self::assertEquals(1, substr_count($content, 'id="summary-activity"'));
|
||||
|
||||
$this->assertStringContainsString('<td>Customer Name</td>', $content);
|
||||
$this->assertStringContainsString('<td>project name</td>', $content);
|
||||
$this->assertStringContainsString('<span class="duration-format" data-duration-decimal="1.94" data-duration="1:56">1:56</span>', $content);
|
||||
$this->assertStringContainsString('<td class="cost summary-rate">€2,437.12</td>', $content);
|
||||
$this->assertStringContainsString('-€100.92', $content);
|
||||
self::assertStringContainsString('<td>Customer Name</td>', $content);
|
||||
self::assertStringContainsString('<td>project name</td>', $content);
|
||||
self::assertStringContainsString('<span class="duration-format" data-duration-decimal="1.94" data-duration="1:56">1:56</span>', $content);
|
||||
self::assertStringContainsString('<td class="cost summary-rate">€2,437.12</td>', $content);
|
||||
self::assertStringContainsString('-€100.92', $content);
|
||||
|
||||
// 5 times in the "full list" and once in the "summary with activities"
|
||||
$this->assertEquals(7, substr_count($content, 'activity description'));
|
||||
$this->assertEquals(1, substr_count($content, '<td>activity description</td>'));
|
||||
self::assertEquals(7, substr_count($content, 'activity description'));
|
||||
self::assertEquals(1, substr_count($content, '<td>activity description</td>'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ use Twig\Environment;
|
||||
* @covers \App\Export\Renderer\PDFRenderer
|
||||
* @group integration
|
||||
*/
|
||||
class PdfRendererTest extends AbstractRendererTest
|
||||
class PdfRendererTest extends AbstractRendererTestCase
|
||||
{
|
||||
public function testConfiguration(): void
|
||||
{
|
||||
@@ -34,13 +34,13 @@ class PdfRendererTest extends AbstractRendererTest
|
||||
$this->createMock(ProjectStatisticService::class)
|
||||
);
|
||||
|
||||
$this->assertEquals('pdf', $sut->getId());
|
||||
$this->assertEquals('pdf', $sut->getTitle());
|
||||
$this->assertEquals([], $sut->getPdfOptions());
|
||||
self::assertEquals('pdf', $sut->getId());
|
||||
self::assertEquals('pdf', $sut->getTitle());
|
||||
self::assertEquals([], $sut->getPdfOptions());
|
||||
|
||||
$sut->setPdfOption('foo', 'bar');
|
||||
$sut->setPdfOption('bar1', 'foo1');
|
||||
$this->assertEquals(['foo' => 'bar', 'bar1' => 'foo1'], $sut->getPdfOptions());
|
||||
self::assertEquals(['foo' => 'bar', 'bar1' => 'foo1'], $sut->getPdfOptions());
|
||||
}
|
||||
|
||||
public function testRenderAttachment(): void
|
||||
@@ -62,9 +62,9 @@ class PdfRendererTest extends AbstractRendererTest
|
||||
$prefix = date('Ymd');
|
||||
|
||||
$response = $this->render($sut);
|
||||
$this->assertEquals('application/pdf', $response->headers->get('Content-Type'));
|
||||
$this->assertEquals('attachment; filename=' . $prefix . '-Customer_Name-project_name.pdf', $response->headers->get('Content-Disposition'));
|
||||
$this->assertNotEmpty($response->getContent());
|
||||
self::assertEquals('application/pdf', $response->headers->get('Content-Type'));
|
||||
self::assertEquals('attachment; filename=' . $prefix . '-Customer_Name-project_name.pdf', $response->headers->get('Content-Disposition'));
|
||||
self::assertNotEmpty($response->getContent());
|
||||
}
|
||||
|
||||
public function testRenderInline(): void
|
||||
@@ -87,8 +87,8 @@ class PdfRendererTest extends AbstractRendererTest
|
||||
|
||||
$sut->setDispositionInline(true);
|
||||
$response = $this->render($sut);
|
||||
$this->assertEquals('application/pdf', $response->headers->get('Content-Type'));
|
||||
$this->assertEquals('inline; filename=' . $prefix . '-Customer_Name-project_name.pdf', $response->headers->get('Content-Disposition'));
|
||||
$this->assertNotEmpty($response->getContent());
|
||||
self::assertEquals('application/pdf', $response->headers->get('Content-Type'));
|
||||
self::assertEquals('inline; filename=' . $prefix . '-Customer_Name-project_name.pdf', $response->headers->get('Content-Disposition'));
|
||||
self::assertNotEmpty($response->getContent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
* @covers \App\Export\Renderer\XlsxRenderer
|
||||
* @group integration
|
||||
*/
|
||||
class XlsxRendererTest extends AbstractRendererTest
|
||||
class XlsxRendererTest extends AbstractRendererTestCase
|
||||
{
|
||||
public function testConfiguration(): void
|
||||
{
|
||||
$sut = $this->getAbstractRenderer(XlsxRenderer::class);
|
||||
|
||||
$this->assertEquals('xlsx', $sut->getId());
|
||||
$this->assertEquals('xlsx', $sut->getTitle());
|
||||
self::assertEquals('xlsx', $sut->getId());
|
||||
self::assertEquals('xlsx', $sut->getTitle());
|
||||
}
|
||||
|
||||
public function testRender(): void
|
||||
@@ -38,16 +38,16 @@ class XlsxRendererTest extends AbstractRendererTest
|
||||
|
||||
$file = $response->getFile();
|
||||
$prefix = date('Ymd');
|
||||
$this->assertEquals('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $response->headers->get('Content-Type'));
|
||||
$this->assertEquals('attachment; filename=' . $prefix . '-Customer_Name-project_name.xlsx', $response->headers->get('Content-Disposition'));
|
||||
self::assertEquals('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $response->headers->get('Content-Type'));
|
||||
self::assertEquals('attachment; filename=' . $prefix . '-Customer_Name-project_name.xlsx', $response->headers->get('Content-Disposition'));
|
||||
|
||||
$this->assertTrue(file_exists($file->getRealPath()));
|
||||
self::assertTrue(file_exists($file->getRealPath()));
|
||||
|
||||
ob_start();
|
||||
$response->sendContent();
|
||||
$content2 = ob_get_clean();
|
||||
$this->assertNotEmpty($content2);
|
||||
self::assertNotEmpty($content2);
|
||||
|
||||
$this->assertFalse(file_exists($file->getRealPath()));
|
||||
self::assertFalse(file_exists($file->getRealPath()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user