mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-09-19 23:16:12 +02: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:
Daniel Siepmann 2023-11-27 14:18:04 +01:00 committed by GitHub
parent 8587bc8389
commit 555c43e18b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 83 additions and 0 deletions

View file

@ -0,0 +1,3 @@
tt_content
,uid,pid,CType,header,list_type
,1,1,list,Teas Index,tea_teaindex
1 tt_content
2 ,uid,pid,CType,header,list_type
3 ,1,1,list,Teas Index,tea_teaindex

View file

@ -0,0 +1,4 @@
pages
,uid,pid,title,slug
,1,0,Rootpage,/
,2,1,Storage,/storage
1 pages
2 ,uid,pid,title,slug
3 ,1,0,Rootpage,/
4 ,2,1,Storage,/storage

View 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.

View file

@ -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

View file

@ -0,0 +1,4 @@
page = PAGE
page {
10 < styles.content.get
}

View 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);
}
}