eliashaeussler / typo3-codeception-helper
Helper functions for Codeception tests within TYPO3 extensions
Installs: 70 509
Dependents: 6
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 1
Open Issues: 2
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0
- composer-runtime-api: ^2.1
- codeception/c3: ^2.8
- codeception/codeception: ^4.1.11 || ^5.0
- symfony/filesystem: ^5.4 || ^6.0 || ^7.0
Requires (Dev)
- armin/editorconfig-cli: ^1.8 || ^2.0
- codeception/module-webdriver: ^4.0
- eliashaeussler/php-cs-fixer-config: ^2.0
- eliashaeussler/phpstan-config: ^2.0
- eliashaeussler/rector-config: ^2.0
- ergebnis/composer-normalize: ^2.30
- phpstan/extension-installer: ^1.2
- phpstan/phpstan-phpunit: ^1.1
- phpunit/phpunit: ^10.2
- symfony/finder: ^5.4 || ^6.0 || ^7.0
This package is auto-updated.
Last update: 2024-11-19 04:36:19 UTC
README
TYPO3 Codeception Helper
This library provides some helper functions for Codeception tests within TYPO3 extensions. In addition, an application entrypoint modifier extension for coverage collection within acceptance tests is distributed.
π₯ Installation
composer require --dev eliashaeussler/typo3-codeception-helper
β‘ Usage
ApplicationEntrypointModifier
extension
A Codeception extension that aims to ease the integration effort
when collecting code coverage with codeception/c3
.
It replaces an existing entrypoint (e.g. typo3/index.php
) with
a modified entrypoint that includes the distributed c3.php
file.
Enable this extension in your codeception.yml
file:
# codeception.yml extensions: enabled: - EliasHaeussler\Typo3CodeceptionHelper\Codeception\Extension\ApplicationEntrypointModifier: entrypoints: - web-dir: .Build/web main-entrypoint: index.php app-entrypoint: app.php - web-dir: .Build/web/typo3 main-entrypoint: index.php app-entrypoint: app.php
For each entrypoint, the following config must be provided:
Example
Given the following directory structure:
.Build
βββ web
βββ index.php # main entrypoint provided by framework/application
Once the extension is enabled and properly configured, the following directory structure exists after the test suite is started:
.Build
βββ web
βββ app.php # contains the original contents from index.php
βββ index.php # generated entrypoint that includes c3.php and app.php
Backend
module
Source:
Codeception\Module\Backend
A Codeception module that allows to perform actions within TYPO3 backend. It can for example be used to log into the TYPO3 backend.
Note
This module requires the WebDriver
module to be installed and enabled.
Enable this module in your codeception.yml
file:
# codeception.yml suites: Acceptance: actor: AcceptanceTester modules: enabled: - EliasHaeussler\Typo3CodeceptionHelper\Codeception\Module\Backend
Available methods
login($username, $password): void
Perform backend login for the given user. The user is identified by the given username and is authenticated by the given password.
Example:
$I->login('admin', 'password');
loginAs($username): void
Perform backend login for the given user. The user is identified by the given username which must be configured in the codeception module config (see Configure backend users).
Example:
$I->loginAs('admin');
openModule($identifier): void
Open a backend module by clicking on the module link. The module link is identified by a given node identifier. Note that the identifier differs between TYPO3 versions (see example below).
Example:
// TYPO3 11 $I->openModule('#web_list'); // TYPO3 12 $I->openModule('[data-modulemenu-identifier="web_list"]');
Configure backend users
Note
Backend users are not automatically created by this module. You need to take care of that by your own, e.g. by importing static database fixtures before tests are executed.
In order to use the loginAs()
method, existing backend users
must be configured in the module config section:
suites: Acceptance: actor: AcceptanceTester modules: enabled: - - EliasHaeussler\Typo3CodeceptionHelper\Codeception\Module\Backend + - EliasHaeussler\Typo3CodeceptionHelper\Codeception\Module\Backend: + userCredentials: + admin: password + editor: password
π§βπ» Contributing
Please have a look at CONTRIBUTING.md
.
β License
This project is licensed under GNU General Public License 2.0 (or later).