>我正在使用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(;
与错误 :
致命错误:在 {路径 测试文件}
当我更改此内容时:
public function tearDown()
{
if (!empty($this->phinx)) {
$this->phinx->run(new StringInput('rollback -t 0'), new NullOutput);
}
}
它通过了,但由于没有回滚,我的下一个测试崩溃了
您是否使用命名空间 (PSR-4( ?如果是这样,您应该有以下代码行:
use PhinxConsolePhinxApplication;