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

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

thunder/travis
==============

Travis scripts for testing drupal modules.

1.0.21(6y ago)09.1k3[3 issues](https://github.com/thunder/travis/issues)[2 PRs](https://github.com/thunder/travis/pulls)GPL-2.0-or-laterShellPHP &gt;=7.0CI failing

Since Jul 20Pushed 5y ago3 watchersCompare

[ Source](https://github.com/thunder/travis)[ Packagist](https://packagist.org/packages/thunder/travis)[ RSS](/packages/thunder-travis/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (3)Versions (33)Used By (0)

Test Drupal projects with travis
================================

[](#test-drupal-projects-with-travis)

[![Build Status](https://camo.githubusercontent.com/ad494ca765e51364cd839b594496fb04dfb9bee7b0be70627175591d915cfd6c/68747470733a2f2f7472617669732d63692e636f6d2f7468756e6465722f7472617669732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/thunder/travis)

Versions
========

[](#versions)

[![Latest Stable Version](https://camo.githubusercontent.com/f39cea236402bdd1e65de16b2d1103445cdbbb167b97a2fe8f9c28faba1a6353/68747470733a2f2f706f7365722e707567782e6f72672f7468756e6465722f7472617669732f762f737461626c65)](https://packagist.org/packages/thunder/travis)[![Latest Unstable Version](https://camo.githubusercontent.com/df2c274d263aa18707a83e8109a455f64236cdad8f293860b78e4ca0fd2b32e4/68747470733a2f2f706f7365722e707567782e6f72672f7468756e6465722f7472617669732f762f756e737461626c65)](https://packagist.org/packages/thunder/travis)

About
=====

[](#about)

Use this package to simplify your drupal module testing on travis. This will run all your standard drupal test on travis and additionally check your source code for drupal coding style guidelines.

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)

All you need to do is to copy the [.travis.yaml.dist](https://github.com/thunder/travis/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 as well! All you need is php command line client, composer, chromedriver and docker (or mysql running natively). If you have all this installed on your local machine, just do `composer global require thunder/travis` 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 (or travis changed some default values) or if you want to split up the testing process into multiple steps.

Steps
-----

[](#steps)

The simplest way to run the tests is to just call `test_drupal_module` 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_module 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_module start_web_server` next, all steps up to the build step will not be executed.

The steps are the following:

### setup

[](#setup-1)

Setup the testing environment. Starts selenium and mysql if necessary and tweaks php on travis

### 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, as required by simpletest module. Enables simpletest module

### start\_web\_server

[](#start_web_server)

Starts a webserver pointing to the installed drupal.

### 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 the 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/travis

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 informations). 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/travis/blob/master/configuration.sh)

Some interesting variables are:

- DRUPAL\_TRAVIS\_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\_TRAVIS\_COMPOSER\_NAME

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

- DRUPAL\_TRAVIS\_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\_TRAVIS\_TEST\_GROUP

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

- DRUPAL\_TRAVIS\_TEST\_FILTER

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

- DRUPAL\_TRAVIS\_TEST\_CODING\_STYLES

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

- DRUPAL\_TRAVIS\_TEST\_JAVASCRIPT
- DRUPAL\_TRAVIS\_TEST\_PHP

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

- DRUPAL\_TRAVIS\_TEST\_BASE\_DIRECTORY

The base directory for all generated files. Into this diretory will be drupal installed and temp files stored. This directory gets removed after successful tests.

- DRUPAL\_TRAVIS\_DRUPAL\_INSTALLATION\_DIRECTORY

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

- DRUPAL\_TRAVIS\_HTTP\_HOST
- DRUPAL\_TRAVIS\_HTTP\_PORT

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

- DRUPAL\_TRAVIS\_SELENIUM\_CHROME\_VERSION

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

- DRUPAL\_TRAVIS\_SELENIUM\_HOST
- DRUPAL\_TRAVIS\_SELENIUM\_PORT

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

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

The database information. Defaults to the web server host, port 3306, user travis and empty password. This is the default configuration for the travis php environment. The database name is set to drupaltesting. If you run your tests locally, you might want to change these to your local mysql installation.

- DRUPAL\_TRAVIS\_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 chnage this, when rennung 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/travis

script:
  - test-drupal-project

```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 93.5% 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 ~18 days

Total

31

Last Release

2339d ago

### 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 (58 commits)")[![alexpott](https://avatars.githubusercontent.com/u/769634?v=4)](https://github.com/alexpott "alexpott (2 commits)")[![chrfritsch](https://avatars.githubusercontent.com/u/731161?v=4)](https://github.com/chrfritsch "chrfritsch (2 commits)")

---

Tags

drupalmoduletestingtravis

### Embed Badge

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

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

###  Alternatives

[slevomat/coding-standard

Slevomat Coding Standard for PHP\_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.

1.5k134.0M2.1k](/packages/slevomat-coding-standard)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k100.2M2.2k](/packages/behat-behat)[phpro/grumphp

A composer plugin that enables source code quality checks.

4.3k16.3M983](/packages/phpro-grumphp)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k42.5M39.3k](/packages/orchestra-testbench)[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.6M324](/packages/drupal-core-dev)

PHPackages © 2026

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