Have you done something with your database.php config file to override the stock config?
Oct 20, 2017
5
Level 15
Empty database after test
Hey guys
I want to start with TDD and have a strange problem:
I've added these lines to my phpunit.xml:
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
and this is my test file:
namespace Tests\Feature\Admin;
use App\User;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class AdminTest extends TestCase
{
use RefreshDatabase;
/** @test */
function a_user_cant_see_admin_area()
{
$this->actingAs(factory(User::class)->create());
$this->get('/admin/index')
->assertStatus(403);
}
}
I thought I've set everything up to use the memory database and don't test against my MySQL database. But after every test my MySQL database is empty.
What am I doing wrong?
Please or to participate in this conversation.