ezzatron/phpunit-extensions

Extensions for PHPUnit to provide additional functionality.

Installs: 529

Dependents: 2

Stars: 2

Watchers: 1

Open Issues: 2

Language: PHP

2.0.0 2014-02-17 09:49 UTC

README

Extensions for PHPUnit to provide additional functionality.

The most recent stable version is 2.0.0 Current build status image Current coverage status image

Installation and documentation

Parameterized test cases

Parameterized test cases allow entire PHPUnit test cases to be run in multiple different configurations. They operate similar to PHPUnit's own data providers, but on a test case level rather than a test method level.

To create a parameterized test case, extend the ParameterizedTestCase class instead of PHPUnit_Framework_TestCase, and implement the required methods:

use Eloquent\Phpunit\ParameterizedTestCase;

class ExampleTest extends ParameterizedTestCase
{
    public function getTestCaseParameters()
    {
        return array(
            array('Ocelot', 'Lapis lazuli', 'Dandelion'),
            array('Sloth', 'Carbon', 'Conifer'),
        );
    }

    public function setUpParameterized($animal, $mineral, $vegetable)
    {
        // set up...
    }

    public function tearDownParameterized($animal, $mineral, $vegetable)
    {
        // tear down...
    }

    public function testSomething()
    {
        // test...
    }
}

Every test in the testcase will now be run once for each entry in the getTestCaseParameters() method.