TASK: Add acceptance tests with codeception

This commit is contained in:
Daniel Siepmann 2018-11-04 00:34:23 +01:00
parent 918e398ee1
commit cfa83dc865
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
12 changed files with 2320 additions and 27 deletions

10
codeception.yml Normal file
View file

@ -0,0 +1,10 @@
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed

View file

@ -30,7 +30,15 @@
"workshop/example-extension": "@dev" "workshop/example-extension": "@dev"
}, },
"require-dev": { "require-dev": {
"typo3/cms-lowlevel": "*" "typo3/cms-lowlevel": "*",
"codeception/codeception": "^2.5",
"typo3-console/php-server-command": "^0.2.0",
"typo3/testing-framework": "^4.11"
},
"autoload-dev": {
"psr-4": {
"Codappix\\Tests\\": "tests/Classes"
}
}, },
"extra": { "extra": {
"typo3/cms": { "typo3/cms": {

2115
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,61 @@
<?php
namespace Codappix\Tests\Acceptance;
/*
* Copyright (C) 2018 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.
*/
use Codeception\Event\TestEvent;
use Codeception\Event\SuiteEvent;
use Codeception\Events;
use PHPUnit\Framework\TestSuite;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\TestingFramework\Core\Acceptance\Extension\BackendEnvironment;
class Typo3Environment extends BackendEnvironment
{
public function _initialize()
{
ArrayUtility::mergeRecursiveWithOverrule($this->config, [
// 'typo3DatabaseDriver' => 'pdo_sqlite',
'typo3DatabaseDriver' => 'pdo_mysql',
'typo3DatabaseHost' => 'localhost',
'typo3DatabaseUsername' => 'testing',
'typo3DatabasePassword' => 'testing',
'typo3DatabaseName' => 'workshopgitlabtesting',
'typo3DatabasePort' => '3306',
'coreExtensionsToLoad' => [
'core',
'extbase',
'fluid',
'fluid_styled_content',
'frontend',
'backend',
],
'testExtensionsToLoad' => [
'typo3conf/ext/example_extension',
],
'xmlDatabaseFixtures' => [
dirname(__FILE__) . '/../../acceptance/fixtures/full.xml',
],
]);
parent::_initialize();
}
}

0
tests/_data/.gitkeep Normal file
View file

2
tests/_output/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

View file

@ -0,0 +1,26 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
}

View file

@ -0,0 +1,10 @@
<?php
namespace Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Acceptance extends \Codeception\Module
{
}

2
tests/_support/_generated/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

View file

@ -0,0 +1,18 @@
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.
actor: AcceptanceTester
modules:
enabled:
-
PhpBrowser:
url: http://127.0.0.1:8080
-
\Helper\Acceptance
extensions:
enabled:
- Codappix\Tests\Acceptance\Typo3Environment

View file

@ -0,0 +1,37 @@
<?php
class AddressCest
{
public function listsExistingRecords(AcceptanceTester $I)
{
$I->amOnPage('/plugin');
$I->see('Codappix GmbH');
}
public function canEditRecord(AcceptanceTester $I)
{
$I->amOnPage('/plugin');
$I->see('Edit');
$I->click('Edit');
$I->see('Editing: Codappix GmbH');
$I->fillField(['id' => 'companyName'], 'TYPO3 Camp Rhein Ruhr');
$I->click('Update');
$I->amOnPage('/plugin');
$I->see('TYPO3 Camp Rhein Ruhr');
}
public function zipValidatesAgainst5Digits(AcceptanceTester $I)
{
$I->amOnPage('/plugin');
$I->see('Edit');
$I->click('Edit');
$I->see('Editing: TYPO3 Camp Rhein Ruhr');
$I->fillField(['id' => 'zip'], '123');
$I->click('Update');
$I->see('Please provide a valid ZIP consisting of 5 digits.');
}
}

View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<dataset>
<pages>
<uid>1</uid>
<pid>0</pid>
<title>Plugin page</title>
<doktype>1</doktype>
<deleted>0</deleted>
<perms_everybody>15</perms_everybody>
<slug>/plugin</slug>
</pages>
<sys_template>
<uid>1</uid>
<pid>1</pid>
<title>Main TypoScript Rendering</title>
<sitetitle>New TYPO3 site</sitetitle>
<hidden>0</hidden>
<starttime>0</starttime>
<endtime>0</endtime>
<root>1</root>
<clear>1</clear>
<include_static_file>EXT:fluid_styled_content/Configuration/TypoScript/,EXT:fluid_styled_content/Configuration/TypoScript/Styling/</include_static_file>
<config><![CDATA[page = PAGE
page.100 =< styles.content.get
]]></config>
<nextLevel></nextLevel>
<basedOn></basedOn>
<deleted>0</deleted>
<includeStaticAfterBasedOn>0</includeStaticAfterBasedOn>
<static_file_mode>0</static_file_mode>
</sys_template>
<tt_content>
<uid>1</uid>
<pid>1</pid>
<hidden>0</hidden>
<sorting>256</sorting>
<CType>list</CType>
<colPos>0</colPos>
<pages>1</pages>
<list_type>exampleextension_address</list_type>
<header>Address Plugin</header>
</tt_content>
<tx_exampleextension_domain_model_address>
<uid>1</uid>
<pid>1</pid>
<company_name>Codappix GmbH</company_name>
<street>Hövelstraße</street>
<house_number>32</house_number>
<zip>41238</zip>
<city>Mönchengladbach</city>
<country>Deutschland</country>
</tx_exampleextension_domain_model_address>
</dataset>