Browse Source

[SoftDeleteable] Fixed tests

comfortablynumb 13 years ago
parent
commit
1ecdc4101e

+ 3 - 5
tests/Gedmo/SoftDeleteable/SoftDeleteableEntityTest.php

@@ -85,13 +85,11 @@ class SoftDeleteableEntityTest extends BaseTestCaseORM
         $this->assertTrue(is_object($comment->getDeletedAt()));
         $this->assertTrue($comment->getDeletedAt() instanceof \DateTime);
 
-        $art->setDeletedAt(null);
-        $comment->setDeletedAt(null);
-        $this->em->persist($art);
-        $this->em->flush();
-
         $this->em->createQuery('UPDATE '.self::ARTICLE_CLASS.' a SET a.deletedAt = NULL')->execute();
 
+        $this->em->refresh($art);
+        $this->em->refresh($comment);
+
         // Now we try with a DQL Delete query
         $this->em->getFilters()->enable(self::SOFT_DELETEABLE_FILTER_NAME);
         $dql = sprintf('DELETE FROM %s a WHERE a.%s = :%s',

+ 15 - 1
tests/Gedmo/Tool/BaseTestCaseORM.php

@@ -208,7 +208,21 @@ abstract class BaseTestCaseORM extends \PHPUnit_Framework_TestCase
      */
     protected function getMockAnnotatedConfig()
     {
-        $config = $this->getMock('Doctrine\ORM\Configuration');
+        // We need to mock every method except the ones which
+        // handle the filters
+        $configurationClass = 'Doctrine\ORM\Configuration';
+        $refl = new \ReflectionClass($configurationClass);
+        $methods = $refl->getMethods();
+
+        $mockMethods = array();
+
+        foreach ($methods as $method) {
+            if ($method->name !== 'addFilter' && $method->name !== 'getFilterClassName') {
+                $mockMethods[] = $method->name;
+            }
+        }
+        
+        $config = $this->getMock($configurationClass, $mockMethods);
 
         $config
             ->expects($this->once())