Permalink
Browse files

Correctly handle relative paths for namespaces in PHPUnit bootstrap

  • Loading branch information...
1 parent d6ed535 commit 6b33d39b50c8df4d515c14d40f74eeec2b3b8fff @mrtorrent mrtorrent committed Sep 28, 2011
Showing with 12 additions and 1 deletion.
  1. +11 −0 Tests/bootstrap.php
  2. +1 −1 phpunit.xml.dist
View
@@ -8,6 +8,17 @@
}
});
+foreach (array('SYMFONY', 'DOCTRINE_COMMON', 'DOCTRINE_ORM') as $component) {
+ if (!isset($_SERVER[$component])) {
+ throw new \RuntimeException("You must set the {$component} path");
+ }
+
+ if (0 === strpos($_SERVER[$component], '..')) {
+ # The path is relative to phpunit.xml, so get the absolute path
+ $_SERVER[$component] = realpath(__DIR__ . "/../{$_SERVER[$component]}");
+ }
+}
+
require_once $_SERVER['SYMFONY'].'/Symfony/Component/ClassLoader/UniversalClassLoader.php';
$loader = new Symfony\Component\ClassLoader\UniversalClassLoader();
View
@@ -2,7 +2,7 @@
<phpunit bootstrap="Tests/bootstrap.php">
<php>
- <!-- override these paths in your phpunit.xml if necessary -->
+ <!-- override these paths in your phpunit.xml if necessary, relative to this directory -->
<server name="SYMFONY" value="../../../symfony/src" />
<server name="DOCTRINE_COMMON" value="../../../doctrine-common/lib" />
<server name="DOCTRINE_ORM" value="../../../doctrine/lib" />

0 comments on commit 6b33d39

Please sign in to comment.