run-tests.php
1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
* PHPTAL templating engine
*
* PHP Version 5
*
* @category HTML
* @package PHPTAL
* @author Laurent Bedubourg <lbedubourg@motion-twin.com>
* @author Kornel Lesiński <kornel@aardvarkmedia.co.uk>
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
* @version SVN: $Id: run-tests.php 714 2009-09-12 00:26:42Z kornel $
* @link http://phptal.org/
*/
//require_once 'PHPUnit/Framework/Test.php';
//require_once 'PHPUnit/Framework/TestCase.php';
//require_once 'PHPUnit/Framework/TestSuite.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
error_reporting( E_ALL | E_STRICT );
assert_options(ASSERT_ACTIVE,1);
chdir(dirname(__FILE__));
require_once "./config.php";
if (isset($argv) && count($argv) >= 2) {
array_shift($argv);
foreach ($argv as $entry) {
echo "-> running standalone test units $entry\n";
try
{
require_once $entry;
$class = str_replace('.php', '', $entry);
$class = basename($class);
$printer = new PHPUnit_TextUI_ResultPrinter();
$result = new PHPUnit_Framework_TestResult();
$result->addListener($printer);
$testclass = new ReflectionClass($class);
$suite = new PHPUnit_Framework_TestSuite($testclass);
$runner = new PHPUnit_TextUI_TestRunner();
$runner->doRun($suite);
}
catch(Exception $e)
{
echo "Exception during execution of $entry: ".$e->getMessage()."\n\n";
}
}
exit(0);
}
$alltests = new PHPUnit_Framework_TestSuite();
foreach (new DirectoryIterator( dirname(__FILE__) ) as $f) {
if ($f->isDot() || !$f->isFile()) continue;
if (preg_match('/(.*?Test).php$/', $f->getFileName(), $m)) {
require_once $f->getPathName();
$alltests->addTestSuite(new PHPUnit_Framework_TestSuite($m[1]));
}
}
$runner = new PHPUnit_TextUI_TestRunner();
$runner->doRun($alltests);