Laravel 5.3與MySQL,PHPUnit的5.7.4Laravel 5.3 DatabaseMigrations是破壞性的
當我創建PHPUnit中與use DatabaseMigrations;
測試,它破壞了它查詢的數據。
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ThingsTest extends TestCase
{
use DatabaseMigrations;
/** @test */
public function there_are_more_than_1000_things()
{
$things = App\Thing::all();
$this->assertGreaterThan(1000, count($things));
}
在我運行phpunit
之前,有很多東西。運行後,mysql說ERROR 1146 (42S02): Table 'database.things' doesn't exist
任何想法如何阻止?
'DatabaseTransactions'完成了任務。 –