Explorar o código

inheritance extension annotation mapping tests added

gediminasm %!s(int64=14) %!d(string=hai) anos
pai
achega
59374cd1f0
Modificáronse 2 ficheiros con 24 adicións e 4 borrados
  1. 1 1
      lib/Gedmo/Tree/Exception.php
  2. 23 3
      tests/Gedmo/Tree/MultiInheritanceTest.php

+ 1 - 1
lib/Gedmo/Tree/Exception.php

@@ -20,7 +20,7 @@ class Exception extends \Exception
     
     static public function missingMetaProperties($fields, $class)
     {
-        return new self("Tree: has detected missing properties: " . explode(', ', $fields) . " in class - {$class}");
+        return new self("Tree: has detected missing properties: " . implode(', ', $fields) . " in class - {$class}");
     }
     
     static public function notValidFieldType($field, $class)

+ 23 - 3
tests/Gedmo/Tree/MultiInheritanceTest.php

@@ -40,8 +40,12 @@ class MultiInheritanceTest extends \PHPUnit_Framework_TestCase
         //$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
         
         $evm = new \Doctrine\Common\EventManager();
-        $treeListener = new TreeListener();
-        $evm->addEventSubscriber($treeListener);
+        $evm->addEventSubscriber(new \Gedmo\Timestampable\TimestampableListener());
+        $evm->addEventSubscriber(new \Gedmo\Sluggable\SluggableListener());
+        $evm->addEventSubscriber(new \Gedmo\Tree\TreeListener());
+        $translationListener = new \Gedmo\Translatable\TranslationListener();
+        $translationListener->setTranslatableLocale('en_us');
+        $evm->addEventSubscriber($translationListener);
         $this->em = \Doctrine\ORM\EntityManager::create($conn, $config, $evm);
 
         $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
@@ -57,8 +61,24 @@ class MultiInheritanceTest extends \PHPUnit_Framework_TestCase
     }
     
     public function testInheritance()
-    {        
+    {
+        $meta = $this->em->getClassMetadata(self::TEST_ENTITY_CLASS);
+        $repo = $this->em->getRepository(self::TEST_ENTITY_CLASS);
+        
+        $food = $repo->findOneByIdentifier('food');
+        $left = $meta->getReflectionProperty('lft')->getValue($food);
+        $right = $meta->getReflectionProperty('rgt')->getValue($food);
+        
+        $this->assertEquals(1, $left);
+        $this->assertTrue($food->getCreated() !== null);
+        $this->assertTrue($food->getUpdated() !== null);
+        
+        $translationRepo = $this->em->getRepository(self::TEST_ENTITY_TRANSLATION);
+        $translations = $translationRepo->findTranslations($food);
         
+        $this->assertEquals(1, count($translations));
+        $this->assertEquals('food', $food->getSlug());
+        $this->assertEquals(2, count($translations['en_us']));
     }
     
     private function _populate()