7
7
* For the full copyright and license information, please view the LICENSE
8
8
* file that was distributed with this source code.
9
9
*/
10
- use PHPUnit \Framework \MockObject \Generator ;
11
- use PHPUnit \Framework \MockObject \MockObject ;
10
+ namespace PHPUnit \Framework \MockObject ;
11
+
12
+ use function class_exists ;
13
+ use function md5 ;
14
+ use function method_exists ;
15
+ use function microtime ;
16
+ use AbstractMockTestClass ;
17
+ use AbstractTrait ;
18
+ use AnInterface ;
19
+ use AnInterfaceWithReturnType ;
20
+ use ClassWithVariadicArgumentMethod ;
21
+ use Countable ;
22
+ use Exception ;
23
+ use ExceptionWithThrowable ;
24
+ use FinalClass ;
25
+ use InterfaceWithSemiReservedMethodName ;
12
26
use PHPUnit \Framework \TestCase ;
27
+ use SingletonClass ;
28
+ use stdClass ;
29
+ use Throwable ;
13
30
14
31
/**
15
32
* @covers \PHPUnit\Framework\MockObject\Generator
@@ -62,7 +79,7 @@ public function testGetMockThrowsExceptionWithNonExistingClass(): void
62
79
{
63
80
$ this ->expectException (\PHPUnit \Framework \MockObject \RuntimeException::class);
64
81
65
- $ this ->assertFalse (\ class_exists ('Tux ' ));
82
+ $ this ->assertFalse (class_exists ('Tux ' ));
66
83
67
84
$ this ->generator ->getMock ('Tux ' , [], [], '' , true , true , false , true , false , null , false );
68
85
}
@@ -71,7 +88,7 @@ public function testGetMockThrowsExceptionWithNonExistingClasses(): void
71
88
{
72
89
$ this ->expectException (\PHPUnit \Framework \MockObject \RuntimeException::class);
73
90
74
- $ this ->assertFalse (\ class_exists ('Tux ' ));
91
+ $ this ->assertFalse (class_exists ('Tux ' ));
75
92
76
93
$ this ->generator ->getMock (['Tux ' , false ], [], [], '' , true , true , false , true , false , null , false );
77
94
}
@@ -87,7 +104,7 @@ public function testGetMockCanCreateNonExistingFunctions(): void
87
104
{
88
105
$ mock = $ this ->generator ->getMock (stdClass::class, ['testFunction ' ]);
89
106
90
- $ this ->assertTrue (\ method_exists ($ mock , 'testFunction ' ));
107
+ $ this ->assertTrue (method_exists ($ mock , 'testFunction ' ));
91
108
}
92
109
93
110
public function testGetMockGeneratorThrowsException (): void
@@ -102,22 +119,22 @@ public function testGetMockBlacklistedMethodNamesPhp7(): void
102
119
{
103
120
$ mock = $ this ->generator ->getMock (InterfaceWithSemiReservedMethodName::class);
104
121
105
- $ this ->assertTrue (\ method_exists ($ mock , 'unset ' ));
122
+ $ this ->assertTrue (method_exists ($ mock , 'unset ' ));
106
123
$ this ->assertInstanceOf (InterfaceWithSemiReservedMethodName::class, $ mock );
107
124
}
108
125
109
126
public function testGetMockForAbstractClassDoesNotFailWhenFakingInterfaces (): void
110
127
{
111
128
$ mock = $ this ->generator ->getMockForAbstractClass (Countable::class);
112
129
113
- $ this ->assertTrue (\ method_exists ($ mock , 'count ' ));
130
+ $ this ->assertTrue (method_exists ($ mock , 'count ' ));
114
131
}
115
132
116
133
public function testGetMockForAbstractClassStubbingAbstractClass (): void
117
134
{
118
135
$ mock = $ this ->generator ->getMockForAbstractClass (AbstractMockTestClass::class);
119
136
120
- $ this ->assertTrue (\ method_exists ($ mock , 'doSomething ' ));
137
+ $ this ->assertTrue (method_exists ($ mock , 'doSomething ' ));
121
138
}
122
139
123
140
public function testGetMockForAbstractClassWithNonExistentMethods (): void
@@ -132,8 +149,8 @@ public function testGetMockForAbstractClassWithNonExistentMethods(): void
132
149
['nonexistentMethod ' ]
133
150
);
134
151
135
- $ this ->assertTrue (\ method_exists ($ mock , 'nonexistentMethod ' ));
136
- $ this ->assertTrue (\ method_exists ($ mock , 'doSomething ' ));
152
+ $ this ->assertTrue (method_exists ($ mock , 'nonexistentMethod ' ));
153
+ $ this ->assertTrue (method_exists ($ mock , 'doSomething ' ));
137
154
}
138
155
139
156
public function testGetMockForAbstractClassShouldCreateStubsOnlyForAbstractMethodWhenNoMethodsWereInformed (): void
@@ -167,8 +184,8 @@ public function testGetMockForTraitWithNonExistentMethodsAndNonAbstractMethods()
167
184
['nonexistentMethod ' ]
168
185
);
169
186
170
- $ this ->assertTrue (\ method_exists ($ mock , 'nonexistentMethod ' ));
171
- $ this ->assertTrue (\ method_exists ($ mock , 'doSomething ' ));
187
+ $ this ->assertTrue (method_exists ($ mock , 'nonexistentMethod ' ));
188
+ $ this ->assertTrue (method_exists ($ mock , 'doSomething ' ));
172
189
$ this ->assertTrue ($ mock ->mockableMethod ());
173
190
$ this ->assertTrue ($ mock ->anotherMockableMethod ());
174
191
}
@@ -177,7 +194,7 @@ public function testGetMockForTraitStubbingAbstractMethod(): void
177
194
{
178
195
$ mock = $ this ->generator ->getMockForTrait (AbstractTrait::class);
179
196
180
- $ this ->assertTrue (\ method_exists ($ mock , 'doSomething ' ));
197
+ $ this ->assertTrue (method_exists ($ mock , 'doSomething ' ));
181
198
}
182
199
183
200
public function testGetMockForTraitWithNonExistantTrait (): void
@@ -226,7 +243,7 @@ public function testCanImplementInterfacesThatHaveMethodsWithReturnTypes(): void
226
243
227
244
public function testCanConfigureMethodsForDoubleOfNonExistentClass (): void
228
245
{
229
- $ className = 'X ' . \ md5 (\ microtime ());
246
+ $ className = 'X ' . md5 (microtime ());
230
247
231
248
$ mock = $ this ->generator ->getMock ($ className , ['someMethod ' ]);
232
249
@@ -235,7 +252,7 @@ public function testCanConfigureMethodsForDoubleOfNonExistentClass(): void
235
252
236
253
public function testCanInvokeMethodsOfNonExistentClass (): void
237
254
{
238
- $ className = 'X ' . \ md5 (\ microtime ());
255
+ $ className = 'X ' . md5 (microtime ());
239
256
240
257
$ mock = $ this ->generator ->getMock ($ className , ['someMethod ' ]);
241
258
0 commit comments