Permalink
Browse files

Get test suite working with modern PHPUnit installs.

git-svn-id: http://svn.php.net/repository/pear/packages/PhpDocumentor/trunk@321507 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
Daniel Convissor
Daniel Convissor committed Dec 29, 2011
1 parent a7df2bc commit 12fbfda2fd7d89c610ae150fb9d6f85339502f15
View
@@ -1439,19 +1439,16 @@ Includes these Sourceforge items:
</dir> <!-- /scripts -->
<dir name="tests">
<file baseinstalldir="PhpDocumentor" name="AllTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="HighlightParserGetInlineTagsTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="HighlightParserTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="IntermediateParserAddPrivatePageTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="IntermediateParserTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="ParserClassGetSourceLocationTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="ParserClassTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="ParserPageGetSourceLocationTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="ParserPageTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="phpDocumentorSetupCleanConverterNamePieceTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="phpDocumentorSetupDecideOnOrOffTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="phpDocumentorSetupTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="phpDocumentorTParserGetInlineTagsTests.php" role="test" />
- <file baseinstalldir="PhpDocumentor" name="phpDocumentorTParserTests.php" role="test" />
+ <file baseinstalldir="PhpDocumentor" name="HighlightParserGetInlineTagsTest.php" role="test" />
+ <file baseinstalldir="PhpDocumentor" name="IntermediateParserAddPrivatePageTest.php" role="test" />
+ <file baseinstalldir="PhpDocumentor" name="ParserClassGetSourceLocationTest.php" role="test" />
+ <file baseinstalldir="PhpDocumentor" name="ParserPageGetSourceLocationTest.php" role="test" />
+ <file baseinstalldir="PhpDocumentor" name="SetupCleanConverterNamePieceTest.php" role="test" />
+ <file baseinstalldir="PhpDocumentor" name="SetupDecideOnOrOffTest.php" role="test" />
+ <file baseinstalldir="PhpDocumentor" name="TParserGetInlineTagsTest.php" role="test" />
+ <file baseinstalldir="PhpDocumentor" name="helper.inc" role="test">
+ <tasks:replace from="@php_dir@" to="php_dir" type="pear-config" />
+ </file>
</dir> <!-- /tests -->
<dir name="tutorials">
<dir name="Converters">
@@ -3245,4 +3242,4 @@ Includes these Sourceforge items:
</notes>
</release>
</changelog>
-</package>
+</package>
View
@@ -3,10 +3,13 @@
/**
* Master Unit Test Suite file for PhpDocumentor
*
- * This top-level test suite file organizes
- * all class test suite files,
- * so that the full suite can be run
- * by PhpUnit or via "pear run-tests -u".
+ * This top-level test suite file organizes all class test suite files,
+ * so that the full suite can be run by calling:
+ * php -d error_reporting=22527 tests/AllTests.php
+ *
+ * But modern versions of PHPUnit don't need the AllTests file. Just cd
+ * into the directory above "tests" and call:
+ * phpunit -d error_reporting=22527 tests
*
* PHP versions 4 and 5
*
@@ -21,45 +24,22 @@
* @todo CS cleanup - change package to PhpDocumentor
*/
-
-/**
- * Check PHP version... PhpUnit v3+ requires at least PHP v5.1.4
- */
-if (version_compare(PHP_VERSION, "5.1.4") < 0) {
- // Cannnot run test suites
- echo "Cannot run test suites... requires at least PHP v5.1.4.\n";
- exit(1);
-}
-
-
/**
- * Derive the "main" method name
- * @internal PhpUnit would have to rename PHPUnit_MAIN_METHOD to PHPUNIT_MAIN_METHOD
- * to make this usage meet the PEAR CS... we cannot rename it here.
+ * Obtain the helper file.
*/
-if (!defined('PHPUnit_MAIN_METHOD')) {
- define('PHPUnit_MAIN_METHOD', 'PhpDocumentor_AllTests::main');
+require_once dirname(__FILE__) . '/helper.inc';
+
+// 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', 'PhpDocumentor_AllTests::main');
+ $call_main = true;
+ }
}
-
-/*
- * Files needed by PhpUnit
- */
-require_once 'PHPUnit/Framework.php';
-require_once 'PHPUnit/TextUI/TestRunner.php';
-
-
-/*
- * You must add each additional class-level test suite file here
- */
-require_once 'phpDocumentorSetupTests.php';
-require_once 'phpDocumentorTParserTests.php';
-require_once 'IntermediateParserTests.php';
-require_once 'HighlightParserTests.php';
-require_once 'ParserClassTests.php';
-require_once 'ParserPageTests.php';
-
-
/**
* Master Unit Test Suite class for PhpDocumentor
*
@@ -80,7 +60,6 @@
*/
class PhpDocumentor_AllTests
{
-
/**
* Launches the TextUI test runner
*
@@ -92,7 +71,6 @@ public static function main()
PHPUnit_TextUI_TestRunner::run(self::suite());
}
-
/**
* Adds all class test suites into the master suite
*
@@ -105,27 +83,13 @@ public static function suite()
$suite = new PHPUnit_Framework_TestSuite(
'PhpDocumentor Full Suite of Unit Tests');
- /*
- * You must add each additional class-level test suite name here
- */
- $suite->addTest(tests_phpDocumentorSetupTests::suite());
- $suite->addTest(tests_phpDocumentorTParserTests::suite());
- $suite->addTest(tests_IntermediateParserTests::suite());
- $suite->addTest(tests_HighlightParserTests::suite());
- $suite->addTest(tests_ParserClassTests::suite());
- $suite->addTest(tests_ParserPageTests::suite());
+ $dir = new GlobIterator(dirname(__FILE__) . '/*Test.php');
+ $suite->addTestFiles($dir);
+
return $suite;
}
}
-/**
- * Call the main method if this file is executed directly
- * @internal PhpUnit would have to rename PHPUnit_MAIN_METHOD to PHPUNIT_MAIN_METHOD
- * to make this usage meet the PEAR CS... we cannot rename it here.
- */
-if (PHPUnit_MAIN_METHOD == 'PhpDocumentor_AllTests::main') {
+if ($call_main) {
PhpDocumentor_AllTests::main();
}
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-?>
@@ -8,47 +8,9 @@
*/
/**
- * PHPUnit main() hack
- *
- * "Call class::main() if this source file is executed directly."
- * @since 1.4.0a2
- */
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "HighlightParserGetInlineTagsTests::main");
-}
-/**
- * TestCase
- *
- * required by PHPUnit
- * @since 1.4.0a2
- */
-require_once "PHPUnit/Framework/TestCase.php";
-/**
- * TestSuite
- *
- * required by PHPUnit
- * @since 1.4.0a2
+ * Obtain the helper file.
*/
-require_once "PHPUnit/Framework/TestSuite.php";
-
-/**
- * Base directory of code
- *
- * Needed by some of the objects being tested in the suites.
- * @since 1.4.1
- */
-chdir(dirname(dirname(__FILE__)));
-if (!defined("PHPDOCUMENTOR_BASE")) {
- define("PHPDOCUMENTOR_BASE", dirname(dirname(__FILE__)));
-}
-
-/**
- * PhpDocumentor Setup
- *
- * required by PhpDocumentor to instantiate the environment
- * @since 1.4.0a2
- */
-require_once 'phpDocumentor/Setup.inc.php';
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Unit Testing of the HighlightParser's getInlineTags() method
@@ -57,34 +19,21 @@
* @author Chuck Burgess
* @since 1.4.0a2
*/
-class tests_HighlightParserGetInlineTagsTests extends PHPUnit_Framework_TestCase {
+class HighlightParserGetInlineTagsTest extends PHPUnit_Framework_TestCase {
/**
- * phpDocumentor_setup object
+ * @var phpDocumentor_setup
* @access private
* @since 1.4.0a2
*/
private $ps;
/**
- * phpDocumentor_HighlightParser object
+ * @var phpDocumentor_HighlightParser
* @access private
* @since 1.4.0a2
*/
private $hp;
- /**
- * Runs the test methods of this class.
- * @access public
- * @static
- * @since 1.4.0a2
- */
- public static function main() {
- require_once "PHPUnit/TextUI/TestRunner.php";
-
- $suite = new PHPUnit_Framework_TestSuite("tests_HighlightParserGetInlineTagsTests");
- $result = PHPUnit_TextUI_TestRunner::run($suite);
- }
-
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
@@ -169,13 +118,3 @@ public function testShowCorrectBehaviorWhenGivenOneEmptyArgAndTrue() {
* END OF "NOW LIST THE TEST CASES" ----------------------------------------------|
*/
}
-
-/**
- * PHPUnit main() hack
- * "Call class::main() if this source file is executed directly."
- * @since 1.4.0a2
- */
-if (PHPUnit_MAIN_METHOD == "HighlightParserGetInlineTagsTests::main") {
- tests_HighlightParserGetInlineTagsTests::main();
-}
-?>
@@ -1,31 +0,0 @@
-<?php
-if (!defined('PHPUnit_MAIN_METHOD')) {
- define('PHPUnit_MAIN_METHOD', 'HighlightParserTests::main');
-}
-
-require_once 'PHPUnit/Framework.php';
-require_once 'PHPUnit/TextUI/TestRunner.php';
-
-/* You must add each method-level test suite file here */
-require_once 'HighlightParserGetInlineTagsTests.php';
-
-class tests_HighlightParserTests
-{
- public static function main()
- {
- PHPUnit_TextUI_TestRunner::run(self::suite());
- }
-
- public static function suite()
- {
- $suite = new PHPUnit_Framework_TestSuite('HighlightParser Unit Test Suites');
- /* You must add each method-level test suite name here */
- $suite->addTestSuite('tests_HighlightParserGetInlineTagsTests');
- return $suite;
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'HighlightParserTests::main') {
- tests_HighlightParserTests::main();
-}
-?>
Oops, something went wrong.

0 comments on commit 12fbfda

Please sign in to comment.