Permalink
Browse files

Final fixes to get AllTests running via direct php call.

git-svn-id: http://svn.php.net/repository/pear/packages/HTTP_Download/trunk@320871 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent fa79871 commit 8ab426a0f11ece11f888570d226ae30ac4d85b5c Daniel Convissor committed Dec 11, 2011
Showing with 13 additions and 7 deletions.
  1. +13 −7 tests/AllTests.php
View
@@ -1,12 +1,18 @@
<?php
-require_once dirname(__FILE__) . '/helper.inc';
-
-if (!defined('PHPUnit_MAIN_METHOD')) {
- define('PHPUnit_MAIN_METHOD', 'HTML_Download_AllTests::main');
+// Keep tests from running twice when calling this file directly via PHPUnit.
+$call_main = false;
+if (strpos($_SERVER['argv'][0], 'phpunit') === false) {
+ // Called via php, not PHPUnit. Pass the request to PHPUnit.
+ if (!defined('PHPUnit_MAIN_METHOD')) {
+ /** The test's main method name */
+ define('PHPUnit_MAIN_METHOD', 'HTML_Download_AllTests::main');
+ $call_main = true;
+ }
}
-require_once dirname(__FILE__) . '/HTML_DownloadTest.php';
+require_once dirname(__FILE__) . '/helper.inc';
+require_once dirname(__FILE__) . '/HTTP_DownloadTest.php';
class HTML_Download_AllTests
{
@@ -19,12 +25,12 @@ public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('PEAR - HTML_Download');
- $suite->addTestSuite('HTML_DownloadTest');
+ $suite->addTestSuite('HTTP_DownloadTest');
return $suite;
}
}
-if (PHPUnit_MAIN_METHOD == 'HTML_Download_AllTests::main') {
+if ($call_main) {
HTML_Download_AllTests::main();
}

0 comments on commit 8ab426a

Please sign in to comment.