protected function prepareData()
 {
     $notificationManager = $this->client->getContainer()->get('doctrine');
     $this->eventUpdate = $notificationManager->getRepository('OroNotificationBundle:Event')->findOneBy(array('name' => 'oro.notification.event.entity_post_update'));
     $this->eventCreate = $notificationManager->getRepository('OroNotificationBundle:Event')->findOneBy(array('name' => 'oro.notification.event.entity_post_persist'));
     $this->templateUpdate = $notificationManager->getRepository('OroEmailBundle:EmailTemplate')->findOneBy(array('entityName' => self::ENTITY_NAME));
 }
 public function testApiGen()
 {
     $result = ToolsAPI::getEntityGrid($this->client, 'users-grid', array('users-grid[_filter][username][value]' => 'testUser1'));
     ToolsAPI::assertJsonResponse($result, 200);
     $result = ToolsAPI::jsonToArray($result->getContent());
     $result = reset($result['data']);
     $this->client->request('GET', $this->client->generate('oro_user_apigen', array('id' => $result['id'])), array(), array(), array('HTTP_X-Requested-With' => 'XMLHttpRequest'));
     /** @var User $user */
     $user = $this->client->getContainer()->get('doctrine')->getRepository('OroUserBundle:User')->findOneBy(array('id' => $result['id']));
     $result = $this->client->getResponse();
     ToolsAPI::assertJsonResponse($result, 200, '');
     //verify result
     $this->assertEquals($user->getApi()->getApiKey(), trim($result->getContent(), '"'));
 }