Reputation: 446
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 running this code I get an error telling me tables do no exist, the only way I can get it to work is to call $this->runDatabaseMigrations();
in the setUp()
method, but as far as I know I should not need to do that. I have similar issues with DatabaseTransactions.
Laravel 5.1.23
Any ideas on why this is happening as the docs say that it should be triggered automatically.
Upvotes: 2
Views: 1042
Reputation: 446
This should have been fixed: https://laracasts.com/discuss/channels/testing/databasetransactions-databasemigrations-have-no-effect?page=0#reply-112955 (see the last comment by Jeffrey)
Upvotes: 1
Reputation: 101
I'm having the same problem. I ended up going the route of using shell_exec() to drop, create, and reseed the database with a mysql.dump file. It's a pretty sloppy alternative, but the only thing that seems to be working right now, short of writing a bunch of SQL scripts to put everything in.
Laravel 5 Reseeding the Database for Unit Testing Between Tests
Upvotes: 1