@@ -15,26 +15,30 @@ class TestInspector
15
15
protected array $ classOptions = [];
16
16
17
17
private TestRun $ testRun ;
18
+ private TestTrace $ testTrace ;
19
+ private Annotations $ annotations ;
18
20
19
21
protected array $ ignore ;
20
22
21
- public function __construct (TestRun $ testRun , array $ config )
23
+ public function __construct (TestRun $ testRun , TestTrace $ testTrace , Annotations $ annotations , array $ config )
22
24
{
23
25
$ this ->testRun = $ testRun ;
26
+ $ this ->testTrace = $ testTrace ;
27
+ $ this ->annotations = $ annotations ;
24
28
$ this ->ignore = $ config ['ignore ' ];
25
29
}
26
30
27
31
public function getCurrentTestInfo (): TestInfo
28
32
{
29
- $ trace = TestTrace:: get ();
33
+ $ trace = $ this -> testTrace -> get ();
30
34
31
- $ info = $ this ->getInfo ($ trace-> className , $ trace-> methodName );
35
+ $ info = $ this ->getInfo ($ trace[ ' class ' ] , $ trace[ ' function ' ] );
32
36
33
37
if ($ info ->isIgnored ()) {
34
38
return $ info ;
35
39
}
36
40
37
- return $ info ->addLine ($ trace-> line );
41
+ return $ info ->addLine ($ trace[ ' line ' ] );
38
42
}
39
43
40
44
public function getInfo ($ className , $ methodName ): TestInfo
@@ -50,7 +54,7 @@ protected function makeTestMethodInfo(string $className, string $methodName): Te
50
54
{
51
55
$ testClassInfo = $ this ->getClassInfo ($ className );
52
56
53
- $ annotations = Annotations:: fromMethod ($ className , $ methodName );
57
+ $ annotations = $ this -> annotations -> getFromMethod ($ className , $ methodName );
54
58
55
59
if ($ this ->ignoreTest ($ className , $ methodName , $ annotations ->get ('enlighten ' , []))) {
56
60
return new IgnoredTest ($ className , $ methodName );
@@ -70,7 +74,7 @@ private function getClassInfo($className): TestClassInfo
70
74
71
75
private function makeTestClassInfo ($ name ): TestClassInfo
72
76
{
73
- $ annotations = Annotations:: fromClass ($ name );
77
+ $ annotations = $ this -> annotations -> getFromClass ($ name );
74
78
75
79
$ this ->classOptions = $ annotations ->get ('enlighten ' , []);
76
80
@@ -80,7 +84,7 @@ private function makeTestClassInfo($name): TestClassInfo
80
84
protected function getTextsFrom (Collection $ annotations ): array
81
85
{
82
86
return [
83
- 'title ' => $ annotations ->get ('testdox ' ),
87
+ 'title ' => $ annotations ->get ('title ' ) ?: $ annotations -> get ( ' testdox ' ),
84
88
'description ' => $ annotations ->get ('description ' ),
85
89
];
86
90
}
0 commit comments