多数据库连接的数据库事务

DatabaseTransactions trait 允许数据库在测试期间回滚所有更改。如果要回滚多个数据库,则需要设置 $connectionsToTransact 属性

use Illuminate\Foundation\Testing\DatabaseMigrations;

class ExampleTest extends TestCase
{
     use DatabaseTransactions;

     $connectionsToTransact =["mysql","sqlite"] //tell Laravel which database need to rollBack

    public function testExampleIndex()
    {
        $this->visit('/action/parameter')
         ->see('items');
    }
}