/**
  * Helper which inserts example data into the database.
  *
  * @param string $type
  * 
  */
 protected function insertExampleEntity($type = 'Generic')
 {
     switch ($type) {
         case 'Specific':
             $entity = new Fixture\Model\Specific();
             $repository =& $this->specificRepository;
             break;
         default:
             $entity = new Fixture\Model\Generic();
             $repository =& $this->genericRepository;
             break;
     }
     foreach ($this->data as $type => $values) {
         foreach ($values as $locale => $value) {
             if ($locale === 'default') {
                 $entity->setDefaultLocaleForTranslation();
             } else {
                 $entity->setLocaleForTranslation($locale);
             }
             $entity->{$type} = $value;
         }
     }
     $repository->add($entity);
     $this->persistenceManager->persistAll();
 }
Пример #2
0
 /**
  * Tests all data type against generic translation
  *
  * @param string $type
  * @param mixed $typeCheckFunction
  * @param mixed $value
  * @param mixed $translatedValue
  * @param string $language
  *
  * @test
  * @dataProvider getTranslationTypes
  */
 public function testOnGenericTranslation($type, $typeCheckFunction, $value, $translatedValue, $language = 'en-US')
 {
     $this->markTestIncomplete('This test has not been implemented yet with new feature.');
     $object = new Generic();
     $object->{$type} = $value;
     $object->setLocaleForTranslation($language)->{$type} = $translatedValue;
     if (is_callable($typeCheckFunction)) {
         $this->assertTrue(call_user_func($typeCheckFunction, $object->setLocaleForTranslation($language)->{$type}));
     }
     $this->assertEquals($object->setLocaleForTranslation($language)->{$type}, $translatedValue);
     $this->assertNotEquals($object->setLocaleForTranslation($language)->{$type}, $object->setDefaultLocaleForTranslation()->{$type});
 }