From d7dd9465a359803038ddda7631180c340319207f Mon Sep 17 00:00:00 2001 From: Eike Starkmann Date: Wed, 31 Jul 2024 14:33:08 +0200 Subject: [PATCH 1/3] [TASK] Add for showAction Related: #1228 --- .../Database/ContentElementTeaIndex.csv | 1 + .../Fixtures/Database/SiteStructure.csv | 1 + .../Controller/TeaControllerTest.php | 31 +++++++++++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Tests/Functional/Controller/Fixtures/Database/ContentElementTeaIndex.csv b/Tests/Functional/Controller/Fixtures/Database/ContentElementTeaIndex.csv index 682e61b..3f3530e 100644 --- a/Tests/Functional/Controller/Fixtures/Database/ContentElementTeaIndex.csv +++ b/Tests/Functional/Controller/Fixtures/Database/ContentElementTeaIndex.csv @@ -1,3 +1,4 @@ "tt_content" ,"uid","pid","CType","header","list_type" ,1,1,"list","Teas Index","tea_teaindex" +,2,3,"list","Tea Show","tea_teashow" diff --git a/Tests/Functional/Controller/Fixtures/Database/SiteStructure.csv b/Tests/Functional/Controller/Fixtures/Database/SiteStructure.csv index f664e49..ce6f70a 100644 --- a/Tests/Functional/Controller/Fixtures/Database/SiteStructure.csv +++ b/Tests/Functional/Controller/Fixtures/Database/SiteStructure.csv @@ -2,3 +2,4 @@ ,"uid","pid","title","slug" ,1,0,"Rootpage","/" ,2,1,"Storage","/storage" +,3,1,"Show","/show" diff --git a/Tests/Functional/Controller/TeaControllerTest.php b/Tests/Functional/Controller/TeaControllerTest.php index b0a8ec8..ee54297 100644 --- a/Tests/Functional/Controller/TeaControllerTest.php +++ b/Tests/Functional/Controller/TeaControllerTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace TTN\Tea\Tests\Functional\Controller; +use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -22,6 +23,14 @@ final class TeaControllerTest extends FunctionalTestCase protected function setUp(): void { + ArrayUtility::mergeRecursiveWithOverrule($this->configurationToUseInTestInstance, [ + 'FE' => [ + 'cacheHash' => [ + 'enforceValidation' => false, + ], + ] + ]); + parent::setUp(); $this->importCSVDataSet(__DIR__ . '/Fixtures/Database/SiteStructure.csv'); @@ -37,6 +46,8 @@ final class TeaControllerTest extends FunctionalTestCase 'EXT:tea/Tests/Functional/Controller/Fixtures/TypoScript/Setup/Rendering.typoscript', ], ]); + $this->importCSVDataSet(__DIR__ . '/Fixtures/Database/ContentElementTeaIndex.csv'); + $this->importCSVDataSet(__DIR__ . '/Fixtures/Database/Teas.csv'); } /** @@ -44,9 +55,6 @@ final class TeaControllerTest extends FunctionalTestCase */ public function indexActionRendersAllAvailableTeas(): void { - $this->importCSVDataSet(__DIR__ . '/Fixtures/Database/ContentElementTeaIndex.csv'); - $this->importCSVDataSet(__DIR__ . '/Fixtures/Database/Teas.csv'); - $request = new InternalRequest(); $request = $request->withPageId(1); @@ -55,4 +63,21 @@ final class TeaControllerTest extends FunctionalTestCase self::assertStringContainsString('Godesberger Burgtee', $html); self::assertStringContainsString('Oolong', $html); } + + /** + * @test + */ + public function showActionRendersTheGivenTeas(): void + { + $request = new InternalRequest(); + $request = $request->withPageId(3); + $request = $request->withQueryParameters([ + "tx_tea_teashow[tea]" => 1 + ]); + + $html = (string)$this->executeFrontendSubRequest($request)->getBody(); + + self::assertStringContainsString('Godesberger Burgtee', $html); + self::assertStringNotContainsString('Oolong', $html); + } } From 8ac92402ebd26979da704727d514ccde381bc9d8 Mon Sep 17 00:00:00 2001 From: Eike Starkmann Date: Wed, 31 Jul 2024 19:38:49 +0200 Subject: [PATCH 2/3] [BUGFIX] Use single quotes Related: #1228 --- Tests/Functional/Controller/TeaControllerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Functional/Controller/TeaControllerTest.php b/Tests/Functional/Controller/TeaControllerTest.php index ee54297..7b97a2d 100644 --- a/Tests/Functional/Controller/TeaControllerTest.php +++ b/Tests/Functional/Controller/TeaControllerTest.php @@ -72,7 +72,7 @@ final class TeaControllerTest extends FunctionalTestCase $request = new InternalRequest(); $request = $request->withPageId(3); $request = $request->withQueryParameters([ - "tx_tea_teashow[tea]" => 1 + 'tx_tea_teashow[tea]' => 1 ]); $html = (string)$this->executeFrontendSubRequest($request)->getBody(); From 951aaf0751f0a580c7dfc4568dabc4dd1f80b642 Mon Sep 17 00:00:00 2001 From: Eike Starkmann Date: Wed, 31 Jul 2024 19:55:03 +0200 Subject: [PATCH 3/3] [BUGFIX] Fix code style Related: #1228 --- Tests/Functional/Controller/TeaControllerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Functional/Controller/TeaControllerTest.php b/Tests/Functional/Controller/TeaControllerTest.php index 7b97a2d..ab8b28a 100644 --- a/Tests/Functional/Controller/TeaControllerTest.php +++ b/Tests/Functional/Controller/TeaControllerTest.php @@ -28,7 +28,7 @@ final class TeaControllerTest extends FunctionalTestCase 'cacheHash' => [ 'enforceValidation' => false, ], - ] + ], ]); parent::setUp(); @@ -72,7 +72,7 @@ final class TeaControllerTest extends FunctionalTestCase $request = new InternalRequest(); $request = $request->withPageId(3); $request = $request->withQueryParameters([ - 'tx_tea_teashow[tea]' => 1 + 'tx_tea_teashow[tea]' => 1, ]); $html = (string)$this->executeFrontendSubRequest($request)->getBody();