portrino/codeception-helper-module

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (0.5.0) of this package.

Generic helper module for codeception acceptance testing

0.5.0 2018-12-01 19:52 UTC

This package is auto-updated.

Last update: 2024-02-05 19:42:50 UTC


README

Build Status MaintainabilityMaintainability Test Coverage Test Coverage Issue Count Latest Stable Version Total Downloads

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.

Installation

You need to add the repository into your composer.json file

composer require --dev portrino/codeception-helper-module

Modules

You can use module(s) as any other codeception module, by adding '\Codeception\Module\Portrino******' to the enabled modules in your codeception suite configurations.

Database module

modules:
    enabled:
        - \Portrino\Codeception\Module\Database:
            depends: Db
            no_reset: true # do not reset database after testsuite

Update codeception build

codecept build

Methods

truncateTableInDatabase($table)

Truncates the $table.

  $I->truncateTableInDatabase($table);

deleteFromDatabase($table, $criteria)

Deletes the row(s) from $table matching the $criteria

$I->deleteFromDatabase($table, $criteria);

TYPO3 module

modules:
    enabled:
        - \Portrino\Codeception\Module\Typo3:
            depends: Asserts
            domain: www.example.com

Update codeception build

codecept build

Methods

executeCommand

Executes the specified typo3_console $command.

$I->executeCommand($command, $arguments = [], $environmentVariables = [])

executeSchedulerTask

Executes tasks that are registered in the scheduler module.

$I->executeSchedulerTask($taskId, $force = false, $environmentVariables = [])

flushCache

Flushes TYPO3 core caches first and after that, flushes caches from extensions.

$I->flushCache($force = false, $filesOnly = false)

flushCacheGroups

Flushes all caches in specified groups. Valid group names are by default:

  • all
  • lowlevel
  • pages
  • system
$I->flushCacheGroups($groups)

importIntoDatabase

Import $file into database.

$I->importIntoDatabase($file)

Shopware module

modules:
    enabled:
        - \Portrino\Codeception\Module\Shopware:
            depends: Asserts
            bin-dir: 

Update codeception build

codecept build

Methods

executeCommand

Executes the specified shopware_console $command.

$I->executeCommand($command, $arguments = [], $environmentVariables = []);

runSqlCommand

Executes SQL query in shopware_console.

$I->runSqlCommand($sql);

activatePlugin

Activates Shopware plugin.

$I->activatePlugin($plugin);

installPlugin

Install Shopware plugin. If activate = true, the plugin will be activated after installation.

$I->installPlugin($plugin, $activate);

refreshPluginList

Refresh Shopware plugin-list. You need to call this sometimes before installing a plugin.

$I->refreshPluginList();

regenerateThemeCache

Regenerates the theme-cache.

$I->regenerateThemeCache();

clearCache

Clear Shopware cache.

$I->clearCache();

setPluginConfiguration

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);

Interfaces

You should use our constants defined in some interfaces to prevent typos and make refactoring easier.

TYPO3

  • \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,
        ]
  );

Shopware

  • \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,
        ]
  );

Fixtures Helper

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');

Hints

Use codeception with shopware

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.

Autoloading

To autoload vendor packages you have to require_once the autoload.php in your composers _bootstrap.php file.

require_once(__DIR__ . '/../../../../web/autoload.php');

Authors

  • 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.