Database interaction - gricob/functional-test-bundle GitHub Wiki
Loading fixtures
$this->loadFixtures([LoadUserData::class]);
$user = $this->getReference(LoadUserData::USER);
Refreshing the database
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;
}
Assertions
assertDatabaseHas
Assert that an entity in the database contains the given data.
$this->assertDatabaseHas(User::class, ['username' => 'john']);
assertDatabaseMissing
Assert that an entity in the database does not contain the given data.
$this->assertDatabaseMissing(User::class, ['username' => 'john']);