我正在使用 PHPUnit 5.7.23 和 phinx 0.9.1,
public function setUp(){
$this->phinx = new PhinxApplication;
$this->phinx->setAutoExit(false);
$this->phinx->run(new StringInput('migrate'), new NullOutput);
$this->phinx->run(new StringInput('seed:run'), new NullOutput);
}
public function tearDown(){
$this->phinx->run(new StringInput('rollback -t 0'), new NullOutput);
}
这是我的测试文件的代码,每次我添加时
public function testExampleFunction(){
$this->assertTrue(true);
}
它失败了:
$this->phinx->run(new StringInput('rollback -t 0'), new NullOutput);
有错误:
致命错误:在 {path to the test file} 中调用 null 上的成员函数 run()
当我改变这个:
public function tearDown()
{
if (!empty($this->phinx)) {
$this->phinx->run(new StringInput('rollback -t 0'), new NullOutput);
}
}
它通过了,但由于没有回滚,我的下一个测试已经崩溃