watoki/scrut

Injectable test classes for PHP.

v0.3 2015-05-12 12:48 UTC

This package is not auto-updated.

Last update: 2024-04-13 13:09:39 UTC


README

Have you ever thought how nice it would be to use dependency injection in your test classes? Search no further! scrut uses [factory] to inject it's properties. Just extend from Specification (which extends PHPUnit's TestCase) and define its dependencies by marking injectable properties with <-.

/**
 * @property DependencyOne one <-
 * @property NotInjected not (because to arrow)
 */
class MyTest extends Specification {

    /** @var DependencyTwo <- **/
    public $two;

    function testSomething() {
        $this->one->createSomeTestContext();
        $this->two->doSomething();
        $this->assertTrue($this->one->everythingIsCool());
    }
}

scrut can be used to create maintainable test suites which can also serve quite nicely as living documentation which then can be published (with dox for example).