Selaa lähdekoodia

added tests for uppercase properties

Robert Gruendler 13 vuotta sitten
vanhempi
commit
5e38b7f018

+ 16 - 1
tests/Gedmo/Translator/Fixture/Person.php

@@ -27,6 +27,11 @@ class Person
      * @ORM\Column(name="desc", type="string", length=128)
      */
     public $description;
+    
+    /**
+     * @ORM\Column(name="last_name", type="string", length=128, nullable=true)
+     */
+    public $lastName;
 
     public function getId()
     {
@@ -52,6 +57,16 @@ class Person
     {
         return $this->description;
     }
+    
+    public function getLastName()
+    {
+        return $this->lastName;
+    }
+    
+    public function setLastName($name)
+    {
+        $this->lastName = $name;
+    }
 
 
 
@@ -96,7 +111,7 @@ class Person
 
         return new \Gedmo\Translator\TranslationProxy($this,
         /* Locale                            */ $locale,
-        /* List of translatable properties:  */ array('name'),
+        /* List of translatable properties:  */ array('name', 'lastName'),
         /* Translation entity class:         */ 'Translator\Fixture\PersonTranslation',
         /* Translations collection property: */ $this->translations
         );

+ 22 - 0
tests/Gedmo/Translator/TranslatableTest.php

@@ -139,6 +139,28 @@ class TranslatableTest extends BaseTestCaseORM
         $name = $personProxy->translate('ru_RU')->getName();
         $this->assertSame('Женя', $name);
     }
+    
+    public function testTranslatableProxyWithUpperCaseProperty()
+    {
+        $person = new Person();
+        $person->setName('Jen');
+        $person->translate('ru_RU')->name = 'Женя';
+        $person->setLastName('Abramowicz');
+        $person->translate('ru_RU')->setLastName('Абрамович');
+        $person->setDescription('description');
+        $person->translate('ru_RU')->setDescription('multilingual description');        
+        
+        $this->em->persist($person);
+        $this->em->flush();
+        $this->em->clear();
+        
+        $personProxy = $this->em->getReference(self::PERSON, array('id' => 1));
+        $this->assertTrue($personProxy instanceof Proxy);
+        $name = $personProxy->translate('ru_RU')->getName();
+        $this->assertSame('Женя', $name);
+        $lastName = $personProxy->translate('ru_RU')->getLastName();
+        $this->assertSame('Абрамович', $lastName);
+    }
 
     public function testTranslatableWithMagicProperties()
     {