mirror of
https://github.com/FriendsOfTYPO3/tea.git
synced 2024-11-10 00:16:13 +01:00
[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
This commit is contained in:
parent
8587bc8389
commit
555c43e18b
6 changed files with 83 additions and 0 deletions
|
@ -0,0 +1,3 @@
|
||||||
|
tt_content
|
||||||
|
,uid,pid,CType,header,list_type
|
||||||
|
,1,1,list,Teas Index,tea_teaindex
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
pages
|
||||||
|
,uid,pid,title,slug
|
||||||
|
,1,0,Rootpage,/
|
||||||
|
,2,1,Storage,/storage
|
|
4
Tests/Functional/Controller/Fixtures/Database/Teas.csv
Normal file
4
Tests/Functional/Controller/Fixtures/Database/Teas.csv
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
"tx_tea_domain_model_product_tea"
|
||||||
|
,"uid","pid","title"
|
||||||
|
,1,2,"Godesberger Burgtee"
|
||||||
|
,2,2,"Oolong"
|
Can't render this file because it has a wrong number of fields in line 2.
|
|
@ -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
|
|
@ -0,0 +1,4 @@
|
||||||
|
page = PAGE
|
||||||
|
page {
|
||||||
|
10 < styles.content.get
|
||||||
|
}
|
52
Tests/Functional/Controller/TeaControllerTest.php
Normal file
52
Tests/Functional/Controller/TeaControllerTest.php
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue