dev-master
9999999-dev http://korstiaan.com/drunitDrupal bootstrapper to ease integration/functional testing your Drupal modules
MIT
The Requires
The Development Requires
testing drupal
Drupal bootstrapper to ease integration/functional testing your Drupal modules
Drupal bootstrapper to ease integration/functional testing your Drupal modules., (*1)
The recommended way to install Drunit
is with composer.
Just add the following to your composer.json
:, (*3)
{ "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., (*4)
Now update composer and install the newly added requirement and its dependencies:, (*5)
``` bash $ php composer.phar update korstiaan/drunit --dev, (*6)
## Usage ### Bootstrap Drupal First initialize composer's autoloading by including it in your tests bootstrap file: ```php // tests/bootstrap.php use Drunit\Drunit; require __DIR__ . '/../vendor/autoload.php';
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:, (*7)
use Drunit\TestCase; class FooTest extends TestCase { ... }
To enabled your modules in a test just add the following to your test:, (*8)
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
)., (*9)
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:, (*10)
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:, (*11)
Drunit::enableModule(__DIR__.'/../modules/my_module1');
Drunit is licensed under the MIT license., (*12)
Drupal bootstrapper to ease integration/functional testing your Drupal modules
MIT
testing drupal