/**
  * @param string $key
  * @param string $value
  */
 protected function assertTranslationRepositoryCalled($key, $value)
 {
     $trans = new Translation();
     $this->repository->expects($this->once())->method('saveValue')->with($key, $value, self::LOCALE, TranslationRepository::DEFAULT_DOMAIN, Translation::SCOPE_UI)->willReturn($trans);
     /** @var \PHPUnit_Framework_MockObject_MockObject|ObjectManager $manager */
     $manager = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
     $manager->expects($this->once())->method('getRepository')->with(Translation::ENTITY_NAME)->willReturn($this->repository);
     $manager->expects($this->once())->method('flush')->with([$trans]);
     $this->registry->expects($this->any())->method('getManagerForClass')->with(Translation::ENTITY_NAME)->willReturn($manager);
 }
Пример #2
0
 /**
  * Find existing translation in database
  *
  * @param string $key
  * @param string $locale
  * @param string $domain
  * @param string $value
  *
  * @return Translation
  */
 private function getTranslationObject($key, $locale, $domain, $value)
 {
     $object = $this->repository->findValue($key, $locale, $domain);
     if (null === $object) {
         $object = new Translation();
         $object->setScope(Translation::SCOPE_SYSTEM);
         $object->setLocale($locale);
         $object->setDomain($domain);
         $object->setKey($key);
     }
     $object->setValue($value);
     return $object;
 }