PHPackages                             korstiaan/drunit - 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. korstiaan/drunit

ActiveLibrary

korstiaan/drunit
================

Drupal bootstrapper to ease integration/functional testing your Drupal modules

5112PHP

Since Mar 27Pushed 12y agoCompare

[ Source](https://github.com/korstiaan/drunit)[ Packagist](https://packagist.org/packages/korstiaan/drunit)[ RSS](/packages/korstiaan-drunit/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Drunit for Drupal 7.x
=====================

[](#drunit-for-drupal-7x)

Drupal bootstrapper to ease integration/functional testing your Drupal modules.

[![Build Status](https://camo.githubusercontent.com/8a79ce5a366dfda1d17194e159dcef4844639935b52052893945884770c6cbf1/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6b6f7273746961616e2f6472756e69742e706e67)](http://travis-ci.org/korstiaan/drunit)

Requirements
------------

[](#requirements)

- PHP 5.3.3+ (unfortunately the SQLite implementation in Drupal is not compatible with PHP 5.4)
- PDO SQLite driver
- Any other extension Drupal 7.\* requires

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

[](#installation)

The recommended way to install `Drunit` is with [composer](http://getcomposer.org). Just add the following to your `composer.json`:

```
   {
       "repositories": [
           ...
           {
              "type": "package",
              "package": {
                  "version": "7.23",
                  "name": "drupal/core",
                  "dist": {
                      "url": "http://ftp.drupal.org/files/projects/drupal-7.23.zip",
                      "type": "zip"
                  }
              }
           }
       ],
       "require-dev": {
       	   ...
           "korstiaan/drunit": "*"
       },
       "scripts": {
           "post-install-cmd": [
               ...
               "Drunit\\Composer\\ScriptHandler::installDrupal"
           ],
           "post-update-cmd": [
               ...
               "Drunit\\Composer\\ScriptHandler::installDrupal"
           ]
       }
   }
```

And change the versions in the `drupal/core` definition to match the Drupal version you want to test with.

Now update composer and install the newly added requirement and its dependencies:

```
$ php composer.phar update korstiaan/drunit --dev
```

Usage
-----

[](#usage)

### Bootstrap Drupal

[](#bootstrap-drupal)

First initialize composer's autoloading by including it in your tests bootstrap file:

```
// tests/bootstrap.php
use Drunit\Drunit;

require __DIR__ . '/../vendor/autoload.php';

```

### Bootstrap Drupal on each test

[](#bootstrap-drupal-on-each-test)

`Drunit` provides a TestCase class which bootstraps Drupal to its final phase `DRUPAL_BOOTSTRAP_FULL`and makes sure each test is run in its own isolated process. Just extend it to make use of it:

```
use Drunit\TestCase;

class FooTest extends TestCase
{
    ...
}
```

### Enable your module(s)

[](#enable-your-modules)

To enabled your modules in a test just add the following to your test:

```
use Drunit\TestCase;

class FooTest extends TestCase
{
    public function setUp()
    {
        parent::setUp();
        Drunit::enableModule(__DIR__.'/../module', array('my_module'));
    }
    ...
}
```

This will enable module `my_module` located at `__ROOT__.'/module'` (Drupal recursively looks for file `my_module.module`).

If you have multiple modules located in a single directory (for example `__ROOT__.'/modules/my_module1'` and `__ROOT__.'/modules/my_module2`), you can enable them all as follows:

```
Drunit::enableModule(__DIR__.'/../modules', array('my_module1', 'my_module2'));
```

If your module name is the same as the base name of the directory you can leave out the 2nd parameter:

```
Drunit::enableModule(__DIR__.'/../modules/my_module1');
```

License
=======

[](#license)

Drunit is licensed under the MIT license.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/28606876af21640e6b63c08dd90b2f3c4de8ced80423279262d6923b18fcf493?d=identicon)[korstiaan](/maintainers/korstiaan)

---

Top Contributors

[![korstiaan](https://avatars.githubusercontent.com/u/902842?v=4)](https://github.com/korstiaan "korstiaan (48 commits)")

### Embed Badge

![Health badge](/badges/korstiaan-drunit/health.svg)

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

PHPackages © 2026

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