Skip to content

Commit e106b62

Browse files
committed
add AllTests.php for XML_Parser
git-svn-id: https://svn.php.net/repository/pear/packages/XML_Parser/trunk@274147 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 532eee2 commit e106b62

File tree

3 files changed

+134
-0
lines changed

3 files changed

+134
-0
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Furthermore its now possible to split the parser from the handler object, so you
6363
<file role="php" name="Simple.php"/>
6464
</dir> <!-- /Parser -->
6565
<dir name="tests">
66+
<file role="test" name="AllTests.php"/>
6667
<file role="test" name="001.phpt"/>
6768
<file role="test" name="002.phpt"/>
6869
<file role="test" name="003.phpt"/>

package2.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Furthermore its now possible to split the parser from the handler object, so you
6868
<file baseinstalldir="XML" name="Simple.php" role="php" />
6969
</dir> <!-- /Parser -->
7070
<dir name="tests">
71+
<file baseinstalldir="XML" name="AllTests.php" role="test" />
7172
<file baseinstalldir="XML" name="001.phpt" role="test" />
7273
<file baseinstalldir="XML" name="002.phpt" role="test" />
7374
<file baseinstalldir="XML" name="003.phpt" role="test" />

tests/AllTests.php

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?php
2+
3+
/**
4+
* Master Unit Test Suite file for XML_Parser
5+
*
6+
* This top-level test suite file organizes
7+
* all class test suite files,
8+
* so that the full suite can be run
9+
* by PhpUnit or via "pear run-tests -u".
10+
*
11+
* PHP version 5
12+
*
13+
* @category XML
14+
* @package XML_Parser
15+
* @subpackage UnitTesting
16+
* @author Chuck Burgess <[email protected]>
17+
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
18+
* @version CVS: $Id$
19+
* @link http://pear.php.net/package/XML_Parser
20+
* @since 1.3.2
21+
*/
22+
23+
24+
/**
25+
* Check PHP version... PhpUnit v3+ requires at least PHP v5.1.4
26+
*/
27+
if (version_compare(PHP_VERSION, "5.1.4") < 0) {
28+
// Cannnot run test suites
29+
echo 'Cannot run test suite via PhpUnit... requires at least PHP v5.1.4.' . PHP_EOL;
30+
echo 'Use "pear run-tests -p xml_util" to run the PHPT tests directly.' . PHP_EOL
31+
;
32+
exit(1);
33+
}
34+
35+
36+
/**
37+
* Derive the "main" method name
38+
* @internal PhpUnit would have to rename PHPUnit_MAIN_METHOD to PHPUNIT_MAIN_METHOD
39+
* to make this usage meet the PEAR CS... we cannot rename it here.
40+
*/
41+
if (!defined('PHPUnit_MAIN_METHOD')) {
42+
define('PHPUnit_MAIN_METHOD', 'XML_Parser_AllTests::main');
43+
}
44+
45+
46+
/*
47+
* Files needed by PhpUnit
48+
*/
49+
require_once 'PHPUnit/Framework.php';
50+
require_once 'PHPUnit/TextUI/TestRunner.php';
51+
require_once 'PHPUnit/Extensions/PhptTestSuite.php';
52+
53+
/*
54+
* You must add each additional class-level test suite file here
55+
*/
56+
// there are no PhpUnit test files... only PHPTs.. so nothing is listed here
57+
58+
/**
59+
* directory where PHPT tests are located
60+
*/
61+
define('XML_PARSER_DIR_PHPT', dirname(__FILE__));
62+
63+
/**
64+
* Master Unit Test Suite class for XML_Parser
65+
*
66+
* This top-level test suite class organizes
67+
* all class test suite files,
68+
* so that the full suite can be run
69+
* by PhpUnit or via "pear run-tests -up xml_util".
70+
*
71+
* @category XML
72+
* @package XML_Parser
73+
* @subpackage UnitTesting
74+
* @author Chuck Burgess <[email protected]>
75+
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
76+
* @version Release: @package_version@
77+
* @link http://pear.php.net/package/XML_Parser
78+
* @since 1.2.0a1
79+
*/
80+
class XML_Parser_AllTests
81+
{
82+
83+
/**
84+
* Launches the TextUI test runner
85+
*
86+
* @return void
87+
* @uses PHPUnit_TextUI_TestRunner
88+
*/
89+
public static function main()
90+
{
91+
PHPUnit_TextUI_TestRunner::run(self::suite());
92+
}
93+
94+
95+
/**
96+
* Adds all class test suites into the master suite
97+
*
98+
* @return PHPUnit_Framework_TestSuite a master test suite
99+
* containing all class test suites
100+
* @uses PHPUnit_Framework_TestSuite
101+
*/
102+
public static function suite()
103+
{
104+
$suite = new PHPUnit_Framework_TestSuite(
105+
'XML_Parser Full Suite of Unit Tests');
106+
107+
/*
108+
* You must add each additional class-level test suite name here
109+
*/
110+
// there are no PhpUnit test files... only PHPTs.. so nothing is listed here
111+
112+
/*
113+
* add PHPT tests
114+
*/
115+
$phpt = new PHPUnit_Extensions_PhptTestSuite(XML_PARSER_DIR_PHPT);
116+
$suite->addTestSuite($phpt);
117+
118+
return $suite;
119+
}
120+
}
121+
122+
/**
123+
* Call the main method if this file is executed directly
124+
* @internal PhpUnit would have to rename PHPUnit_MAIN_METHOD to PHPUNIT_MAIN_METHOD
125+
* to make this usage meet the PEAR CS... we cannot rename it here.
126+
*/
127+
if (PHPUnit_MAIN_METHOD == 'XML_Parser_AllTests::main') {
128+
XML_Parser_AllTests::main();
129+
}
130+
131+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
132+
?>

0 commit comments

Comments
 (0)