mirror of
https://github.com/werkraum-media/thuecat.git
synced 2024-12-04 19:16:13 +01:00
Add first frontend test
This should ensure rendering works as expected. Most important: This ensures data is available in frontend templates. Add dev dependency to fluid_styled_content. This is necessary to test our rendering integration with fluid_styled_content defaults. Relates: #34
This commit is contained in:
parent
dc09713884
commit
1a6940633e
7 changed files with 223 additions and 0 deletions
42
Tests/Functional/Fixtures/Frontend/Content.xml
Normal file
42
Tests/Functional/Fixtures/Frontend/Content.xml
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dataset>
|
||||
<pages>
|
||||
<uid>1</uid>
|
||||
<pid>0</pid>
|
||||
<title>Root</title>
|
||||
<slug>/</slug>
|
||||
<sorting>128</sorting>
|
||||
<deleted>0</deleted>
|
||||
</pages>
|
||||
<pages>
|
||||
<uid>2</uid>
|
||||
<pid>1</pid>
|
||||
<title>Tourist Attraction</title>
|
||||
<slug>/example-attraction/</slug>
|
||||
<sorting>128</sorting>
|
||||
<deleted>0</deleted>
|
||||
</pages>
|
||||
<pages>
|
||||
<uid>3</uid>
|
||||
<pid>1</pid>
|
||||
<title>Storage</title>
|
||||
<doktype>254</doktype>
|
||||
<sorting>128</sorting>
|
||||
<deleted>0</deleted>
|
||||
</pages>
|
||||
<tt_content>
|
||||
<uid>2</uid>
|
||||
<pid>2</pid>
|
||||
<hidden>0</hidden>
|
||||
<sorting>1</sorting>
|
||||
<CType>thuecat_tourist_attraction</CType>
|
||||
<header>Show Example Tourist Attraction</header>
|
||||
<deleted>0</deleted>
|
||||
<starttime>0</starttime>
|
||||
<endtime>0</endtime>
|
||||
<colPos>0</colPos>
|
||||
<sys_language_uid>0</sys_language_uid>
|
||||
<records>1</records>
|
||||
</tt_content>
|
||||
</dataset>
|
||||
|
2
Tests/Functional/Fixtures/Frontend/Rendering.typoscript
Normal file
2
Tests/Functional/Fixtures/Frontend/Rendering.typoscript
Normal file
|
@ -0,0 +1,2 @@
|
|||
page = PAGE
|
||||
page.10 < styles.content.get
|
47
Tests/Functional/Fixtures/Frontend/Sites/example/config.yaml
Normal file
47
Tests/Functional/Fixtures/Frontend/Sites/example/config.yaml
Normal file
|
@ -0,0 +1,47 @@
|
|||
base: '/'
|
||||
languages:
|
||||
-
|
||||
title: Deutsch
|
||||
enabled: true
|
||||
base: /
|
||||
typo3Language: de
|
||||
locale: de_DE.UTF-8
|
||||
iso-639-1: de
|
||||
navigationTitle: Deutsch
|
||||
hreflang: de-DE
|
||||
direction: ''
|
||||
flag: de
|
||||
websiteTitle: ''
|
||||
languageId: 0
|
||||
-
|
||||
title: English
|
||||
enabled: true
|
||||
base: /en
|
||||
typo3Language: default
|
||||
locale: en_GB.UTF-8
|
||||
iso-639-1: en
|
||||
websiteTitle: ''
|
||||
navigationTitle: English
|
||||
hreflang: en-GB
|
||||
direction: ''
|
||||
flag: gb
|
||||
languageId: 1
|
||||
fallbackType: strict
|
||||
fallbacks: '0'
|
||||
-
|
||||
title: French
|
||||
enabled: true
|
||||
base: /fr/
|
||||
typo3Language: fr
|
||||
locale: fr_FR.ytf8
|
||||
iso-639-1: fr
|
||||
websiteTitle: ''
|
||||
navigationTitle: ''
|
||||
hreflang: fr-FR
|
||||
direction: ''
|
||||
fallbackType: strict
|
||||
fallbacks: '1,0'
|
||||
flag: fr
|
||||
languageId: 2
|
||||
rootPageId: 1
|
||||
websiteTitle: 'Example Website'
|
|
@ -0,0 +1,18 @@
|
|||
base: /
|
||||
languages:
|
||||
-
|
||||
title: e
|
||||
enabled: true
|
||||
base: /
|
||||
typo3Language: default
|
||||
locale: e
|
||||
iso-639-1: ab
|
||||
websiteTitle: ''
|
||||
navigationTitle: ''
|
||||
hreflang: ''
|
||||
direction: ''
|
||||
flag: global
|
||||
languageId: 0
|
||||
rootPageId: 1
|
||||
thuecat_api_key: ''
|
||||
websiteTitle: test
|
21
Tests/Functional/Fixtures/Frontend/TouristAttractions.xml
Normal file
21
Tests/Functional/Fixtures/Frontend/TouristAttractions.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dataset>
|
||||
<tx_thuecat_tourist_attraction>
|
||||
<uid>1</uid>
|
||||
<pid>3</pid>
|
||||
<title>Erste Attraktion</title>
|
||||
<description>Die Beschreibung der Attraktion</description>
|
||||
<town>1</town>
|
||||
<media>[{"mainImage":true,"type":"image","title":"Erfurt-Dom und Severikirche-beleuchtet.jpg","description":"","url":"https:\/\/cms.thuecat.org\/o\/adaptive-media\/image\/5159216\/Preview-1280x0\/image","copyrightYear":2016,"license":{"type":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/","author":""}},{"mainImage":false,"type":"image","title":"Erfurt-Dom-und-Severikirche.jpg","description":"Sicht auf Dom St. Marien, St. Severikirche sowie die davor liegenden Klostergeb\u00e4ude und einem Ausschnitt des Biergartens umgeben von einem d\u00e4mmerungsverf\u00e4rten Himmel","url":"https:\/\/cms.thuecat.org\/o\/adaptive-media\/image\/5159186\/Preview-1280x0\/image","copyrightYear":2020,"license":{"type":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/","author":""}},{"mainImage":false,"type":"image","title":"Erfurt-Dom und Severikirche-beleuchtet.jpg","description":"","url":"https:\/\/cms.thuecat.org\/o\/adaptive-media\/image\/5159216\/Preview-1280x0\/image","copyrightYear":2016,"license":{"type":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/","author":""}}]</media>
|
||||
<opening_hours>[{"opens":"09:30:00","closes":"18:00:00","from":{"date":"2021-05-01 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"through":{"date":"2021-10-31 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"daysOfWeek":["Saturday","Friday","Thursday","Tuesday","Monday","Wednesday"]},{"opens":"13:00:00","closes":"18:00:00","from":{"date":"2021-05-01 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"through":{"date":"2021-10-31 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"daysOfWeek":["Sunday"]},{"opens":"09:30:00","closes":"17:00:00","from":{"date":"2021-11-01 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"through":{"date":"2022-04-30 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"daysOfWeek":["Saturday","Friday","Thursday","Tuesday","Monday","Wednesday"]},{"opens":"13:00:00","closes":"17:00:00","from":{"date":"2021-11-01 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"through":{"date":"2022-04-30 00:00:00.000000","timezone_type":3,"timezone":"UTC"},"daysOfWeek":["Sunday"]}]</opening_hours>
|
||||
<address>{"street":"Beispielstraße 1a","zip":"99084","city":"Beispielstadt","email":"example@example.com","phone":"(0)30 23125 000","fax":"","geo":{"latitude":50.975955358589545,"longitude":11.023667024961856}}</address>
|
||||
<offers>[{"title":"F\u00fchrungen","description":"Immer samstags, um 11:15 Uhr findet eine \u00f6ffentliche F\u00fchrung durch das Museum statt. Dauer etwa 90 Minuten","prices":[{"title":"Erwachsene","description":"","price":8,"currency":"EUR","rule":"PerPerson"},{"title":"Erm\u00e4\u00dfigt","description":"als erm\u00e4\u00dfigt gelten schulpflichtige Kinder, Auszubildende, Studierende, Rentner\/-innen, Menschen mit Behinderungen, Inhaber Sozialausweis der Landeshauptstadt Erfurt","price":5,"currency":"EUR","rule":"PerPerson"}]},{"title":"Eintritt","description":"Schulklassen und Kitagruppen im Rahmen des Unterrichts: Eintritt frei\nAn jedem ersten Dienstag im Monat: Eintritt frei","prices":[{"title":"Erm\u00e4\u00dfigt","description":"als erm\u00e4\u00dfigt gelten schulpflichtige Kinder, Auszubildende, Studierende, Rentner\/-innen, Menschen mit Behinderungen, Inhaber Sozialausweis der Landeshauptstadt Erfurt","price":5,"currency":"EUR","rule":"PerPerson"},{"title":"Familienkarte","description":"","price":17,"currency":"EUR","rule":"PerGroup"},{"title":"ErfurtCard","description":"","price":14.9,"currency":"EUR","rule":"PerPackage"},{"title":"Erwachsene","description":"","price":8,"currency":"EUR","rule":"PerPerson"}]}]</offers>
|
||||
</tx_thuecat_tourist_attraction>
|
||||
<tx_thuecat_town>
|
||||
<uid>1</uid>
|
||||
<pid>3</pid>
|
||||
<title>Beispielstadt</title>
|
||||
<description>Die Beschreibung der Stadt</description>
|
||||
</tx_thuecat_town>
|
||||
</dataset>
|
||||
|
92
Tests/Functional/FrontendTest.php
Normal file
92
Tests/Functional/FrontendTest.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Copyright (C) 2021 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
namespace WerkraumMedia\ThueCat\Tests\Functional;
|
||||
|
||||
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
|
||||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
||||
|
||||
/**
|
||||
* @covers \
|
||||
*/
|
||||
class FrontendTest extends FunctionalTestCase
|
||||
{
|
||||
protected $coreExtensionsToLoad = [
|
||||
'fluid_styled_content',
|
||||
];
|
||||
|
||||
protected $testExtensionsToLoad = [
|
||||
'typo3conf/ext/thuecat/',
|
||||
];
|
||||
|
||||
protected $pathsToLinkInTestInstance = [
|
||||
'typo3conf/ext/thuecat/Tests/Functional/Fixtures/Frontend/Sites/' => 'typo3conf/sites',
|
||||
];
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->importDataSet('EXT:thuecat/Tests/Functional/Fixtures/Frontend/Content.xml');
|
||||
$this->setUpFrontendRootPage(1, [
|
||||
'EXT:thuecat/Tests/Functional/Fixtures/Frontend/Rendering.typoscript',
|
||||
'EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript',
|
||||
'EXT:thuecat/Configuration/TypoScript/ContentElements/setup.typoscript',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function touristAttractionContentElementIsRendered(): void
|
||||
{
|
||||
$this->importDataSet('EXT:thuecat/Tests/Functional/Fixtures/Frontend/TouristAttractions.xml');
|
||||
|
||||
$request = new InternalRequest();
|
||||
$request = $request->withPageId(2);
|
||||
|
||||
$result = $this->executeFrontendRequest($request);
|
||||
|
||||
self::assertSame(200, $result->getStatusCode());
|
||||
|
||||
self::assertStringContainsString('Erste Attraktion (Beispielstadt)', (string)$result->getBody());
|
||||
self::assertStringContainsString('Die Beschreibung der Attraktion', (string)$result->getBody());
|
||||
|
||||
self::assertStringContainsString('<img src="https://cms.thuecat.org/o/adaptive-media/image/5159216/Preview-1280x0/image" />', (string)$result->getBody());
|
||||
|
||||
self::assertStringContainsString('Beispielstraße 1a', (string)$result->getBody());
|
||||
self::assertStringContainsString('99084', (string)$result->getBody());
|
||||
self::assertStringContainsString('Beispielstadt', (string)$result->getBody());
|
||||
self::assertStringContainsString('example@example.com', (string)$result->getBody());
|
||||
self::assertStringContainsString('(0)30 23125 000', (string)$result->getBody());
|
||||
|
||||
self::assertStringContainsString('Monday: 09:30:00 - 18:00:00', (string)$result->getBody());
|
||||
|
||||
self::assertStringContainsString('Führungen', (string)$result->getBody());
|
||||
self::assertStringContainsString('Immer samstags, um 11:15 Uhr findet eine öffentliche Führung durch das Museum statt. Dauer etwa 90 Minuten', (string)$result->getBody());
|
||||
|
||||
self::assertStringContainsString('Erwachsene', (string)$result->getBody());
|
||||
self::assertStringContainsString('8,00 EUR', (string)$result->getBody());
|
||||
self::assertStringContainsString('pro Person', (string)$result->getBody());
|
||||
}
|
||||
}
|
|
@ -49,6 +49,7 @@
|
|||
"phpstan/phpstan": "^0.12.71",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"symplify/easy-coding-standard": "^9.0",
|
||||
"typo3/cms-fluid-styled-content": "^10.4",
|
||||
"typo3/testing-framework": "^6.6"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in a new issue