Skip to content
Snippets Groups Projects
Commit dc3831d3 authored by Alexander Nitsche's avatar Alexander Nitsche Committed by Anja Leichsenring
Browse files

[TASK] Provide web server url configuration for acceptance tests

In order to run TYPO3 Core acceptance tests not only in the TYPO3 Core
own docker environment but in an arbitrary environment the web server
url of the testing environment should be configurable by the
environment variable "typo3TestingAcceptanceBaseUrl".

For example, having a LEMP stack with an Nginx web server available at
http://nginx:8080 you would set the variable
"typo3TestingAcceptanceBaseUrl=http://nginx:8080" in the environment
of the acceptance tests runner.

Resolves: #92205
Releases: master, 10.4
Change-Id: Ia890ed813d1e46af0b9010f325b13f08f9863ab2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65585


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: default avatarSimon Gilli <typo3@gilbertsoft.org>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent ff3e97d3
Branches
Tags
No related merge requests found
......@@ -2,7 +2,7 @@ class_name: BackendTester
modules:
enabled:
- WebDriver:
url: http://web:8000/typo3temp/var/tests/acceptance
url: '%typo3TestingAcceptanceBaseUrl%/typo3temp/var/tests/acceptance'
browser: chrome
wait: 1
host: chrome
......
......@@ -41,6 +41,9 @@ class SiteModuleCest
*/
protected function editExistingRecord(BackendTester $I)
{
$acceptanceUrl = $I->grabModuleConfig('WebDriver', 'url');
$acceptanceUrlWithTrailingSlash = rtrim($acceptanceUrl, '/') . '/';
$I->click('Sites');
$I->switchToContentFrame();
$I->canSee('Site Configuration', 'h1');
......@@ -50,11 +53,11 @@ class SiteModuleCest
$I->waitForElementNotVisible('#t3js-ui-block');
$I->canSee('Edit Site Configuration "styleguide-demo-1" on root level');
$I->fillField('//input[contains(@data-formengine-input-name, "data[site]") and contains(@data-formengine-input-name, "[identifier]")]', 'autogenerated-1-c4ca4238a0');
$I->fillField('//input[contains(@data-formengine-input-name, "data[site]") and contains(@data-formengine-input-name, "[base]")]', 'http://web:8000/typo3temp/var/tests/acceptance/');
$I->fillField('//input[contains(@data-formengine-input-name, "data[site]") and contains(@data-formengine-input-name, "[base]")]', $acceptanceUrlWithTrailingSlash);
$I->click('Languages');
$I->click('div[data-table-unique-original-value=site_language_0] > div.panel-heading > div:nth-child(1) > div:nth-child(3) > span:nth-child(1)');
$I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[title]")]', 'English');
$I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[base]")]', 'http://web:8000/typo3temp/var/tests/acceptance/');
$I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[base]")]', $acceptanceUrlWithTrailingSlash);
$I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[locale]")]', 'en_US.UTF-8');
$saveButtonLink = '//*/button[@name="_savedok"][1]';
......@@ -76,6 +79,9 @@ class SiteModuleCest
*/
public function createSiteConfigIfNoneExists(BackendTester $I, ModalDialog $modalDialog)
{
$acceptanceUrl = $I->grabModuleConfig('WebDriver', 'url');
$acceptanceUrlWithTrailingSlash = rtrim($acceptanceUrl, '/') . '/';
$I->click('Sites');
$I->switchToContentFrame();
$I->canSee('Site Configuration', 'h1');
......@@ -91,10 +97,10 @@ class SiteModuleCest
$I->waitForElementNotVisible('#t3js-ui-block');
$I->canSee('Create new Site configuration');
$I->fillField('//input[contains(@data-formengine-input-name, "data[site]") and contains(@data-formengine-input-name, "[identifier]")]', 'SitesTestIdentifier');
$I->fillField('//input[contains(@data-formengine-input-name, "data[site]") and contains(@data-formengine-input-name, "[base]")]', 'http://web:8000/typo3temp/var/tests/acceptance/');
$I->fillField('//input[contains(@data-formengine-input-name, "data[site]") and contains(@data-formengine-input-name, "[base]")]', $acceptanceUrlWithTrailingSlash);
$I->click('Languages');
$I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[title]")]', 'Homepage');
$I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[base]")]', 'http://web:8000/typo3temp/var/tests/acceptance/');
$I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[base]")]', $acceptanceUrlWithTrailingSlash);
$I->fillField('//input[contains(@data-formengine-input-name, "data[site_language]") and contains(@data-formengine-input-name, "[locale]")]', 'en_US.UTF-8');
$saveButtonLink = '//*/button[@name="_savedok"][1]';
$I->waitForElement($saveButtonLink, 30);
......
......@@ -2,7 +2,7 @@ actor: InstallTester
modules:
enabled:
- WebDriver:
url: http://web:8000/typo3temp/var/tests/acceptance
url: '%typo3TestingAcceptanceBaseUrl%/typo3temp/var/tests/acceptance'
browser: chrome
wait: 1
host: chrome
......
......@@ -27,15 +27,19 @@ class AbstractIntroductionPackage
*/
protected function manipulateSiteConfigurationOnlyForTesting(InstallTester $I): void
{
$acceptanceUrl = $I->grabModuleConfig('WebDriver', 'url');
$acceptanceUrlWithTrailingSlash = rtrim($acceptanceUrl, '/') . '/';
$acceptanceHost = $this->getHostWithPortFromUrl($acceptanceUrl);
$trustedHostsPatternConfig = '<?php' . PHP_EOL
. '$GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'trustedHostsPattern\'] = \'web:8000\';';
. '$GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'trustedHostsPattern\'] = \'' . $acceptanceHost . '\';';
$I->writeToFile('typo3conf/AdditionalConfiguration.php', $trustedHostsPatternConfig);
$configFile = __DIR__ . '/../../../../../../typo3temp/var/tests/acceptance/typo3conf/sites/introduction/config.yaml';
$config = file($configFile);
if (strpos($config[0], 'base: /') !== false) {
$I->amGoingTo('manipulate base in sites config');
$config[0] = 'base: http://web:8000/typo3temp/var/tests/acceptance/' . PHP_EOL;
$config[0] = 'base: ' . $acceptanceUrlWithTrailingSlash . PHP_EOL;
file_put_contents($configFile, $config);
}
$I->amOnPage('/typo3');
......@@ -43,4 +47,14 @@ class AbstractIntroductionPackage
$I->switchToContentFrame();
$I->click('Flush cache');
}
/**
* @param string $url
* @return string Host with port
*/
protected function getHostWithPortFromUrl(string $url): string
{
$urlParts = parse_url($url);
return $urlParts['host'] . (isset($urlParts['port']) ? ':' . $urlParts['port'] : '');
}
}
......@@ -2,7 +2,7 @@ class_name: BackendTester
modules:
enabled:
- WebDriver:
url: http://web:8000/typo3temp/var/tests/acceptance
url: '%typo3TestingAcceptanceBaseUrl%/typo3temp/var/tests/acceptance'
browser: chrome
wait: 1
host: chrome
......
......@@ -2,7 +2,7 @@ class_name: BackendTester
modules:
enabled:
- WebDriver:
url: http://web:8000/typo3temp/var/tests/acceptance
url: '%typo3TestingAcceptanceBaseUrl%/typo3temp/var/tests/acceptance'
browser: chrome
wait: 1
host: chrome
......
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\Tests\Acceptance\Support\Helper;
use Codeception\Module;
/**
* Helper to expose params of Codeception suites to tests.
*
*
* Example 1 "Retrieve configuration param of other module"
*
* suite.yml:
* ----------
* modules:
* enabled:
* - WebDriver:
* browser: chrome
*
* ConfigCest.php
* --------------
* $webDriverUrl = $I->grabModuleConfig('WebDriver', 'browser');
*
*
* Example 2 "Expose arbitrary configuration params to tests"
*
* suite.yml:
* ----------
* modules:
* config:
* - TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Config:
* myCustomParam: myCustomValue
*
* ConfigCest.php
* --------------
* $myCustomName = $I->grabConfig('myCustomParam');
*/
class Config extends Module
{
/**
* Retrieves configuration of this module.
*
* @param string|null $parameter
* @return array|string|null
* @throws \Codeception\Exception\ModuleException
*/
public function grabConfig(string $parameter = null)
{
return $this->grab($parameter);
}
/**
* Retrieves configuration of a different module.
*
* @param string $moduleName
* @param string|null $parameter
* @return array|string|null
* @throws \Codeception\Exception\ModuleException
*/
public function grabModuleConfig(string $moduleName, string $parameter = null)
{
return $this->grab($parameter, $moduleName);
}
/**
* Retrieves configuration of a module.
*
* @param string|null $parameter
* @param string|null $moduleName
* @return array|string|null
* @throws \Codeception\Exception\ModuleException
*/
protected function grab(string $parameter = null, string $moduleName = null)
{
$module = is_string($moduleName) ? $this->getModule($moduleName) : $this;
return $module->_getConfig($parameter);
}
}
......@@ -14,3 +14,7 @@ extensions:
modules:
enabled:
- Filesystem
- TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\Config
params:
- parameters.yml
- env
#
# Default parameters for use in the codeception.yml.
# These values can be overridden by environment variables,
# e.g. in Build/testing-docker/local/docker-compose.yml
#
typo3TestingAcceptanceBaseUrl: http://web:8000
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment