1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) Enalean, 2012. All Rights Reserved. |
4
|
|
|
* |
5
|
|
|
* This file is a part of Tuleap. |
6
|
|
|
* |
7
|
|
|
* Tuleap is free software; you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* Tuleap is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License |
18
|
|
|
* along with Tuleap. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
require_once dirname(__FILE__) . '/simpletest/test_case.php'; |
22
|
|
|
|
23
|
|
|
class TestsPluginOrderedSuite extends TestSuite { |
24
|
|
|
|
25
|
|
|
protected $testPaths = array(); |
26
|
|
|
|
27
|
|
|
public function runByOrder(&$reporter, $order) { |
28
|
|
|
$this->addTestFiles(); |
29
|
|
|
if ($order === 'invert') { |
30
|
|
|
$this->_test_cases = array_reverse($this->_test_cases); |
31
|
|
|
} elseif ($order === 'random') { |
32
|
|
|
shuffle($this->_test_cases); |
33
|
|
|
} |
34
|
|
|
$reporter->paintGroupStart($this->getLabel(), $this->getSize()); |
35
|
|
|
for ($i = 0, $count = count($this->_test_cases); $i < $count; $i++) { |
36
|
|
|
if (is_string($this->_test_cases[$i])) { |
37
|
|
|
$class = $this->_test_cases[$i]; |
38
|
|
|
$test = new $class(); |
39
|
|
|
$test->run($reporter); |
40
|
|
|
unset($test); |
41
|
|
|
} elseif (get_class($this->_test_cases[$i]) === __CLASS__) { |
42
|
|
|
$this->_test_cases[$i]->runByOrder($reporter, $order); |
43
|
|
|
} else { |
44
|
|
|
$this->_test_cases[$i]->run($reporter); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
$reporter->paintGroupEnd($this->getLabel()); |
48
|
|
|
return $reporter->getStatus(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
protected function addTestFiles() { |
52
|
|
|
foreach ($this->testPaths as $testPath) { |
53
|
|
|
parent::addFile($testPath); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function addFile($testPath) { |
58
|
|
|
$this->testPaths[] = $testPath; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
?> |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.