PHPackages                             thunder/drupal-testing - 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. thunder/drupal-testing

ActiveLibrary

thunder/drupal-testing
======================

Scripts for testing drupal projects.

2.0.3(4mo ago)571.3k—6.7%1[5 PRs](https://github.com/thunder/drupal-testing/pulls)GPL-2.0-or-laterShellPHP &gt;=7.2

Since Feb 3Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/thunder/drupal-testing)[ Packagist](https://packagist.org/packages/thunder/drupal-testing)[ RSS](/packages/thunder-drupal-testing/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (71)Used By (0)

Test Drupal projects
====================

[](#test-drupal-projects)

[![Build Status](https://camo.githubusercontent.com/33b6015a91060013981150c73098109932bc19dd3cb7be953c6612d3936c967d/68747470733a2f2f7472617669732d63692e636f6d2f7468756e6465722f64727570616c2d74657374696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/thunder/drupal-testing)

Versions
========

[](#versions)

[![Latest Stable Version](https://camo.githubusercontent.com/664dadd53b898dd5d5832a5f5425d7910cc05855ef9eb385de4c8941648d3ddf/68747470733a2f2f706f7365722e707567782e6f72672f7468756e6465722f64727570616c2d74657374696e672f762f737461626c65)](https://packagist.org/packages/thunder/drupal-testing)[![Latest Unstable Version](https://camo.githubusercontent.com/c9f3ad2dfd9586c4eaa4a0c267f3d018cd47f24096cfd4da1a393cea1333b0e7/68747470733a2f2f706f7365722e707567782e6f72672f7468756e6465722f64727570616c2d74657374696e672f762f756e737461626c65)](https://packagist.org/packages/thunder/drupal-testing)

About
=====

[](#about)

Use this package to simplify your drupal project testing. This will run all your standard drupal test and additionally check your source code for drupal coding style guidelines. It can be used to locally run those tests, or on CI platforms like travis or in github actions.

Prerequisites
=============

[](#prerequisites)

To get the most out of this package you should consider to add a few things to your module

Add your module name to the @group annotation of your test classes.
-------------------------------------------------------------------

[](#add-your-module-name-to-the-group-annotation-of-your-test-classes)

If your module is called "my\_module" add the following annotation to your test classes:

```
/**
 * Tests for my_module.
 *
 * @group my_module
 */
class MyModuleTest extends ...

```

Add a composer.json to your module.
-----------------------------------

[](#add-a-composerjson-to-your-module)

We use that file to automate different things. We parse the module name from it and we will automatically download required drupal modules before running the tests.

A composer.json could look like the following:

```
{
    "name": "drupal/my_module",
    "description": "The description of my_module",
    "type": "drupal-module",
    "license": "GPL-2.0-or-later",
    "require": {
        "drupal/another_module": "^2.0"
    }
}

```

Do not use deprecated TestBase classes
--------------------------------------

[](#do-not-use-deprecated-testbase-classes)

Only not deprecated (as of drupal 8.6) TestBase classes are tested. Especially the deprecated JavascriptTestBase is not supported, please use WebDriverTestBase instead. See [JavascriptTestBase is deprecated in favor of WebDriverTestBase](https://www.drupal.org/node/2945059)

Setup
=====

[](#setup)

Make sure, that you have bash 4 installed or greater. On most systems this will be the case. But on MacOS you need to update the build-in bash with homebrew.

Other requirements:

```
- [jq](https://stedolan.github.io/jq/)
- PHP > 7.2 + extensions needed by Drupal + sqlite extension, if no other database is used.
- [composer](https://getcomposer.org/)
- [node + npm](https://nodejs.org/en/)

```

For using drupal-testing on travis all you need to do is to copy the [.travis.yaml.dist](https://github.com/thunder/drupal-testing/blob/master/.travis.yml.dist)to your project root folder and rename it to .travis.yaml. If your module meets all the prerequisites, you should be done. Otherwise you might need to provide some environment variables. See below for possible configurations.

Differences to LionsAd/drupal\_ti
=================================

[](#differences-to-lionsaddrupal_ti)

While the general approach is very similar to drupal\_ti, we differ in some regards.

- If you want to run deprecated TestBase classes, or if you want to run behat tests, use drupal\_ti.
- When using WebDriverTestBase and Drupal &gt; 8.6 (which needs selenium instead of phantom.js) use this package.
- If you want a simple travis.yml file, that works without any configuration, use this package.
- You can directly use this for quickly running the tests locally and on other CI environments as well! Just do `composer global require thunder/drupal-testing` add the global composer directory to your $PATH and call `test-drupal-project` from within your modules directory. Everything will be build, installed and tested automatically.

Configuration
=============

[](#configuration)

We try to run without configuration as much as possible. But we still have a lot of configuration options, if your module requires some special treatment, or if your testing environment is not travis/github (or they changed some default values).

Steps
-----

[](#steps)

The simplest way to run the tests is to just call `test_drupal_project` in your .travis.yml. This will do everything, but it is actually divided into several steps which can be called separately by providing the step as a parameter: `test_drupal_project build` would call the build step and any steps that the build step depends on. Steps, that have already been executed will not be called again on subsequent call. So, if you call `test_drupal_project start_services` next, all steps up to the build step will not be executed.

The steps are the following:

### requirements

[](#requirements)

Check if testing requirements are met.

### coding\_style

[](#coding_style)

Tests php and javascript coding styles

### prepare\_build

[](#prepare_build)

Creates a drupal project and modifies the composer.json to contain the required modules.

### build

[](#build)

Builds the drupal installation with drupal project, adds all dependencies from the module and calls composer install.

### install

[](#install)

Installs drupal with the minimal profile or the one that has been configured.

### start\_services

[](#start_services)

Starts services required for testing. Starts web server and selenium.

### run\_tests

[](#run_tests)

Runs the tests

This is also the order of the step dependencies, coding\_style depends on prepare, build depends on coding\_style and prepare, and so on.

A very common use case for splitting the execution into steps is to stop after the build step, and add custom build operations (e.g. downloading dependencies, that cannot be installed by composer) and then continue later. An example for such a custom .travis.yml would be:

```
language: php
sudo: required

cache:
  apt: true
  directories:
  - "$HOME/.composer/cache"
  - "$HOME/.drush/cache"
  - "$HOME/.npm"

php:
  - 7.2

branches:
  only:
    - /^8\.([0-9]+|x)\-[0-9]+\.([0-9]+|x)$/

env:
  global:
    - PATH="$PATH:$HOME/.composer/vendor/bin"

before_install:
  - composer global require thunder/drupal-testing

install:
  - test-drupal-project build
  # Download something to the ccurrent directory.
  - wget -qO- https://www.some-domain.com/some-needed-dependency.tar.gz | tar xvz

script:
  # this continues after the build step and finishes testing.
  - test-drupal-project

```

Environment variables
=====================

[](#environment-variables)

You can configure your tests with several environment variables, most of them are only needed, if you want to run the tests in different environments then travis. You can change database credentials, server hosts and ports, some installation paths and the test setup. All those variables should work out of the box when running on travis with a module, that has a correct composer.json and the test group set to the module name (see prerequisites for more information). Variables can be set in the env section of the .travis.yml.

Available variables
-------------------

[](#available-variables)

Find all defined variables in [configuration.sh](https://github.com/thunder/drupal-testing/blob/master/configuration.sh)

Some interesting variables are:

- DRUPAL\_TESTING\_PROJECT\_BASEDIR

The directory, where the project is located. On travis this is set to TRAVIS\_BUILD\_DIR otherwise defaults to the current directory.

- DRUPAL\_TESTING\_COMPOSER\_NAME

The composer name of the current project, if not specified, it will be read from the composer.json.

- DRUPAL\_TESTING\_PROJECT\_NAME

The project name, if not provided, the second part of the composer name will be use. E.g. If the composer name is vendor/myproject the project name will be myproject. This will be used as default test group.

- DRUPAL\_TESTING\_TEST\_GROUP

The phpunit test group, defaults to the value of ${DRUPAL\_TESTING\_PROJECT\_NAME}. To provide multiple groups, concatenate them with comma: DRUPAL\_TESTING\_TEST\_GROUP="mygroup1,mygroup2"

- DRUPAL\_TESTING\_TEST\_GROUP\_EXCLUDE

The phpunit test groups to exclude, defaults an empty string. To provide multiple groups, concatenate them with comma: DRUPAL\_TESTING\_TEST\_GROUP\_EXCLUDE="mygroup1,mygroup2"

- DRUPAL\_TESTING\_TEST\_FILTER

Only runs tests whose name matches the given regular expression pattern. Example: DRUPAL\_TESTING\_TEST\_FILTER=TestCaseClass::testMethod

- DRUPAL\_TESTING\_TEST\_CODING\_STYLES

Boolean value if coding styles should be tested with burdamagazinorg/thunder-dev-tools. By default coding styles are tested.

- DRUPAL\_TESTING\_TEST\_JAVASCRIPT
- DRUPAL\_TESTING\_TEST\_PHP

Boolean values if javascript and php coding styles should be tested. By default all coding styles are tested.

- DRUPAL\_TESTING\_TEST\_BASE\_DIRECTORY

The base directory for all generated files. Drupal will be installed into this directory. This directory and its contents get removed after a successful tests.

- DRUPAL\_TESTING\_DRUPAL\_INSTALLATION\_DIRECTORY

The directory, where drupal will be installed, defaults to ${DRUPAL\_TESTING\_TEST\_BASE\_DIRECTORY}/install This directory gets removed after successful tests.

- DRUPAL\_TESTING\_HTTP\_HOST
- DRUPAL\_TESTING\_HTTP\_PORT

The web server host and port. Defaults to 127.0.0.1 and 8888

- DRUPAL\_TESTING\_SELENIUM\_CHROME\_VERSION

The selenium chrome docker version to use. defaults to the latest version.

- DRUPAL\_TESTING\_SELENIUM\_HOST
- DRUPAL\_TESTING\_SELENIUM\_PORT

The selenium host and port. Defaults to the web server host and port 4444.

- DRUPAL\_TESTING\_DATABASE\_HOST
- DRUPAL\_TESTING\_DATABASE\_PORT
- DRUPAL\_TESTING\_DATABASE\_USER
- DRUPAL\_TESTING\_DATABASE\_PASSWORD
- DRUPAL\_TESTING\_DATABASE\_NAME

The database information. Defaults to the web server host, port 3306, user testing and empty password. The database name is set to testing. If you run your tests locally, you might want to change these to your local mysql installation.

- DRUPAL\_TESTING\_CLEANUP

By default all created files are deleted after successful test runs, you can disable this behaviour by setting this to false.

- SYMFONY\_DEPRECATIONS\_HELPER

The symfony environment variable to ignore deprecations, for possible values see [PHPUnit Bridge documentation](https://symfony.com/doc/3.4/components/phpunit_bridge.html). The default value is "week" to ignore any deprecation notices.

- MINK\_DRIVER\_ARGS\_WEBDRIVER

The driver args for webdriver. You might change this, when running your own chromedriver / selenium instance.

Example .travis.yml with some variables set:

```
language: php
dist: xenial

php:
  - 7.2

services:
  - mysql

cache:
  apt: true
  directories:
  - "$HOME/.composer/cache"
  - "$HOME/.drush/cache"
  - "$HOME/.npm"

branches:
  only:
    - /^8\.([0-9]+|x)\-[0-9]+\.([0-9]+|x)$/

env:
  matrix:
    # Add a test matrix where tests are running once with deprecations failing and once without.
    # The test with deprecation warnings is allowed to fail.
    - SYMFONY_DEPRECATIONS_HELPER=weak
    - SYMFONY_DEPRECATIONS_HELPER=0
  global:
    - PATH="$PATH:$HOME/.composer/vendor/bin"

matrix:
  allow_failures:
    - env: SYMFONY_DEPRECATIONS_HELPER=0

before_install:
  - composer global require thunder/drupal-testing

script:
  - test-drupal-project

```

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance76

Regular maintenance activity

Popularity34

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 64.2% 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 ~42 days

Total

52

Last Release

130d ago

Major Versions

1.0.47 → 2.0.02025-07-16

### Community

Maintainers

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

---

Top Contributors

[![dbosen](https://avatars.githubusercontent.com/u/6398151?v=4)](https://github.com/dbosen "dbosen (86 commits)")[![chrfritsch](https://avatars.githubusercontent.com/u/731161?v=4)](https://github.com/chrfritsch "chrfritsch (42 commits)")[![alexpott](https://avatars.githubusercontent.com/u/769634?v=4)](https://github.com/alexpott "alexpott (4 commits)")[![IT-Cru](https://avatars.githubusercontent.com/u/10243292?v=4)](https://github.com/IT-Cru "IT-Cru (1 commits)")[![ol0lll](https://avatars.githubusercontent.com/u/5558666?v=4)](https://github.com/ol0lll "ol0lll (1 commits)")

### Embed Badge

![Health badge](/badges/thunder-drupal-testing/health.svg)

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

###  Alternatives

[getkirby/cms

The Kirby core

1.5k535.5k352](/packages/getkirby-cms)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)

PHPackages © 2026

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