Pluf Framework

Pluf Framework Git Source Tree

Root/tests/runAllTests.php

1<?php
2/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3/*
4# ***** BEGIN LICENSE BLOCK *****
5# This file is part of Plume Framework, a simple PHP Application Framework.
6# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
7#
8# Plume Framework is free software; you can redistribute it and/or modify
9# it under the terms of the GNU Lesser General Public License as published by
10# the Free Software Foundation; either version 2.1 of the License, or
11# (at your option) any later version.
12#
13# Plume Framework is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Lesser General Public License for more details.
17#
18# You should have received a copy of the GNU Lesser General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21#
22# ***** END LICENSE BLOCK ***** */
23
24
25/**
26 * Run all the unit tests of the Plume Framework.
27 */
28
29if (!defined('PHPUnit_MAIN_METHOD')) {
30 define('PHPUnit_MAIN_METHOD', 'Framework_AllTests::main');
31}
32
33if (!defined('PHPUnit_INSIDE_OWN_TESTSUITE')) {
34 define('PHPUnit_INSIDE_OWN_TESTSUITE', TRUE);
35}
36
37require_once 'PHPUnit/Framework.php';
38require_once 'PHPUnit/TextUI/TestRunner.php';
39require_once 'PHPUnit/Framework/TestCase.php';
40
41#require_once 'Framework/AllTests.php';
42
43#require_once 'PHPUnit/Framework/TestSuite.php';
44#require_once 'PHPUnit/TextUI/TestRunner.php';
45#require_once 'PHPUnit/Util/Filter.php';
46
47error_reporting(E_ALL | E_STRICT);
48putenv('TZ=UTC');
49
50function getTestDirs($dir='./')
51{
52 $file = new DirectoryIterator($dir);
53 $res = array();
54 while ($file->valid()) {
55 if ($file->isDir() && !$file->isDot()) {
56 $res[] = $file->getPathName();
57 }
58 $file->next();
59 }
60 return $res;
61}
62
63function getTestFiles($dir='')
64{
65 $file = new DirectoryIterator($dir);
66 $res = array();
67 while ($file->valid()) {
68 if ($file->isFile() && substr($file->getPathName(), -8) == 'Test.php') {
69 $res[] = $file->getPathName();
70 }
71 $file->next();
72 }
73 return $res;
74}
75
76
77class Framework_AllTests
78{
79 public static function main()
80 {
81 PHPUnit_TextUI_TestRunner::run(self::suite());
82 }
83
84 public static function suite()
85 {
86 $suite = new PHPUnit_Framework_TestSuite('Plume_Framework_Test');
87 $dirs = getTestDirs();
88 foreach ($dirs as $dir) {
89 $testfiles = getTestFiles($dir);
90 foreach ($testfiles as $test) {
91 $suite->addTestFile(substr($test, 2));
92 }
93 }
94 return $suite;
95 }
96}
97
98if (PHPUnit_MAIN_METHOD == 'Framework_AllTests::main') {
99 Framework_AllTests::main();
100}
101
102
103//print $tests." tests performed.\n";
104?>

Archive Download this file

Branches

Tags