PHPackages                             guncha25/drupal-codeception - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. guncha25/drupal-codeception

ActivePackage[Testing &amp; Quality](/categories/testing)

guncha25/drupal-codeception
===========================

Codeception toolset for Drupal testing.

10.0.3(2y ago)17131.1k—5.3%20[2 PRs](https://github.com/guncha25/drupal-codeception/pulls)2GPL-2.0PHP

Since Sep 24Pushed 2y ago3 watchersCompare

[ Source](https://github.com/guncha25/drupal-codeception)[ Packagist](https://packagist.org/packages/guncha25/drupal-codeception)[ RSS](/packages/guncha25-drupal-codeception/feed)WikiDiscussions 10.x Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (31)Used By (2)

Drupal Codeception
==================

[](#drupal-codeception)

Overview
--------

[](#overview)

Sets of codeception modules and utilities to test drupal cms. Includes:

- Drupal Bootstrap
- Drupal Entity
- Drupal User
- Drupal Watchdog
- Drupal Drush
- Drupal Acceptance

Installation
------------

[](#installation)

Require package:

`composer require guncha25/drupal-codeception --dev`

If codeception was not previously set up:

`./vendor/bin/codecept bootstrap`

If you require only one suite for now (e.g. acceptance):

`./vendor/bin/codecept init acceptance`

Drupal Bootstrap
----------------

[](#drupal-bootstrap)

Provides full bootstrapping in to Drupal before test. Allows using drupal API in test cases.

### Configuration

[](#configuration)

- server: Server and execution environment information.
- root: Drupal root. Uses DrupalFinder to detect the Drupal root. Falls back to codeception root + `/web`. (optional)

```
modules:
    - DrupalBootstrap:
        server:
            SERVER_PORT: null
            REQUEST_URI: '/'
            REMOTE_ADDR: '127.0.0.1'
            HTTP_HOST: 'site.multi'

```

Drupal Drush
------------

[](#drupal-drush)

Provides drush (`runDrush`) command.

### Configuration

[](#configuration-1)

- working\_directory: Working directory where drush should be executed. Defaults to codeception root.
- timeout: Timeout in seconds for drush command. Set to 0 for no timeout. Default to 60 seconds.
- drush: Drush executable. Defaults to `drush`.

```
modules:
    - DrupalDrush:
        working_directory: './web'
        timeout: 120
        drush: './vendor/bin/drush'
          options:
            uri: http://mydomain.com
            root: /app/web

```

### Usage

[](#usage)

Run drush status and store output.

`$output = $i->runDrush('status');`

Run drush config import and store output from STDERR.

`$output = $i->runDrush('cim -y', [], TRUE)->getErrorOutput();`

Run drush cache rebuild and store the exit code.

`$exit_code = $i->runDrush('cr', [], TRUE)->getExitCode();`

Get one-time login url.

`$uri = $i->getLoginUri('userName');`

Drupal Entity
-------------

[](#drupal-entity)

Provides better interaction with drupal entities and test entity cleanup service.

### Configuration

[](#configuration-2)

- cleanup\_test: Indicator if test entities should be deleted after each test.
- cleanup\_failed: Indicator if test entities should be deleted after test fails.
- cleanup\_suite: Indicator if test entities should be deleted after suite.
- route\_entities: Entity list that can be retrieved by url.

```
modules:
    - DrupalEntity:
        cleanup_test: true
        cleanup_failed: false
        cleanup_suite: true
        route_entities:
            - node
            - taxonomy_term

```

### Usage

[](#usage-1)

Create entities.

`$node = $i->createEntity(['title => 'My node', 'type' => 'page']);`

`$term = $i->createEntity(['name => 'My term', 'vid' => 'tag'], 'taxonomy_term');`

Delete all stored test entities.

`$i->doEntityCleanup();`

Register test entity.

`$i->registerTestEntity('node', '99');`

Register test entity by url.

`$i->registerTestEntityByUrl($i->grabFromCurrentUrl());`

Get entity by url.

`$entity = $i->getEntityFromUrl($i->grabFromCurrentUrl());`

Drupal User
-----------

[](#drupal-user)

Provides better interaction with drupal user and test user setup and cleanup service.

### Configuration

[](#configuration-3)

- default\_role: Default user role if no specified. Defaults to 'authenticated'
- driver: Driver used for interacting with site. Defaults to WebDriver.
- drush: Drush executable. Defaults to `drush`.
- cleanup\_entities: Entities to delete when test user gets deleted.
- cleanup\_test: Indicator if test entities should be deleted after each test.
- cleanup\_failed: Indicator if test entities should be deleted after test fails.
- cleanup\_suite: Indicator if test entities should be deleted after suite.

```
modules:
    - DrupalUser:
        default_role: 'authenticated'
        driver: 'PhpBrowser'
        drush: './vendor/bin/drush'
        cleanup_entities:
            - media
            - file
        cleanup_test: true
        cleanup_failed: false
        cleanup_suite: true

```

### Usage

[](#usage-2)

Create test user with specified roles.

`$user = $i->createUserWithRoles(['editor', 'authenticated'], 'password');`

Log in user by username.

`$i->loginAs('userName');`

Create new user with certain role and login.

`$i->logInWithRole('administrator');`

Drupal Watchdog
---------------

[](#drupal-watchdog)

Provides log checking while testing.

### Configuration

[](#configuration-4)

- enabled: Wheather automatic check is enabled after suite. Defaults to `TRUE`
- level: Global log level that would produce fail. Defaults to 'ERROR'.
- channels: Individual log channel settings.

```
modules:
    - DrupalWatchdog:
        enabled: true
        level: 'ERROR'
        channels:
            my_module: 'NOTICE'
            php: 'WARNING'

```

### Usage

[](#usage-3)

Clean logs.

`$i->prepareLogWatch();`

Check logs.

`$i->checkLogs();`

Drupal Acceptance
-----------------

[](#drupal-acceptance)

Provides helper methods to interact with drupal via webdriver.

```
modules:
    - DrupalAcceptance:

```

### Usage

[](#usage-4)

```
// Fill title.
$i->fillTextField(FormField::title(), 'Mans nosukums');

// Select option from select list by key or value.
// For custom fields, target (last parameter) usually needs to be set to an
// empty string.
$i->selectOptionFromList(FormField::langcode(), 'en');
$i->selectOptionFromList(FormField::langcode(), 'English');
$i->selectOptionFromList(FormField::field_my_list(), 'Apple', '');

// Select the nth option from a select list.
$i->selectOptionFromList(FormField::langcode());
$i->selectNthOptionFromList(MTOFormField::field_my_list(), 2, '');

// Fill first paragraph of type text.
$page_elements = ParagraphFormField::field_page_elements();
$i->fillWysiwygEditor(FormField::field_text_formatted($page_elements), 'Lorem');

// Remove text paragraph.
$i->removeParagraph($page_elements);

// Add second paragraph of type graybox.
$i->addParagraph('graybox', $page_elements->next());

// Fill title of graybox.
$i->fillTextField(FormField::field_title($page_elements), 'Mans nosukums');

// Fill link field.
$i->fillLinkField(FormField::field_link($page_elements), 'http://example.com', 'Example');
$i->fillLinkField(FormField::field_link($page_elements), 'http://example.com');

// Add taxonomy term reference for tags field.
$field_tags = FormField::field_tags();
$i->fillReferenceField(FormField::field_tags(), Fixtures::get('term1'));
$i->addReferenceFieldItem($field_tags->next());
$i->fillReferenceField($field_tags, Fixtures::get('term2'));

$i->clickOn(FormField::submit());

```

Drupal Fields Utility
---------------------

[](#drupal-fields-utility)

Provides xpath builder object for drupal specific form field xpath retrieval.

Includes: - FormField: Fields that can be set to cardinality unlimited - MTOFormField: Single value fields. - ParagraphFormField: Paragraph form fields.

### Usage

[](#usage-5)

Create paragraph field with machine name field\_page\_elements.

`$page_elements = ParagraphFormField::field_page_elements();`

Get next paragraph.

`$page_elements->next();`

Fill title field value from field page elements.

`$i->fillField(FormField::title($page_elements)->value);`

Add new paragraph of type liftup\_element.

```
$i->click($page_elements->addMore('liftup_element'));
$i->waitForElementVisible($page_elements->getCurrent('Subform'));

```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 81.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~68 days

Recently: every ~37 days

Total

30

Last Release

802d ago

Major Versions

8.0.16 → 9.0.02020-09-17

9.x-dev → 10.0.22023-10-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0df2ca5e4a923ccf57390609f7e33071692d18b1aa039971b7da34fdfcf0264?d=identicon)[guncha25](/maintainers/guncha25)

---

Top Contributors

[![guncha25](https://avatars.githubusercontent.com/u/10857118?v=4)](https://github.com/guncha25 "guncha25 (61 commits)")[![Rade333](https://avatars.githubusercontent.com/u/922901?v=4)](https://github.com/Rade333 "Rade333 (6 commits)")[![minorOffense](https://avatars.githubusercontent.com/u/871728?v=4)](https://github.com/minorOffense "minorOffense (2 commits)")[![mgalang](https://avatars.githubusercontent.com/u/209939?v=4)](https://github.com/mgalang "mgalang (2 commits)")[![Juhani-moilanen](https://avatars.githubusercontent.com/u/107038594?v=4)](https://github.com/Juhani-moilanen "Juhani-moilanen (2 commits)")[![jaapjan](https://avatars.githubusercontent.com/u/2848293?v=4)](https://github.com/jaapjan "jaapjan (1 commits)")[![ragnarkurmwunder](https://avatars.githubusercontent.com/u/28702260?v=4)](https://github.com/ragnarkurmwunder "ragnarkurmwunder (1 commits)")

### Embed Badge

![Health badge](/badges/guncha25-drupal-codeception/health.svg)

```
[![Health](https://phpackages.com/badges/guncha25-drupal-codeception/health.svg)](https://phpackages.com/packages/guncha25-drupal-codeception)
```

###  Alternatives

[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15511.5M30](/packages/magento-magento2-functional-testing-framework)[lucatume/wp-browser

A set of Codeception modules to test WordPress projects.

6343.8M153](/packages/lucatume-wp-browser)[orchestra/workbench

Workbench Companion for Laravel Packages Development

8217.0M43](/packages/orchestra-workbench)[oxid-esales/testing-library

OXID eShop testing library

13374.0k10](/packages/oxid-esales-testing-library)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
