foogile/elgg-phpunit

PHPUnit setup to support integration testing with Elgg.

v0.0.3 2015-04-15 17:07 UTC

This package is not auto-updated.

Last update: 2024-04-27 15:25:52 UTC


README

Simple test configuration to support integration testing in Elgg using PHPUnit. Assumes the default directory structure for Elgg 1.9.

Installation

Install test configuration into your plugin using composer:

composer require foogile/elgg-phpunit

Usage

There are three default PHPUnit configurations that can be used to run all unit tests, all integration tests, or all tests. Unit tests are placed in PLUGIN/tests/unit adn integration tests are placed in PLUGIN/tests/integration. You can modify the Elgg configuration for the test environment by creating a file named PLUGIN/tests/integration/settings.php.

Bootstrap

You can run custom init code by creating PLUGIN/tests/integration/bootstrap.php and PLUGIN/tests/unit/bootstrap.php for integration and unit tests, respectively. Additionally, PLUGIN/tests/bootstrap.php is loaded first for all cases.

Run unit tests

phpunit -c vendor/foogile/elgg-phpunit/phpunit.unit.xml

Run integration tests

phpunit -c vendor/foogile/elgg-phpunit/phpunit.integration.unit.xml

Run all tests

phpunit -c vendor/foogile/elgg-phpunit/phpunit.xml

Elgg installation helper

It is included a utility script to install an Elgg test environment. To initialize the database, specify your database setup in PLUGIN/tests/integration/settings.php and execute the following from the root folder of your plugin:

php vendor/foogile/elgg-phpunit/install.php