Here is an example from a test suite that includes database results. If you need to interact directly with the database in your test, the object manager may be available for testing. See this bit of documentation for more information. Note that the results are most often displayed on a web page and read by the DOM crawler.
public function setUp() { self::bootKernel(); $this->em = static::$kernel->getContainer() ->get('doctrine') ->getManager() ; $this->tool = static::$kernel->getContainer() ->get('truckee.toolbox') ; $classes = array( 'Truckee\VolunteerBundle\DataFixtures\SampleData\LoadFocusSkillData', 'Truckee\VolunteerBundle\DataFixtures\SampleData\LoadMinimumData', 'Truckee\VolunteerBundle\DataFixtures\SampleData\LoadStaffUserGlenshire', 'Truckee\VolunteerBundle\DataFixtures\SampleData\LoadStaffUserMelanzane', 'Truckee\VolunteerBundle\DataFixtures\SampleData\LoadOpportunity', 'Truckee\VolunteerBundle\DataFixtures\SampleData\LoadVolunteer', ); $this->loadFixtures($classes); $this->client = $this->createClient(); $this->client->followRedirects(); } public function testOutboxUser() { $crawler = $this->login('admin'); $link = $crawler->selectLink("Send alerts to organizations")->link(); $crawler = $this->client->click($link); $outboxObj = $this->em->getRepository('TruckeeVolunteerBundle:AdminOutbox')->findAll(); $outbox = $outboxObj[0]; $recipient = $outbox->getRecipientId(); $type = $this->tool->getTypeFromId($recipient); $this->assertEquals('staff', $type); }
source share