Permalink
Browse files

Get unit tests working.

  • Loading branch information...
1 parent f6ca28b commit 79db7833b6428ddb6670e2db56e174ba726c2592 Daniel Convissor committed Dec 30, 2011
Showing with 24 additions and 9 deletions.
  1. +14 −8 {Text → }/tests/AllTests.php
  2. +10 −1 {Text → }/tests/PathNavigatorTest.php
View
22 Text/tests/AllTests.php → tests/AllTests.php
@@ -17,12 +17,15 @@
define('PHPUnit_MAIN_METHOD', 'Text_PathNavigator_AllTests::main');
}
-require_once 'PHPUnit/Framework.php';
-require_once 'PHPUnit/TextUI/TestRunner.php';
-
-chdir(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
-
-require_once dirname(__FILE__) . '/PathNavigatorTest.php';
+if ($fp = @fopen('PHPUnit/Autoload.php', 'r', true)) {
+ require_once 'PHPUnit/Autoload.php';
+} elseif ($fp = @fopen('PHPUnit/Framework.php', 'r', true)) {
+ require_once 'PHPUnit/Framework.php';
+ require_once 'PHPUnit/TextUI/TestRunner.php';
+} else {
+ die('skip could not find PHPUnit');
+}
+fclose($fp);
class Text_PathNavigator_AllTests
{
@@ -34,7 +37,10 @@ public static function main()
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('Text_PathNavigator package');
- $suite->addTestSuite('PathNavigatorTest');
+
+ $dir = new GlobIterator(dirname(__FILE__) . '/*Test.php');
+ $suite->addTestFiles($dir);
+
return $suite;
}
}
@@ -43,4 +49,4 @@ public static function suite()
Text_PathNavigator_AllTests::main();
}
-?>
+?>
View
11 Text/tests/PathNavigatorTest.php → tests/PathNavigatorTest.php
@@ -13,7 +13,16 @@
* @link http://pear.php.net/package/Text_PathNavigator
*/
-require_once 'PHPUnit/Framework/TestCase.php';
+if ($fp = @fopen('PHPUnit/Autoload.php', 'r', true)) {
+ require_once 'PHPUnit/Autoload.php';
+} elseif ($fp = @fopen('PHPUnit/Framework.php', 'r', true)) {
+ require_once 'PHPUnit/Framework.php';
+ require_once 'PHPUnit/TextUI/TestRunner.php';
+} else {
+ die('skip could not find PHPUnit');
+}
+fclose($fp);
+
require_once 'Text/PathNavigator.php';
class PathNavigatorTest extends PHPUnit_Framework_TestCase {

0 comments on commit 79db783

Please sign in to comment.