eloquent / phpunit-extensions
Extensions for PHPUnit to provide additional functionality.
Installs: 1 417
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 2
Requires (Dev)
- eloquent/liberator: ~2
- icecave/archer: ~1
- phpunit/phpunit: ~3
This package is not auto-updated.
Last update: 2020-01-24 15:27:38 UTC
README
Extensions for PHPUnit to provide additional functionality.
Installation and documentation
- Available as Composer package eloquent/phpunit-extensions.
- API documentation available.
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.