4
4
5
5
use Matthias \SymfonyServiceDefinitionValidator \ArgumentValidator ;
6
6
use Matthias \SymfonyServiceDefinitionValidator \Exception \TypeHintMismatchException ;
7
+ use PHPUnit \Framework \TestCase ;
7
8
use Symfony \Component \DependencyInjection \ContainerBuilder ;
8
9
use Symfony \Component \DependencyInjection \Definition ;
9
10
use Symfony \Component \DependencyInjection \Reference ;
10
11
use Symfony \Component \ExpressionLanguage \Expression ;
11
12
12
- class ArgumentValidatorTest extends \PHPUnit_Framework_TestCase
13
+ class ArgumentValidatorTest extends TestCase
13
14
{
14
15
private $ containerBuilder ;
15
16
16
- protected function setUp ()
17
+ protected function setUp (): void
17
18
{
18
19
$ this ->containerBuilder = new ContainerBuilder ();
19
20
}
@@ -24,7 +25,7 @@ public function testFailsWhenParameterHasTypeHintButNoReferenceOrDefinitionWasPr
24
25
25
26
$ validator = new ArgumentValidator ($ this ->containerBuilder , $ this ->createMockResultingClassResolver ());
26
27
27
- $ this ->setExpectedException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'reference ' );
28
+ $ this ->expectException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'reference ' );
28
29
$ validator ->validate (new \ReflectionParameter (array ($ class , '__construct ' ), 'expected ' ), new \stdClass ());
29
30
}
30
31
@@ -43,7 +44,7 @@ public function testFailsWhenParameterHasTypeHintForObjectButArgumentIsDefinitio
43
44
->will ($ this ->returnValue ('Matthias\SymfonyServiceDefinitionValidator\Tests\Fixtures\WrongClass ' ));
44
45
$ validator = new ArgumentValidator ($ this ->containerBuilder , $ resultingClassResolver );
45
46
46
- $ this ->setExpectedException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'ExpectedClass ' );
47
+ $ this ->expectException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'ExpectedClass ' );
47
48
$ validator ->validate (new \ReflectionParameter (array ($ class , '__construct ' ), 'expected ' ), $ inlineDefinition );
48
49
}
49
50
@@ -65,7 +66,7 @@ public function testFailsWhenParameterHasTypeHintForObjectButArgumentIsReference
65
66
->will ($ this ->returnValue ('stdClass ' ));
66
67
$ validator = new ArgumentValidator ($ this ->containerBuilder , $ resultingClassResolver );
67
68
68
- $ this ->setExpectedException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'ExpectedClass ' );
69
+ $ this ->expectException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'ExpectedClass ' );
69
70
70
71
$ validator ->validate ($ parameter , $ argument );
71
72
}
@@ -79,7 +80,7 @@ public function testFailsWhenParameterHasArrayTypeHintButArgumentIsNotArray()
79
80
80
81
$ validator = new ArgumentValidator (new ContainerBuilder (), $ this ->createMockResultingClassResolver ());
81
82
82
- $ this ->setExpectedException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'array ' );
83
+ $ this ->expectException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'array ' );
83
84
84
85
$ validator ->validate ($ parameter , $ argument );
85
86
}
@@ -114,7 +115,7 @@ public function testFailsWhenResultOfExpressionIsNotAnObjectOfTheExpectedClass()
114
115
115
116
$ validator = new ArgumentValidator ($ containerBuilder , $ this ->createMockResultingClassResolver (), true );
116
117
117
- $ this ->setExpectedException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'ExpectedClass ' );
118
+ $ this ->expectException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'ExpectedClass ' );
118
119
119
120
$ validator ->validate ($ parameter , $ argument );
120
121
}
@@ -130,7 +131,7 @@ public function testFailsWhenResultOfExpressionIsNotAnObject()
130
131
131
132
$ validator = new ArgumentValidator (new ContainerBuilder (), $ this ->createMockResultingClassResolver (), true );
132
133
133
- $ this ->setExpectedException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'ExpectedClass ' );
134
+ $ this ->expectException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'ExpectedClass ' );
134
135
135
136
$ validator ->validate ($ parameter , $ argument );
136
137
}
@@ -164,7 +165,7 @@ public function testFailsIfSyntaxOfExpressionIsInvalid()
164
165
165
166
$ validator = new ArgumentValidator (new ContainerBuilder (), $ this ->createMockResultingClassResolver ());
166
167
167
- $ this ->setExpectedException ('Matthias\SymfonyServiceDefinitionValidator\Exception\InvalidExpressionSyntaxException ' );
168
+ $ this ->expectException ('Matthias\SymfonyServiceDefinitionValidator\Exception\InvalidExpressionSyntaxException ' );
168
169
169
170
$ validator ->validate ($ parameter , $ argument );
170
171
}
@@ -180,7 +181,7 @@ public function testFailsIfExpressionCouldNotBeEvaluated()
180
181
181
182
$ validator = new ArgumentValidator (new ContainerBuilder (), $ this ->createMockResultingClassResolver (), true );
182
183
183
- $ this ->setExpectedException ('Matthias\SymfonyServiceDefinitionValidator\Exception\InvalidExpressionException ' );
184
+ $ this ->expectException ('Matthias\SymfonyServiceDefinitionValidator\Exception\InvalidExpressionException ' );
184
185
185
186
$ validator ->validate ($ parameter , $ argument );
186
187
}
@@ -231,14 +232,14 @@ public function testFailsIfContainerReferenceArgumentIsInjectedForParameterWithI
231
232
->willReturn ('Symfony\Component\DependencyInjection\Container ' );
232
233
$ validator = new ArgumentValidator (new ContainerBuilder (), $ classResolver );
233
234
234
- $ this ->setExpectedException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'ExpectedClass ' );
235
+ $ this ->expectException ('Matthias\SymfonyServiceDefinitionValidator\Exception\TypeHintMismatchException ' , 'ExpectedClass ' );
235
236
236
237
$ validator ->validate ($ parameter , $ argument );
237
238
}
238
239
239
240
private function createMockResultingClassResolver ()
240
241
{
241
- return $ this ->getMock ('Matthias\SymfonyServiceDefinitionValidator\ResultingClassResolverInterface ' );
242
+ return $ this ->createMock ('Matthias\SymfonyServiceDefinitionValidator\ResultingClassResolverInterface ' );
242
243
}
243
244
244
245
private function skipTestIfExpressionsAreNotAvailable ()
0 commit comments