Repository navigation
Expand file tree
/
Copy pathCest.php
More file actions
55 lines (45 loc) · 1.3 KB
/
Copy pathCest.php
File metadata and controls
55 lines (45 loc) · 1.3 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
<?php
namespace Codeception\Test\Loader;
use Codeception\Lib\Parser;
use Codeception\Test\Cest as CestFormat;
use Codeception\Util\Annotation;
class Cest implements LoaderInterface
{
protected $tests = [];
public function getTests()
{
return $this->tests;
}
public function getPattern()
{
return '~Cest\.php$~';
}
public function loadTests($file)
{
Parser::load($file);
$testClasses = Parser::getClassesFromFile($file);
foreach ($testClasses as $testClass) {
if (substr($testClass, -strlen('Cest')) !== 'Cest') {
continue;
}
if (!(new \ReflectionClass($testClass))->isInstantiable()) {
continue;
}
$unit = new $testClass;
$methods = get_class_methods($testClass);
foreach ($methods as $method) {
$test = $this->createTestForMethod($unit, $method, $file);
if ($test) {
$this->tests[] = $test;
}
}
}
}
protected function createTestForMethod($cestInstance, $methodName, $file)
{
if (strpos($methodName, '_') === 0) {
return null;
}
return new CestFormat($cestInstance, $methodName, $file);
}
}