eliashaeussler/typo3-codeception-helper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

eliashaeussler/typo3-codeception-helper

最新稳定版本:2.0.0

Composer 安装命令:

composer require eliashaeussler/typo3-codeception-helper

包简介

Helper functions for Codeception tests within TYPO3 extensions

README 文档

README

TYPO3 Codeception Helper

Coverage CGL Tests Supported PHP Versions

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

Packagist Packagist Downloads

composer require --dev eliashaeussler/typo3-codeception-helper

⚡ Usage

ApplicationEntrypointModifier extension

Source: Codeception\Extension\ApplicationEntrypointModifier

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
            optional: true

For each entrypoint, the following config must be provided:

Config name Description Default value
web-dir Relative path from project root to directory that contains the main entrypoint
main-entrypoint Name of the entrypoint to replace (the file being accessed by the web server) index.php
app-entrypoint Name of the original relocated entrypoint (the renamed main entrypoint) app.php
optional Set to true if a non-existent main entrypoint can be ignored false

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

scrollToElementInModule($identifier, $offsetX = 0, $offsetY = 0): void

Scroll to a given element, identified by the given node identifier, inside the current backend module. This circumvents issues with Codeception's native WebDriver::scrollTo() method which does not support scrolling inside frames.

Example:

$I->openModule('[data-modulemenu-identifier="web_list"]');
$I->scrollToElementInModule('tr[data-table="tt_content"]');

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

统计信息

  • 总下载量: 148.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 1
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2023-07-05