Переглянути джерело

merged branch stloyd/tests-fix (PR #2401)

Commits
-------

205f524 [Tests] Skip MimeTypeTest if running as root
d3e9104 [Tests] Skip Routing annotation tests when Doctrine is not available.

Discussion
----------

[Tests] Fix tests when some vendor is not available.
Fabien Potencier 13 роки тому
батько
коміт
2aa1e4d351

+ 1 - 1
tests/Symfony/Tests/Component/HttpFoundation/File/MimeType/MimeTypeTest.php

@@ -94,7 +94,7 @@ class MimeTypeTest extends \PHPUnit_Framework_TestCase
         touch($path);
         chmod($path, 0333);
 
-        if (substr(sprintf('%o', fileperms($path)), -4) == '0333') {
+        if (get_current_user() != 'root' && substr(sprintf('%o', fileperms($path)), -4) == '0333') {
             $this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException');
             MimeTypeGuesser::getInstance()->guess($path);
         } else {

+ 7 - 0
tests/Symfony/Tests/Component/Routing/Loader/AbstractAnnotationLoaderTest.php

@@ -18,6 +18,13 @@ use Symfony\Component\Routing\RouteCollection;
 
 abstract class AbstractAnnotationLoaderTest extends \PHPUnit_Framework_TestCase
 {
+    public function setUp()
+    {
+        if (!class_exists('Doctrine\\Common\\Version')) {
+            $this->markTestSkipped('Doctrine is not available.');
+        }
+    }
+
     public function getReader()
     {
         return $this->getMockBuilder('Doctrine\Common\Annotations\Reader')

+ 2 - 0
tests/Symfony/Tests/Component/Routing/Loader/AnnotationClassLoaderTest.php

@@ -25,6 +25,8 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
 
     public function setUp()
     {
+        parent::setUp();
+
         $this->loader = $this->getClassLoader($this->getReader());
     }
 

+ 2 - 0
tests/Symfony/Tests/Component/Routing/Loader/AnnotationDirectoryLoaderTest.php

@@ -26,6 +26,8 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
 
     public function setUp()
     {
+        parent::setUp();
+
         $this->reader = $this->getReader();
         $this->loader = new AnnotationDirectoryLoader(new FileLocator(), $this->getClassLoader($this->reader));
     }

+ 2 - 0
tests/Symfony/Tests/Component/Routing/Loader/AnnotationFileLoaderTest.php

@@ -26,6 +26,8 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
 
     public function setUp()
     {
+        parent::setUp();
+
         $this->reader = $this->getReader();
         $this->loader = new AnnotationFileLoader(new FileLocator(), $this->getClassLoader($this->reader));
     }