Laravel DatabaseTransactions, DatabaseMigrations do not affect testing

I have the following test class

use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; class ProvidersTest extends TestCase { use DatabaseMigrations; /** * @var \Orka\Entities\User */ protected $user; public function setUp() { parent::setUp(); $user = factory(\Orka\Entities\User::class)->create(); $this->user = $user; } /** * @test */ public function it_shows_no_connected_providers() { $this ->actingAs($this->user) ->visit('/teams/1/providers') ->see('You have not connected a provider yet.') ; } } 

When I run this code, I get an error message indicating that the tables do not exist, the only way to make it work is to call $this->runDatabaseMigrations(); in the setUp() method, but as far as I know, I do not need to do this. I have similar problems with DatabaseTransactions.

Laravel 5.1.23

Any ideas on why this is happening as the docs say they should start automatically.

+2
source share
2 answers

I have the same problem. I ended up using shell_exec () to delete, create and reload the database using the mysql.dump file. This is a pretty messy alternative, but the only thing that seems to work right now without writing a bunch of SQL scripts to put everything in.

Laravel 5 Reloading database for unit testing between tests

+1
source

All Articles