Collection of modules for codeception acceptance testing with TYPO3 and Shopware. You can use this module as base for your codeception acceptance testsuite. It provides a set of modules, abstract page objects and interfaces to make acceptance testing a bit cleaner and easier in context of TYPO3 and Shopware.
You need to add the repository into your composer.json file
composer require --dev portrino/codeception-helper-moduleYou can use module(s) as any other codeception module, by adding '\Codeception\Module\Portrino******' to the enabled modules in your codeception suite configurations.
modules:
enabled:
- \Portrino\Codeception\Module\Database:
depends: Db
no_reset: true # do not reset database after testsuiteUpdate codeception build
codecept buildTruncates the $table.
$I->truncateTableInDatabase($table);Deletes the row(s) from $table matching the $criteria
$I->deleteFromDatabase($table, $criteria);modules:
enabled:
- \Portrino\Codeception\Module\Typo3:
depends: Asserts
domain: www.example.comUpdate codeception build
codecept buildExecutes the specified typo3_console $command.
$I->executeCommand($command, $arguments = [], $environmentVariables = [])Executes tasks that are registered in the scheduler module.
$I->executeSchedulerTask($taskId, $force = false, $environmentVariables = [])Flushes TYPO3 core caches first and after that, flushes caches from extensions.
$I->flushCache($force = false, $filesOnly = false)Flushes all caches in specified groups. Valid group names are by default:
- all
- lowlevel
- pages
- system
$I->flushCacheGroups($groups)Import $file into database.
$I->importIntoDatabase($file)modules:
enabled:
- \Portrino\Codeception\Module\Shopware:
depends: Asserts
bin-dir: Update codeception build
codecept buildExecutes the specified shopware_console $command.
$I->executeCommand($command, $arguments = [], $environmentVariables = []);Executes SQL query in shopware_console.
$I->runSqlCommand($sql);Activates Shopware plugin.
$I->activatePlugin($plugin);Install Shopware plugin. If activate = true, the plugin will be activated after installation.
$I->installPlugin($plugin, $activate);Refresh Shopware plugin-list. You need to call this sometimes before installing a plugin.
$I->refreshPluginList();Regenerates the theme-cache.
$I->regenerateThemeCache();Clear Shopware cache.
$I->clearCache();Set configuration of Shopware plugin by plugin-name, configuration-key and configuration-value.
- you'll be able to set cofigurations for a specified shop by using the $shop parameter
$I->setPluginConfiguration($plugin, $key, $value, $shop = 1);You should use our constants defined in some interfaces to prevent typos and make refactoring easier.
\Portrino\Codeception\Interfaces\DatabaseTables\Typo3Database\Portrino\Codeception\Interfaces\Cookies\Typo3Cookie\Portrino\Codeception\Interfaces\Commands\Typo3Command
Example:
$I->seeInDatabase(
\Portrino\Codeception\Interfaces\DatabaseTables\Typo3::PAGES,
[
'uid' => 123,
]
);\Portrino\Codeception\Interfaces\DatabaseTables\ShopwareDatabase\Portrino\Codeception\Interfaces\Cookies\ShopwareCookie\Portrino\Codeception\Interfaces\Commands\ShopwareCommand
$I->seeInDatabase(
\Portrino\Codeception\Interfaces\DatabaseTables\Shopware::ARTICLE,
[
'id' => 123,
]
);For the sake of simplicity we added an little Helper for the Codeception Fixture feature.
Please add in your _bootstrap.php file
'__model' => \Portrino\Codeception\Model\Typo3\Typo3FrontendUser::class,
as the first entry in your Fixture array. your Fixture has to look like
\Codeception\Util\Fixtures::add(
'your_fixture_name',
[
'__model' => \Portrino\Codeception\Model\Typo3\Typo3FrontendUser::class,
'fixtureValueX' => 'X',
'fixtureValueY' => 'Y'
]
);now you'll be able to use your Fixture with our adapted Fixtures class
\Portrino\Codeception\Util\Fixtures::get('your_fixture_name');Due the fact that shopware only supports some very old versions of packages like guzzlehttp/guzzle or symfony/process,
we advise you to put all the testing stuff into a indepented composer.json file under a seperate location like web/tests/Codeception/. Do not add codeception\codeception package into the root composer.json of shopware - you will get trouble.
To autoload vendor packages you have to require_once the autoload.php in your composers _bootstrap.php file.
require_once(__DIR__ . '/../../../../web/autoload.php');- André Wuttig - Initial work, Unit Tests - aWuttig
- Leopold Engst - Unit Tests, Documentation - leen2104
- Axel Böswetter - Bugfixes - EvilBMP
See also the list of contributors who participated in this project.