Commit aab39102 authored by Davert's avatar Davert Committed by Christian Kuhn
Browse files

[TASK] Refactor acceptance tests

typo3/testing-framework got a major release:
composer update typo3/testing-framework ^4.0

* codeception acceptance tests now live in a proper php namespace
* merged installation suites yml files into one
* installer tests are now one suite with different environment settings
* aligned with changes in typo3/testing-framework
* renamed Acceptance test suite to Backend test suite
* removed Admin/Editor steps, replaced with useExistingLogin('role')

Resolves: #85472
Releases: master
Change-Id: Ia049b43f5f9f645dddb509bde557ad83a7ac9023
Reviewed-on: https://review.typo3.org/57461


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 49f4e9ab
......@@ -60,3 +60,5 @@ phantomjsdriver.log
#
# root .htaccess file
/.htaccess
typo3/sysext/core/Tests/Acceptance/Support/_generated/
......@@ -58,6 +58,8 @@ class NodeVisitor extends NodeVisitorAbstract
'api', 'author', 'category', 'copyright', 'deprecated', 'example', 'filesource', 'global', 'ignore', 'internal', 'license', 'link', 'method', 'package', 'param', 'property', 'property-read', 'property-write', 'return', 'see', 'since', 'source', 'subpackage', 'throws', 'todo', 'TODO', 'usedby', 'uses', 'var', 'version',
// PHPUnit tags
'codeCoverageIgnore', 'codeCoverageIgnoreStart', 'codeCoverageIgnoreEnd', 'test', 'covers', 'dataProvider', 'group', 'skip', 'depends', 'expectedException', 'before',
// codeception tags
'env',
// PHPCheckStyle
'SuppressWarnings', 'noinspection',
// Extbase related (deprecated)
......
......@@ -56,6 +56,12 @@ abstract public class AbstractCoreSpec {
" typo3DatabaseHost=\"localhost\"" +
" typo3InstallToolPassword=\"klaus\"";
protected String installCredentialsMysql =
"typo3InstallMysqlDatabaseName=\"func_install\"" +
" typo3InstallMysqlDatabaseUsername=\"funcu\"" +
" typo3InstallMysqlDatabasePassword=\"funcp\"" +
" typo3InstallMysqlDatabaseHost=\"localhost\"";
protected String credentialsMssql =
"typo3DatabaseDriver=\"sqlsrv\"" +
" typo3DatabaseName=\"func\"" +
......@@ -63,15 +69,18 @@ abstract public class AbstractCoreSpec {
" typo3DatabaseUsername=\"SA\"" +
" typo3DatabaseHost=\"localhost\"" +
" typo3DatabasePort=\"1433\"" +
" typo3DatabaseCharset=\"utf-8\"" +
" typo3InstallToolPassword=\"klaus\"";
" typo3DatabaseCharset=\"utf-8\"";
protected String credentialsPgsql =
"typo3DatabaseDriver=\"pdo_pgsql\"" +
" typo3DatabaseName=\"func\"" +
" typo3DatabaseUsername=\"bamboo\"" +
" typo3DatabaseHost=\"localhost\"" +
" typo3InstallToolPassword=\"klaus\"";
" typo3DatabaseHost=\"localhost\"";
protected String installCredentialsPgsql =
"typo3InstallPostgresqlDatabaseName=\"func_atipgsql\"" +
" typo3InstallPostgresqlDatabaseUsername=\"bamboo\"" +
" typo3InstallPostgresqlDatabaseHost=\"localhost\"";
protected String credentialsSqlite =
"typo3DatabaseDriver=\"pdo_sqlite\"";
......@@ -181,14 +190,14 @@ abstract public class AbstractCoreSpec {
this.getTaskComposerInstall(),
this.getTaskPrepareAcceptanceTest(),
new CommandTask()
.description("Execute codeception AcceptanceInstallMysql suite")
.description("Install TYPO3 on mysql")
.executable("codecept")
.argument("run AcceptanceInstallMysql -d -c " + this.testingFrameworkBuildPath + "AcceptanceTestsInstallMysql.yml --xml reports.xml --html reports.html")
.environmentVariables(this.credentialsMysql)
.argument("run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=mysql,headless --xml reports.xml --html reports.html")
.environmentVariables(this.installCredentialsMysql)
)
.finalTasks(
new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
.resultDirectories("typo3temp/var/tests/AcceptanceReportsInstallMysql/reports.xml"),
.resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml"),
this.getTaskDeleteMysqlDatabases(),
this.getTaskTearDownAcceptanceTestSetup()
)
......@@ -197,7 +206,7 @@ abstract public class AbstractCoreSpec {
)
.artifacts(new Artifact()
.name("Test Report")
.copyPattern("typo3temp/var/tests/AcceptanceReportsInstallMysql/")
.copyPattern("typo3temp/var/tests/AcceptanceReports/")
.shared(false)
)
.cleanWorkingDirectory(true);
......@@ -219,14 +228,14 @@ abstract public class AbstractCoreSpec {
this.getTaskComposerInstall(),
this.getTaskPrepareAcceptanceTest(),
new CommandTask()
.description("Execute codeception AcceptanceInstallPgsql suite")
.description("Install TYPO3 on postgresql")
.executable("codecept")
.argument("run AcceptanceInstallPgsql -d -c " + this.testingFrameworkBuildPath + "AcceptanceTestsInstallPgsql.yml --xml reports.xml --html reports.html")
.environmentVariables(this.credentialsPgsql)
.argument("run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=postgresql,headless --xml reports.xml --html reports.html")
.environmentVariables(this.installCredentialsPgsql)
)
.finalTasks(
new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
.resultDirectories("typo3temp/var/tests/AcceptanceReportsInstallPgsql/reports.xml"),
.resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml"),
this.getTaskDeletePgsqlDatabases(),
this.getTaskTearDownAcceptanceTestSetup()
)
......@@ -235,7 +244,7 @@ abstract public class AbstractCoreSpec {
)
.artifacts(new Artifact()
.name("Test Report")
.copyPattern("typo3temp/var/tests/AcceptanceReportsInstallPgsql/")
.copyPattern("typo3temp/var/tests/AcceptanceReports/")
.shared(false)
)
.cleanWorkingDirectory(true);
......@@ -257,14 +266,13 @@ abstract public class AbstractCoreSpec {
this.getTaskComposerInstall(),
this.getTaskPrepareAcceptanceTest(),
new CommandTask()
.description("Execute codeception AcceptanceInstallSqlite suite")
.description("Install TYPO3 on sqlite")
.executable("codecept")
.argument("run AcceptanceInstallSqlite -d -c " + this.testingFrameworkBuildPath + "AcceptanceTestsInstallSqlite.yml --xml reports.xml --html reports.html")
.environmentVariables(this.credentialsSqlite)
.argument("run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=sqlite,headless --xml reports.xml --html reports.html")
)
.finalTasks(
new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
.resultDirectories("typo3temp/var/tests/AcceptanceReportsInstallSqlite/reports.xml"),
.resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml"),
this.getTaskTearDownAcceptanceTestSetup()
)
.requirements(
......@@ -272,7 +280,7 @@ abstract public class AbstractCoreSpec {
)
.artifacts(new Artifact()
.name("Test Report")
.copyPattern("typo3temp/var/tests/AcceptanceReportsInstallSqlite/")
.copyPattern("typo3temp/var/tests/AcceptanceReports/")
.shared(false)
)
.cleanWorkingDirectory(true);
......
......@@ -64,7 +64,7 @@
"fiunchinho/phpunit-randomizer": "^4.0",
"friendsofphp/php-cs-fixer": "^2.0",
"typo3/cms-styleguide": "^9.1",
"typo3/testing-framework": "^3.8"
"typo3/testing-framework": "^4.0"
},
"suggest": {
"ext-gd": "GDlib/Freetype is required for building images with text (GIFBUILDER) and can also be used to scale images",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "f62eab6aa1190b064eca1d92cf446797",
"content-hash": "6f16d9031c0614955697202f7c44bc49",
"packages": [
{
"name": "cogpowered/finediff",
......@@ -4404,39 +4404,37 @@
},
{
"name": "typo3/testing-framework",
"version": "3.8.1",
"version": "4.0.0",
"source": {
"type": "git",
"url": "https://github.com/TYPO3/testing-framework.git",
"reference": "024448439a037445f712ed9b60a3da293d594aaf"
"reference": "0155dc11572dd7722506ea0005a0e1c24ce89bdf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/024448439a037445f712ed9b60a3da293d594aaf",
"reference": "024448439a037445f712ed9b60a3da293d594aaf",
"url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/0155dc11572dd7722506ea0005a0e1c24ce89bdf",
"reference": "0155dc11572dd7722506ea0005a0e1c24ce89bdf",
"shasum": ""
},
"require": {
"mikey179/vfsstream": "~1.6.0",
"phpunit/phpunit": "^7.1",
"typo3/cms-backend": "^9.2",
"typo3/cms-core": "^9.2",
"typo3/cms-extbase": "^9.2",
"typo3/cms-fluid": "^9.2",
"typo3/cms-frontend": "^9.2",
"typo3/cms-backend": "^9.3",
"typo3/cms-core": "^9.3",
"typo3/cms-extbase": "^9.3",
"typo3/cms-fluid": "^9.3",
"typo3/cms-frontend": "^9.3",
"typo3fluid/fluid": "^2.5"
},
"suggest": {
"codeception/codeception": "^2.4",
"typo3/cms-saltedpasswords": "^9.2",
"typo3/cms-saltedpasswords": "^9.3",
"typo3/cms-styleguide": "^9.0"
},
"type": "library",
"autoload": {
"psr-4": {
"TYPO3\\TestingFramework\\": "Classes/",
"TYPO3\\CMS\\Core\\Tests\\": "compat/core/",
"TYPO3\\CMS\\Fluid\\Tests\\": "compat/fluid/"
"TYPO3\\TestingFramework\\": "Classes/"
}
},
"notification-url": "https://packagist.org/downloads/",
......@@ -4462,7 +4460,7 @@
"tests",
"typo3"
],
"time": "2018-06-13T17:03:55+00:00"
"time": "2018-07-07T08:51:19+00:00"
},
{
"name": "webmozart/assert",
......
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
- \Helper\Acceptance
- Asserts
config:
WebDriver:
url: http://localhost:8000/typo3temp/var/tests/acceptance
browser: chrome
port: 9515
capabilities:
# Disable the "scroll to element before clicking" behavior as this breaks tests
# where for example a fixed docbar is used. Selenium scrolls to the element before
# clicking it and then complains that it can't click the element because another elemnt
# is overlaying it.
# You have to ensure that the element is in the viewport by your own before clicking it!
# You can simply do that by scrolling to it.
elementScrollBehavior: 1
chromeOptions:
args: ["--headless", "--no-sandbox", "window-size=1280x1024", "--proxy-server='direct://'", "--proxy-bypass-list=*", "--disable-gpu"]
\ No newline at end of file
class_name: BackendTester
modules:
enabled:
- WebDriver:
url: http://master:8000/typo3temp/var/tests/acceptance
browser: chrome
wait: 1
host: chrome
- \TYPO3\TestingFramework\Core\Acceptance\Helper\Acceptance
- \TYPO3\TestingFramework\Core\Acceptance\Helper\Login:
sessions:
# This sessions must exist in the database fixture to get a logged in state.
editor: ff83dfd81e20b34c27d3e97771a4525a
admin: 886526ce72b86870739cc41991144ec1
- Asserts
extensions:
enabled:
- TYPO3\TestingFramework\Core\Acceptance\Extension\BackendCoreEnvironment
env:
headless:
modules:
config:
WebDriver:
host: localhost
port: 9515
url: http://localhost:8000/typo3temp/var/tests/acceptance
capabilities:
# Disable the "scroll to element before clicking" behavior as this breaks tests
# where for example a fixed docbar is used. Selenium scrolls to the element before
# clicking it and then complains that it can't click the element because another elemnt
# is overlaying it.
# You have to ensure that the element is in the viewport by your own before clicking it!
# You can simply do that by scrolling to it.
elementScrollBehavior: 1
chromeOptions:
args: ["--headless", "--no-sandbox", "window-size=1280x1024", "--proxy-server='direct://'", "--proxy-bypass-list=*", "--disable-gpu"]
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\BackendUser;
/*
......@@ -16,7 +15,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\BackendUser;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
use TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester;
/**
* Tests concerning the compare view of BE user module
......@@ -24,11 +23,11 @@ use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
class CompareUserCest
{
/**
* @param Admin $I
* @param BackendTester $I
*/
public function _before(Admin $I)
public function _before(BackendTester $I)
{
$I->useExistingSession();
$I->useExistingSession('admin');
$I->see('Backend users');
$I->click('Backend users');
......@@ -36,16 +35,16 @@ class CompareUserCest
}
/**
* @param Admin $I
* @param BackendTester $I
*/
public function editingBeUserRecordsFromCompareViewWorks(Admin $I)
public function editingBeUserRecordsFromCompareViewWorks(BackendTester $I)
{
// put two users into compare list
$I->see('Backend User Listing');
$I->click('#typo3-backend-user-list > tbody > tr:nth-child(1) > td.col-control > div:nth-child(3) > a');
$I->waitForElementVisible('table#typo3-backend-user-list');
$I->click('#typo3-backend-user-list > tbody > tr:nth-child(2) > td.col-control > div:nth-child(3) > a');
$I->waitForElementVisible('table#typo3-backend-user-list-compare');
$I->waitForElementVisible('table#typo3-backend-user-list-compare', 20);
$I->canSeeNumberOfElements('#typo3-backend-user-list-compare tbody tr', 2);
$I->click('body > div > div.module-body.t3js-module-body > form:nth-child(4) > input');
$I->waitForElementVisible('table.table-striped');
......@@ -58,7 +57,7 @@ class CompareUserCest
$I->canSee('Edit Backend user "' . $usernameFirstCompare . '" on root level');
// back to compare view
$I->click('div.module-docheader .btn.t3js-editform-close');
$I->click('.module-docheader .btn.t3js-editform-close');
$I->waitForElementVisible('table.table-striped');
$I->canSee('Compare backend users', 'h1');
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\BackendUser;
/*
......@@ -16,7 +15,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\BackendUser;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
use TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester;
/**
* Tests concerning the listing of BeUser groups
......@@ -24,11 +23,11 @@ use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
class ListGroupCest
{
/**
* @param Admin $I
* @param BackendTester $I
*/
public function _before(Admin $I)
public function _before(BackendTester $I)
{
$I->useExistingSession();
$I->useExistingSession('admin');
$I->see('Backend users');
$I->click('Backend users');
......@@ -39,7 +38,10 @@ class ListGroupCest
$I->canSee('Backend User Group Listing', 'h1');
}
public function canEditBeGroupsFromListView(Admin $I)
/**
* @param BackendTester $I
*/
public function canEditBeGroupsFromListView(BackendTester $I)
{
$groupname = $I->grabTextFrom('table.table-striped > tbody > tr:nth-child(1) > td.col-title > a > b');
......@@ -53,9 +55,9 @@ class ListGroupCest
}
/**
* @param Admin $I
* @param BackendTester $I
*/
public function canEditSubGroupFromListView(Admin $I)
public function canEditSubGroupFromListView(BackendTester $I)
{
$I->amGoingTo('test the subgroup edit form');
$groupname = $I->grabTextFrom('table.table-striped > tbody > tr:nth-child(2) > td:nth-child(3) > a:nth-child(1)');
......@@ -64,13 +66,13 @@ class ListGroupCest
}
/**
* @param Admin $I
* @param string $groupname
* @param BackendTester $I
* @param string $groupName
*/
private function openAndCloseTheEditForm(Admin $I, string $groupname): void
private function openAndCloseTheEditForm(BackendTester $I, string $groupName): void
{
$I->waitForText('Edit Backend usergroup "' . $groupname . '" on root level', 120);
$I->see('Edit Backend usergroup "' . $groupname . '" on root level', 'h1');
$I->waitForText('Edit Backend usergroup "' . $groupName . '" on root level', 120);
$I->see('Edit Backend usergroup "' . $groupName . '" on root level', 'h1');
$I->click('div.module-docheader .btn.t3js-editform-close');
$I->waitForElementVisible('table.table-striped');
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\BackendUser;
/*
......@@ -14,7 +15,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\BackendUser;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
use TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester;
/**
* List User tests
......@@ -22,11 +23,11 @@ use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
class ListUserCest
{
/**
* @param Admin $I
* @param BackendTester $I
*/
public function _before(Admin $I)
public function _before(BackendTester $I)
{
$I->useExistingSession();
$I->useExistingSession('admin');
$I->see('Backend users');
$I->click('Backend users');
......@@ -35,9 +36,9 @@ class ListUserCest
}
/**
* @param Admin $I
* @param BackendTester $I
*/
public function showsHeadingAndListsBackendUsers(Admin $I)
public function showsHeadingAndListsBackendUsers(BackendTester $I)
{
$I->see('Backend User Listing');
......@@ -49,9 +50,9 @@ class ListUserCest
}
/**
* @param Admin $I
* @param BackendTester $I
*/
public function filterUsersByUsername(Admin $I)
public function filterUsersByUsername(BackendTester $I)
{
$I->wantTo('See the table of users');
$I->waitForElementVisible('#typo3-backend-user-list');
......@@ -78,9 +79,9 @@ class ListUserCest
}
/**
* @param Admin $I
* @param BackendTester $I
*/
public function filterUsersByAdmin(Admin $I)
public function filterUsersByAdmin(BackendTester $I)
{
$I->wantTo('See the table of users');
$I->waitForElementVisible('#typo3-backend-user-list');
......@@ -107,9 +108,9 @@ class ListUserCest
}
/**
* @param Admin $I
* @param BackendTester $I
*/
public function filterUsersByStatus(Admin $I)
public function filterUsersByStatus(BackendTester $I)
{
$I->wantTo('See the table of users');
$I->waitForElementVisible('#typo3-backend-user-list');
......@@ -136,9 +137,9 @@ class ListUserCest
}
/**
* @param Admin $I
* @param BackendTester $I
*/
public function filterUsersByLogin(Admin $I)
public function filterUsersByLogin(BackendTester $I)
{
$I->wantTo('See the table of users');
$I->waitForElementVisible('#typo3-backend-user-list');
......@@ -165,9 +166,9 @@ class ListUserCest
}
/**
* @param Admin $I
* @param BackendTester $I
*/
public function filterUsersByUserGroup(Admin $I)
public function filterUsersByUserGroup(BackendTester $I)
{
$I->wantTo('See the table of users');
$I->waitForElementVisible('#typo3-backend-user-list');
......@@ -186,21 +187,9 @@ class ListUserCest
}
/**
* @param Admin $I
* @param int $countOfUsers
*/
protected function checkCountOfUsers(Admin $I, $countOfUsers)
{
$I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $countOfUsers);
$I->wantToTest('If a number of users is shown in the footer row');
$I->canSeeNumberOfElements('#typo3-backend-user-list tfoot tr', 1);
$I->see($countOfUsers . ' Users', '#typo3-backend-user-list tfoot tr');
}
/**
* @param Admin $I
* @param BackendTester $I
*/
public function canEditUsersFromIndexListView(Admin $I)
public function canEditUsersFromIndexListView(BackendTester $I)
{
$I->canSee('Backend User Listing', 'h1');
$username = $I->grabTextFrom('#typo3-backend-user-list > tbody > tr:nth-child(1) > td.col-title > a:nth-child(1) > b');
......@@ -219,12 +208,22 @@ class ListUserCest
}
/**
* @param Admin $I
* @param BackendTester $I
* @param int $countOfUsers
*/
private function checkCountOfUsers(BackendTester $I, int $countOfUsers)
{
$I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $countOfUsers);
$I->wantToTest('If a number of users is shown in the footer row');
$I->canSeeNumberOfElements('#typo3-backend-user-list tfoot tr', 1);
$I->see($countOfUsers . ' Users', '#typo3-backend-user-list tfoot tr');
}
/**
* @param BackendTester $I
* @param string $username
*
* @throws \Exception
*/
private function openAndCloseTheEditForm(Admin $I, string $username): void
private function openAndCloseTheEditForm(BackendTester $I, string $username): void
{
$I->waitForElementNotVisible('#t3js-ui-block');
$I->canSee('Edit Backend user "' . $username . '" on root level');
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Extensionmanager;
/*
......@@ -15,7 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\Extensionmanager;
*/
use Facebook\WebDriver\WebDriverKeys;
use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
use TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester;
/**
* Tests for the "Get Extensions view" of the extension manager
......@@ -23,11 +24,11 @@ use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
class GetExtensionsCest
{
/**
* @param Admin $I
* @param BackendTester $I
*/
public function _before(Admin $I)
public function _before(BackendTester $I)
{
$I->useExistingSession();
$I->useExistingSession('admin');
$I->click('Extensions', '#menu');
$I->switchToContentFrame();
......@@ -41,27 +42,27 @@ class GetExtensionsCest
}
/**
* @param Admin $I
* @param BackendTester $I
*/
public function checkRetrievedExtensionsFromTerAreDisplayed(Admin $I)
public function checkRetrievedExtensionsFromTerAreDisplayed(BackendTester $I)
{
$I->see('superext');
$I->see('neededext');
}
/**
* @param Admin $I
* @param BackendTester $I