-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add first functional test using a request (#1021)
That way the extension serves as an example on how to use the TYPO3 internal requests provided by the TYPO3 testing framework. Those can be used as integration tests. They are also often easier to set up on existing projects and allow to refactor the code base, compared to functional and unit tests. Resolves: #859
- Loading branch information
1 parent
8587bc8
commit 555c43e
Showing
6 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
Tests/Functional/Controller/Fixtures/Database/ContentElementTeaIndex.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
tt_content | ||
,uid,pid,CType,header,list_type | ||
,1,1,list,Teas Index,tea_teaindex |
4 changes: 4 additions & 0 deletions
4
Tests/Functional/Controller/Fixtures/Database/SiteStructure.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pages | ||
,uid,pid,title,slug | ||
,1,0,Rootpage,/ | ||
,2,1,Storage,/storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"tx_tea_domain_model_product_tea" | ||
,"uid","pid","title" | ||
,1,2,"Godesberger Burgtee" | ||
,2,2,"Oolong" |
16 changes: 16 additions & 0 deletions
16
Tests/Functional/Controller/Fixtures/Sites/default/config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
base: '/' | ||
languages: | ||
- | ||
title: English | ||
enabled: true | ||
languageId: '0' | ||
base: / | ||
typo3Language: default | ||
locale: en_US.utf8 | ||
iso-639-1: en | ||
navigationTitle: English | ||
hreflang: en-us | ||
direction: ltr | ||
flag: us | ||
websiteTitle: '' | ||
rootPageId: 1 |
4 changes: 4 additions & 0 deletions
4
Tests/Functional/Controller/Fixtures/TypoScript/Rendering.typoscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
page = PAGE | ||
page { | ||
10 < styles.content.get | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TTN\Tea\Tests\Functional\Controller; | ||
|
||
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
|
||
/** | ||
* @covers \TTN\Tea\Controller\TeaController | ||
*/ | ||
final class TeaControllerTest extends FunctionalTestCase | ||
{ | ||
protected array $testExtensionsToLoad = ['ttn/tea']; | ||
|
||
protected array $coreExtensionsToLoad = ['typo3/cms-fluid-styled-content']; | ||
|
||
protected array $pathsToLinkInTestInstance = [ | ||
'typo3conf/ext/tea/Tests/Functional/Controller/Fixtures/Sites/' => 'typo3conf/sites', | ||
]; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->importCSVDataSet(__DIR__ . '/Fixtures/Database/SiteStructure.csv'); | ||
$this->setUpFrontendRootPage(1, [ | ||
'setup' => [ | ||
'EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript', | ||
'EXT:tea/Tests/Functional/Controller/Fixtures/TypoScript/Rendering.typoscript', | ||
], | ||
]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
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); | ||
|
||
$html = $this->executeFrontendRequest($request)->getBody()->__toString(); | ||
|
||
self::assertStringContainsString('Godesberger Burgtee', $html); | ||
self::assertStringContainsString('Oolong', $html); | ||
} | ||
} |