Explorar o código

Fixed Security tests failing when D2 is not present

Jordi Boggiano %!s(int64=14) %!d(string=hai) anos
pai
achega
964bf4356e

+ 3 - 0
tests/Symfony/Tests/Component/Security/Acl/Dbal/AclProviderTest.php

@@ -115,6 +115,9 @@ class AclProviderTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
+        if (!class_exists('Doctrine\DBAL\DriverManager')) {
+            $this->markTestSkipped('The Doctrine2 DBAL is required for this test');
+        }
         $this->con = DriverManager::getConnection(array(
             'driver' => 'pdo_sqlite',
             'memory' => true,

+ 3 - 0
tests/Symfony/Tests/Component/Security/Acl/Dbal/MutableAclProviderTest.php

@@ -396,6 +396,9 @@ class MutableAclProviderTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
+        if (!class_exists('Doctrine\DBAL\DriverManager')) {
+            $this->markTestSkipped('The Doctrine2 DBAL is required for this test');
+        }
         $this->con = DriverManager::getConnection(array(
             'driver' => 'pdo_sqlite',
             'memory' => true,

+ 7 - 0
tests/Symfony/Tests/Component/Security/Acl/Domain/AclTest.php

@@ -499,4 +499,11 @@ class AclTest extends \PHPUnit_Framework_TestCase
     {
         return new Acl(1, new ObjectIdentity(1, 'foo'), new PermissionGrantingStrategy(), array(), true);
     }
+
+    public function setUp()
+    {
+        if (!class_exists('Doctrine\DBAL\DriverManager')) {
+            $this->markTestSkipped('The Doctrine2 DBAL is required for this test');
+        }
+    }
 }

+ 7 - 0
tests/Symfony/Tests/Component/Security/Acl/Domain/DoctrineAclCacheTest.php

@@ -91,4 +91,11 @@ class DoctrineAclCacheTest extends \PHPUnit_Framework_TestCase
 
         return new DoctrineAclCache($cacheDriver, $this->getPermissionGrantingStrategy(), $prefix);
     }
+
+    public function setUp()
+    {
+        if (!class_exists('Doctrine\DBAL\DriverManager')) {
+            $this->markTestSkipped('The Doctrine2 DBAL is required for this test');
+        }
+    }
 }

+ 14 - 7
tests/Symfony/Tests/Component/Security/Acl/Domain/ObjectIdentityTest.php

@@ -9,11 +9,11 @@ class ObjectIdentityTest extends \PHPUnit_Framework_TestCase
     public function testConstructor()
     {
         $id = new ObjectIdentity('fooid', 'footype');
-        
+
         $this->assertEquals('fooid', $id->getIdentifier());
         $this->assertEquals('footype', $id->getType());
     }
-    
+
     public function testFromDomainObjectPrefersInterfaceOverGetId()
     {
         $domainObject = $this->getMock('Symfony\Component\Security\Acl\Model\DomainObjectInterface');
@@ -27,17 +27,17 @@ class ObjectIdentityTest extends \PHPUnit_Framework_TestCase
             ->method('getId')
             ->will($this->returnValue('getId()'))
         ;
-        
+
         $id = ObjectIdentity::fromDomainObject($domainObject);
         $this->assertEquals('getObjectIdentifier()', $id->getIdentifier());
     }
-    
+
     public function testFromDomainObjectWithoutInterface()
     {
         $id = ObjectIdentity::fromDomainObject(new TestDomainObject());
         $this->assertEquals('getId()', $id->getIdentifier());
     }
-    
+
     /**
      * @dataProvider getCompareData
      */
@@ -50,7 +50,7 @@ class ObjectIdentityTest extends \PHPUnit_Framework_TestCase
             $this->assertFalse($oid1->equals($oid2));
         }
     }
-    
+
     public function getCompareData()
     {
         return array(
@@ -60,6 +60,13 @@ class ObjectIdentityTest extends \PHPUnit_Framework_TestCase
             array(new ObjectIdentity('1', 'bla'), new ObjectIdentity('1', 'blub'), false),
         );
     }
+
+    public function setUp()
+    {
+        if (!class_exists('Doctrine\DBAL\DriverManager')) {
+            $this->markTestSkipped('The Doctrine2 DBAL is required for this test');
+        }
+    }
 }
 
 class TestDomainObject
@@ -68,7 +75,7 @@ class TestDomainObject
     {
         return 'getObjectIdentifier()';
     }
-    
+
     public function getId()
     {
         return 'getId()';

+ 7 - 0
tests/Symfony/Tests/Component/Security/Acl/Domain/PermissionGrantingStrategyTest.php

@@ -187,4 +187,11 @@ class PermissionGrantingStrategyTest extends \PHPUnit_Framework_TestCase
         static $id = 1;
         return new Acl($id++, new ObjectIdentity(1, 'Foo'), $strategy, array(), true);
     }
+
+    public function setUp()
+    {
+        if (!class_exists('Doctrine\DBAL\DriverManager')) {
+            $this->markTestSkipped('The Doctrine2 DBAL is required for this test');
+        }
+    }
 }