watoki/scrut

PHP的注入式测试类。

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

This package is not auto-updated.

Last update: 2024-09-14 15:21:45 UTC


README

你是否曾想过在你的测试类中使用依赖注入有多好?无需再寻找!scrut 使用 [工厂] 注入其属性。只需继承自 Specification(它继承自 PHPUnitTestCase),并通过标记注入属性为 <- 来定义其依赖项。

/**
 * @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 可以用来创建可维护的测试套件,这些套件还可以很好地作为 活文档,然后可以通过(例如,使用 dox)进行发布。