From a4089e04e953610222f217768eee34f08847e79c Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Sun, 27 May 2018 00:28:13 +0200 Subject: [PATCH] [FEATURE] Functional tests for the tea controller (#21) --- .travis.yml | 2 - .../Controller/Fixtures/Database/pages.xml | 30 +++++++++++ .../Fixtures/Frontend/Basic.typoscript | 54 +++++++++++++++++++ .../Fixtures/Frontend/Template.html | 1 + .../Controller/TeaControllerTest.php | 51 ++++++++++++++++++ composer.json | 1 + 6 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 Tests/Functional/Controller/Fixtures/Database/pages.xml create mode 100644 Tests/Functional/Controller/Fixtures/Frontend/Basic.typoscript create mode 100644 Tests/Functional/Controller/Fixtures/Frontend/Template.html create mode 100644 Tests/Functional/Controller/TeaControllerTest.php diff --git a/.travis.yml b/.travis.yml index bb000b1..31a3836 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,6 @@ env: - typo3DatabaseHost=localhost typo3DatabaseName=typo3 typo3DatabaseUsername=travis typo3DatabasePassword='' - TYPO3_PATH_ROOT=$PWD/.Build/public matrix: - - TYPO3_VERSION="^7.6" DEPENDENCIES=latest - - TYPO3_VERSION="^7.6" DEPENDENCIES=oldest - TYPO3_VERSION="^8.7" DEPENDENCIES=latest - TYPO3_VERSION="^8.7" DEPENDENCIES=oldest diff --git a/Tests/Functional/Controller/Fixtures/Database/pages.xml b/Tests/Functional/Controller/Fixtures/Database/pages.xml new file mode 100644 index 0000000..efc9631 --- /dev/null +++ b/Tests/Functional/Controller/Fixtures/Database/pages.xml @@ -0,0 +1,30 @@ + + + + 1 + 0 + Root + 1 + 15 + + + 1 + 1 + list + tea_tea + + + + + + + Tea->index + + + + + + ]]> + + diff --git a/Tests/Functional/Controller/Fixtures/Frontend/Basic.typoscript b/Tests/Functional/Controller/Fixtures/Frontend/Basic.typoscript new file mode 100644 index 0000000..be86e8f --- /dev/null +++ b/Tests/Functional/Controller/Fixtures/Frontend/Basic.typoscript @@ -0,0 +1,54 @@ +lib.dynamicContent = COA +lib.dynamicContent { + 10 = LOAD_REGISTER + 10.colPos.cObject = TEXT + 10.colPos.cObject { + field = colPos + ifEmpty.cObject = TEXT + ifEmpty.cObject { + value.current = 1 + ifEmpty = 0 + } + } + + 20 = CONTENT + 20 { + table = tt_content + select { + orderBy = sorting + where = colPos={register:colPos} + where.insertData = 1 + } + } + + 90 = RESTORE_REGISTER +} + +config { + doctype = html5 + xmlprologue = none + + inlineStyle2TempFile = 0 + removeDefaultJS = 0 + compressJs = 0 + concatenateJs = 0 + compressCss = 0 + concatenateCss = 0 + + no_cache = 1 + debug = 0 + xhtml_cleaning = 0 + admPanel = 0 + disableAllHeaderCode = 1 + sendCacheHeaders = 0 + absRefPrefix = / + contentObjectExceptionHandler = 0 +} + +page = PAGE +page { + 10 = FLUIDTEMPLATE + 10 { + file = EXT:tea/Tests/Functional/Controller/Fixtures/Frontend/Template.html + } +} diff --git a/Tests/Functional/Controller/Fixtures/Frontend/Template.html b/Tests/Functional/Controller/Fixtures/Frontend/Template.html new file mode 100644 index 0000000..10992ca --- /dev/null +++ b/Tests/Functional/Controller/Fixtures/Frontend/Template.html @@ -0,0 +1 @@ + diff --git a/Tests/Functional/Controller/TeaControllerTest.php b/Tests/Functional/Controller/TeaControllerTest.php new file mode 100644 index 0000000..3622232 --- /dev/null +++ b/Tests/Functional/Controller/TeaControllerTest.php @@ -0,0 +1,51 @@ + + */ +class TeaControllerTest extends FunctionalTestCase +{ + /** + * @var string[] + */ + protected $testExtensionsToLoad = ['typo3conf/ext/tea']; + + /** + * @var string[] + */ + protected $coreExtensionsToLoad = ['fluid_styled_content']; + + protected function setUp() + { + parent::setUp(); + + $this->importDataSet(__DIR__ . '/Fixtures/Database/pages.xml'); + $this->importDataSet(__DIR__ . '/../Domain/Repository/Fixtures/Product/Tea.xml'); + + $this->setUpFrontendRootPage( + 1, + [ + 'EXT:fluid_styled_content/Configuration/TypoScript/setup.txt', + 'EXT:tea/Configuration/TypoScript/setup.txt', + 'EXT:tea/Tests/Functional/Controller/Fixtures/Frontend/Basic.typoscript', + ] + ); + } + + /** + * @test + */ + public function indexActionRendersTeaTitle() + { + $responseContent = $this->getFrontendResponse(1)->getContent(); + + $teaTitle = 'Earl Grey'; + $this->assertContains($teaTitle, $responseContent); + } +} diff --git a/composer.json b/composer.json index e88ced7..e533b24 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,7 @@ "typo3/cms-frontend": "^7.6.23 || ^8.7.9" }, "require-dev": { + "typo3/cms-fluid-styled-content": "^7.6.23 || ^8.7.9", "helhum/typo3-composer-setup": "^0.5.1", "helmich/typo3-typoscript-lint": "^1.4.4", "nimut/testing-framework": "^3.0.0",