1 : <?php
2 : /**
3 : * Dictionaries of Old French and Latin
4 : *
5 : * PHP version 5
6 : *
7 : * @category DicFro
8 : * @package Tests
9 : * @author Michel Corne <mcorne@yahoo.com>
10 : * @copyright 2010 Michel Corne
11 : * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
12 : * @version SVN: $Id$
13 : */
14 :
15 : define('APPLICATION_DIR', dirname(__FILE__) . '/../application/');
16 : is_dir(APPLICATION_DIR) or die('Error: invalid application directory!');
17 :
18 : define('APPLICATION_TEST_DIR', dirname(__FILE__) . '/application/');
19 : is_dir(APPLICATION_TEST_DIR) or die('Error: invalid application test directory!');
20 :
21 : defined('PHPUnit_MAIN_METHOD') or define('PHPUnit_MAIN_METHOD', 'AllTests::main');
22 :
23 : // require_once 'PHPUnit/Framework.php';
24 : require_once 'PHPUnit/TextUI/TestRunner.php';
25 : require_once 'Filter.php';
26 : require_once 'Test.php';
27 :
28 : set_include_path(APPLICATION_DIR . PATH_SEPARATOR . get_include_path());
29 :
30 : // removes test directory for test code coverage report
31 : // PHPUnit_Util_Filter::addDirectoryToFilter(dirname(__FILE__), array('.php')); FIX!!!!
32 :
33 : date_default_timezone_set('UTC');
34 :
35 : /**
36 : * Test suite
37 : *
38 : * @category DicFro
39 : * @package Tests
40 : * @author Michel Corne <mcorne@yahoo.com>
41 : * @copyright 2010 Michel Corne
42 : * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
43 : */
44 :
45 : class AllTests
46 : {
47 : /**
48 : * Runs the tests
49 : *
50 : * @param array $files the files to test
51 : * @return void
52 : */
53 : public static function main($files)
54 : {
55 0 : PHPUnit_TextUI_TestRunner::run(self::suite());
56 0 : }
57 :
58 : /**
59 : * Runs the tests
60 : *
61 : * @param array $files the files to test
62 : * @return object the test suite object
63 : */
64 : public static function suite($files)
65 : {
66 0 : $suite = new PHPUnit_Framework_TestSuite('DicFro Tests');
67 :
68 0 : if ($files = Filter::listTestFiles(APPLICATION_DIR, APPLICATION_TEST_DIR)) {
69 0 : $message = "Files to test ...\n" . implode("\n", $files);
70 0 : } else {
71 0 : $message = "No files to test!";
72 : }
73 0 : echo "$message\n\n";
74 :
75 0 : $suite->addTestFiles($files);
76 :
77 0 : return $suite;
78 : }
79 :
80 : /**
81 : * Formats a test title to display
82 : *
83 : * @param string $message the message
84 : * @return string the formatted message
85 : */
86 : public static function printMessage($message)
87 : {
88 106 : return strtoupper("*** error: $message ***");
89 : }
90 : }
91 :
92 : PHPUnit_MAIN_METHOD == 'AllTests::main' and AllTests::main($files);
|