public function testMessage()
 {
     $catalogue = new MessageCatalogue('foo');
     $message = new Message('foo', 'bar', 'baz');
     $catalogue->addMessage($message);
     $this->assertTrue($catalogue->defines('foo', 'baz'));
     $this->assertEquals($message, $catalogue->getMessage('foo', 'baz'));
 }
 /**
  * Load messages cached for specified action.
  * @param  string                                             $locale
  * @param  string                                             $bundle
  * @param  string                                             $controller
  * @param  string                                             $action
  * @return \AO\TranslationBundle\Translation\MessageCatalogue
  */
 public function loadAction($locale, $bundle, $controller, $action)
 {
     $catalogue = new MessageCatalogue($locale);
     $qb = $this->em->createQueryBuilder();
     $qb->select('m, d, t')->from('AOTranslationBundle:Message', 'm')->leftJoin('m.translations', 't', 'WITH', 't.locale = :locale')->innerJoin('m.caches', 'c')->innerJoin('m.domain', 'd')->where('c.bundle=:bundle AND c.controller=:controller AND c.action=:action')->setParameters(array('locale' => $locale, 'bundle' => $bundle, 'controller' => $controller, 'action' => $action));
     $results = $qb->getQuery()->getResult();
     foreach ($results as $m) {
         $message = new Message($m->getIdentification(), null, $m->getDomain()->getName());
         if ($translation = $m->getLocaleTranslation($locale)) {
             $message->setContent($translation->getContent());
         }
         $message->setParameters($m->getParameters());
         $message->setStatus('cached');
         $message->setEntity($m);
         $catalogue->addMessage($message);
     }
     return $catalogue;
 }