Browse Source

Test for empty translations

Robert 10 years ago
parent
commit
6cfbf2317f
1 changed files with 16 additions and 0 deletions
  1. 16 0
      tests/TestCase/ORM/Behavior/Translate/TranslateTraitTest.php

+ 16 - 0
tests/TestCase/ORM/Behavior/Translate/TranslateTraitTest.php

@@ -64,6 +64,22 @@ class TranslateTraitTest extends TestCase
     }
 
     /**
+     * Tests empty translations.
+     *
+     * @return void
+     */
+    public function testTranslationEmpty()
+    {
+        $entity = new TestEntity;
+        $entity->set('_translations', [
+            'eng' => new Entity(['title' => 'My Title']),
+            'spa' => new Entity(['title' => 'Titulo'])
+        ]);
+        $this->assertTrue($entity->translation('pol')->isNew());
+        $this->assertInstanceOf('Cake\Test\TestCase\ORM\Behavior\Translate\TestEntity', $entity->translation('pol'));
+    }
+
+    /**
      * Tests that just accessing the translation will mark the property as dirty, this
      * is to facilitate the saving process by not having to remember to mark the property
      * manually