14
14
use PHPUnit \Framework \TestCase ;
15
15
use SebastianBergmann \CodeCoverage \TestFixture \Target \TargetClass ;
16
16
use SebastianBergmann \CodeCoverage \TestFixture \Target \TargetInterface ;
17
+ use SebastianBergmann \CodeCoverage \TestFixture \Target \TraitOne ;
17
18
18
19
#[CoversClass(Target::class)]
19
20
#[CoversClass(Class_::class)]
22
23
#[CoversClass(Function_::class)]
23
24
#[CoversClass(Method::class)]
24
25
#[CoversClass(Namespace_::class)]
26
+ #[CoversClass(Trait_::class)]
25
27
#[Small]
26
28
final class TargetTest extends TestCase
27
29
{
@@ -37,6 +39,7 @@ public function testCanBeClass(): void
37
39
$ this ->assertFalse ($ target ->isFunction ());
38
40
$ this ->assertFalse ($ target ->isMethod ());
39
41
$ this ->assertFalse ($ target ->isNamespace ());
42
+ $ this ->assertFalse ($ target ->isTrait ());
40
43
41
44
$ this ->assertSame ($ className , $ target ->className ());
42
45
$ this ->assertSame ('classes ' , $ target ->key ());
@@ -56,6 +59,7 @@ public function testCanBeClassesThatExtendClass(): void
56
59
$ this ->assertFalse ($ target ->isFunction ());
57
60
$ this ->assertFalse ($ target ->isMethod ());
58
61
$ this ->assertFalse ($ target ->isNamespace ());
62
+ $ this ->assertFalse ($ target ->isTrait ());
59
63
60
64
$ this ->assertSame ($ className , $ target ->className ());
61
65
$ this ->assertSame ('classesThatExtendClass ' , $ target ->key ());
@@ -75,6 +79,7 @@ public function testCanBeClassesThatImplementInterface(): void
75
79
$ this ->assertFalse ($ target ->isFunction ());
76
80
$ this ->assertFalse ($ target ->isMethod ());
77
81
$ this ->assertFalse ($ target ->isNamespace ());
82
+ $ this ->assertFalse ($ target ->isTrait ());
78
83
79
84
$ this ->assertSame ($ interfaceName , $ target ->interfaceName ());
80
85
$ this ->assertSame ('classesThatImplementInterface ' , $ target ->key ());
@@ -94,6 +99,7 @@ public function testCanBeFunction(): void
94
99
$ this ->assertTrue ($ target ->isFunction ());
95
100
$ this ->assertFalse ($ target ->isMethod ());
96
101
$ this ->assertFalse ($ target ->isNamespace ());
102
+ $ this ->assertFalse ($ target ->isTrait ());
97
103
98
104
$ this ->assertSame ($ functionName , $ target ->functionName ());
99
105
$ this ->assertSame ('functions ' , $ target ->key ());
@@ -114,6 +120,7 @@ public function testCanBeMethod(): void
114
120
$ this ->assertFalse ($ target ->isFunction ());
115
121
$ this ->assertTrue ($ target ->isMethod ());
116
122
$ this ->assertFalse ($ target ->isNamespace ());
123
+ $ this ->assertFalse ($ target ->isTrait ());
117
124
118
125
$ this ->assertSame ($ className , $ target ->className ());
119
126
$ this ->assertSame ($ methodName , $ target ->methodName ());
@@ -134,10 +141,31 @@ public function testCanBeNamespace(): void
134
141
$ this ->assertFalse ($ target ->isFunction ());
135
142
$ this ->assertFalse ($ target ->isMethod ());
136
143
$ this ->assertTrue ($ target ->isNamespace ());
144
+ $ this ->assertFalse ($ target ->isTrait ());
137
145
138
146
$ this ->assertSame ($ namespace , $ target ->namespace ());
139
147
$ this ->assertSame ('namespaces ' , $ target ->key ());
140
148
$ this ->assertSame ($ namespace , $ target ->target ());
141
149
$ this ->assertSame ('Namespace ' . $ namespace , $ target ->description ());
142
150
}
151
+
152
+ public function testCanBeTrait (): void
153
+ {
154
+ $ traitName = TraitOne::class;
155
+
156
+ $ target = Target::forTrait ($ traitName );
157
+
158
+ $ this ->assertTrue ($ target ->isTrait ());
159
+ $ this ->assertFalse ($ target ->isClass ());
160
+ $ this ->assertFalse ($ target ->isClassesThatExtendClass ());
161
+ $ this ->assertFalse ($ target ->isClassesThatImplementInterface ());
162
+ $ this ->assertFalse ($ target ->isFunction ());
163
+ $ this ->assertFalse ($ target ->isMethod ());
164
+ $ this ->assertFalse ($ target ->isNamespace ());
165
+
166
+ $ this ->assertSame ($ traitName , $ target ->traitName ());
167
+ $ this ->assertSame ('traits ' , $ target ->key ());
168
+ $ this ->assertSame ($ traitName , $ target ->target ());
169
+ $ this ->assertSame ('Trait ' . $ traitName , $ target ->description ());
170
+ }
143
171
}
0 commit comments