-
Notifications
You must be signed in to change notification settings - Fork 1
Database interaction
Gerard Rico Botella edited this page Nov 9, 2019
·
2 revisions
$this->loadFixtures([LoadUserData::class]);
$user = $this->getReference(LoadUserData::USER);
In order to refresh database just use RefreshDatabase trait. This trait will create the database schema on test setUp and purge it on tearDown.
use Gricob\SymfonyWebTestBundle\Testing\RefreshDatabase;
class FunctionalTest extends WebTestCase
{
use RefreshDatabase;
}
Assert that an entity in the database contains the given data.
$this->assertDatabaseHas(User::class, ['username' => 'john']);
Assert that an entity in the database does not contain the given data.
$this->assertDatabaseMissing(User::class, ['username' => 'john']);