Could you show us your config/database.php ?
phpUnit is deleting my database!
Okay, I hope that this isn't a bug. This is my test case
<?php
namespace Tests\Feature\Discussions;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ThreadsTest extends TestCase
{
use RefreshDatabase;
/** @test */
public function guests_can_view_thread_list()
{
$thread = factory('App\Model\Discussions\Thread')->create(['state' => 1]);
$this->get('/threads/latest')
->assertSee($thread->title);
}
}
My phpUnit.xml has :
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
...Which is the standard set up I've been using for my trial projects. Today, I upgraded composer and brew; then did a fresh install of Laravel and wrote my first test. This simple test produced erratic behavior - it'd pass or fail randomly on each run.
I then decided to find out the pattern; and ran the phpUnit (first through terminal, then through phpStorm) and was surprised to find out that the test actually deleted my database!
My prime suspect is that the RefreshDatabase thing is actually working on my real database and not sqlite.
I was able to reproduce this issue 3 times at the time of creating this thread. However, I did another composer dumpautoload and php artisan cache:clear and now, I'm getting random pass or fails on this test case.
Can someone point me in the right direction? I'm unable to figure out what's going on.
Please or to participate in this conversation.