watoki/scrut

Injectable test classes for PHP.

Installs: 3 912

Dependents: 10

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/watoki/scrut

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

This package is not auto-updated.

Last update: 2025-10-11 20:41:18 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).