Skip to content

单元测试

TIGERB edited this page May 21, 2017 · 3 revisions

tests目录下编写测试文件,具体参考tests/demo目录下的DemoTest文件,然后运行:

 vendor/bin/phpunit

测试断言示例:

/**
 * 演示测试
 */
public function testDemo()
{
    $this->assertEquals(
        'Hello Easy PHP',
        // 执行demo模块index控制器hello操作,断言结果是不是等于'Hello Easy PHP' 
        App::$app->get('demo/index/hello')
    );
}

phpunit断言文档语法参考

Clone this wiki locally