@@ -25,23 +25,23 @@ public function testResolverResolvesFromContainer(): void
25
25
26
26
$ container = $ this ->getMockBuilder (Container::class)->getMock ();
27
27
28
+ $ matcher = $ this ->exactly (2 );
29
+
28
30
$ container
29
- ->expects (self :: at ( 0 ) )
31
+ ->expects ($ matcher )
30
32
->method ('has ' )
31
- ->with (self ::equalTo ('alias1 ' ))
32
- ->willReturn (true )
33
+ ->willReturnOnConsecutiveCalls (true , false )
33
34
;
34
35
35
- $ container ->expects (self ::at (1 ))->method ('get ' )->with (self ::equalTo ('alias1 ' ))->willReturn ($ resolver );
36
- $ container ->expects (self ::at (2 ))->method ('has ' )->with (self ::equalTo ('alias2 ' ))->willReturn (false );
36
+ $ container ->expects ($ this ->once ())->method ('get ' )->with ($ this ->equalTo ('alias1 ' ))->willReturn ($ resolver );
37
37
38
38
/** @var Container $container */
39
39
$ resolver ->setContainer ($ container );
40
40
41
41
$ args = $ resolver ->resolveArguments (['alias1 ' , 'alias2 ' ]);
42
42
43
- self :: assertSame ($ resolver , $ args [0 ]);
44
- self :: assertSame ('alias2 ' , $ args [1 ]);
43
+ $ this -> assertSame ($ resolver , $ args [0 ]);
44
+ $ this -> assertSame ('alias2 ' , $ args [1 ]);
45
45
}
46
46
47
47
public function testResolverResolvesLiteralArguments (): void
@@ -54,16 +54,15 @@ public function testResolverResolvesLiteralArguments(): void
54
54
$ container = $ this ->getMockBuilder (Container::class)->getMock ();
55
55
56
56
$ container
57
- ->expects (self :: at ( 0 ))
57
+ ->expects ($ this -> once ( ))
58
58
->method ('has ' )
59
- ->with (self ::equalTo ('alias1 ' ))
60
- ->willReturn (true )
59
+ ->willReturnOnConsecutiveCalls (true , false )
61
60
;
62
61
63
62
$ container
64
- ->expects (self :: at ( 1 ))
63
+ ->expects ($ this -> once ( ))
65
64
->method ('get ' )
66
- ->with (self :: equalTo ('alias1 ' ))
65
+ ->with ($ this -> equalTo ('alias1 ' ))
67
66
->willReturn (new Literal \StringArgument ('value1 ' ))
68
67
;
69
68
@@ -72,8 +71,8 @@ public function testResolverResolvesLiteralArguments(): void
72
71
73
72
$ args = $ resolver ->resolveArguments (['alias1 ' , new Literal \StringArgument ('value2 ' )]);
74
73
75
- self :: assertSame ('value1 ' , $ args [0 ]);
76
- self :: assertSame ('value2 ' , $ args [1 ]);
74
+ $ this -> assertSame ('value1 ' , $ args [0 ]);
75
+ $ this -> assertSame ('value2 ' , $ args [1 ]);
77
76
}
78
77
79
78
public function testResolverResolvesArgumentsViaReflection (): void
@@ -85,21 +84,21 @@ public function testResolverResolvesArgumentsViaReflection(): void
85
84
$ class = $ this ->getMockBuilder (ReflectionNamedType::class)->disableOriginalConstructor ()->getMock ();
86
85
$ container = $ this ->getMockBuilder (Container::class)->getMock ();
87
86
88
- $ class ->expects (self :: once ())->method ('getName ' )->willReturn ('Class ' );
89
- $ param1 ->expects (self :: once ())->method ('getName ' )->willReturn ('param1 ' );
90
- $ param1 ->expects (self :: once ())->method ('getType ' )->willReturn ($ class );
87
+ $ class ->expects ($ this -> once ())->method ('getName ' )->willReturn ('Class ' );
88
+ $ param1 ->expects ($ this -> once ())->method ('getName ' )->willReturn ('param1 ' );
89
+ $ param1 ->expects ($ this -> once ())->method ('getType ' )->willReturn ($ class );
91
90
92
- $ param2 ->expects (self :: once ())->method ('getName ' )->willReturn ('param2 ' );
93
- $ param2 ->expects (self :: once ())->method ('getType ' )->willReturn (null );
94
- $ param2 ->expects (self :: once ())->method ('isDefaultValueAvailable ' )->willReturn (true );
95
- $ param2 ->expects (self :: once ())->method ('getDefaultValue ' )->willReturn ('value2 ' );
91
+ $ param2 ->expects ($ this -> once ())->method ('getName ' )->willReturn ('param2 ' );
92
+ $ param2 ->expects ($ this -> once ())->method ('getType ' )->willReturn (null );
93
+ $ param2 ->expects ($ this -> once ())->method ('isDefaultValueAvailable ' )->willReturn (true );
94
+ $ param2 ->expects ($ this -> once ())->method ('getDefaultValue ' )->willReturn ('value2 ' );
96
95
97
- $ param3 ->expects (self :: once ())->method ('getName ' )->willReturn ('param3 ' );
96
+ $ param3 ->expects ($ this -> once ())->method ('getName ' )->willReturn ('param3 ' );
98
97
99
- $ method ->expects (self :: once ())->method ('getParameters ' )->willReturn ([$ param1 , $ param2 , $ param3 ]);
98
+ $ method ->expects ($ this -> once ())->method ('getParameters ' )->willReturn ([$ param1 , $ param2 , $ param3 ]);
100
99
101
- $ container ->expects (self :: once ())->method ('has ' )->with ($ this ->equalTo ('Class ' ))->willReturn (true );
102
- $ container ->expects (self :: once ())->method ('get ' )->with ($ this ->equalTo ('Class ' ))->willReturn ('classObject ' );
100
+ $ container ->expects ($ this -> once ())->method ('has ' )->with ($ this ->equalTo ('Class ' ))->willReturn (true );
101
+ $ container ->expects ($ this -> once ())->method ('get ' )->with ($ this ->equalTo ('Class ' ))->willReturn ('classObject ' );
103
102
104
103
$ resolver = new class implements ArgumentResolverInterface {
105
104
use ArgumentResolverTrait;
@@ -111,9 +110,9 @@ public function testResolverResolvesArgumentsViaReflection(): void
111
110
112
111
$ args = $ resolver ->reflectArguments ($ method , ['param3 ' => 'value3 ' ]);
113
112
114
- self :: assertSame ('classObject ' , $ args [0 ]);
115
- self :: assertSame ('value2 ' , $ args [1 ]);
116
- self :: assertSame ('value3 ' , $ args [2 ]);
113
+ $ this -> assertSame ('classObject ' , $ args [0 ]);
114
+ $ this -> assertSame ('value2 ' , $ args [1 ]);
115
+ $ this -> assertSame ('value3 ' , $ args [2 ]);
117
116
}
118
117
119
118
public function testResolvesDefaultValueArgument (): void
@@ -124,7 +123,7 @@ public function testResolvesDefaultValueArgument(): void
124
123
};
125
124
126
125
$ result = $ resolver ->reflectArguments ((new ReflectionClass (Baz::class))->getConstructor ());
127
- self :: assertSame ([null ], $ result );
126
+ $ this -> assertSame ([null ], $ result );
128
127
}
129
128
130
129
public function testResolverThrowsExceptionWhenReflectionDoesNotResolve (): void
@@ -134,11 +133,11 @@ public function testResolverThrowsExceptionWhenReflectionDoesNotResolve(): void
134
133
$ method = $ this ->getMockBuilder (ReflectionFunctionAbstract::class)->getMock ();
135
134
$ param = $ this ->getMockBuilder (ReflectionParameter::class)->disableOriginalConstructor ()->getMock ();
136
135
137
- $ param ->expects (self :: once ())->method ('getName ' )->willReturn ('param1 ' );
138
- $ param ->expects (self :: once ())->method ('getType ' )->willReturn (null );
139
- $ param ->expects (self :: once ())->method ('isDefaultValueAvailable ' )->willReturn (false );
136
+ $ param ->expects ($ this -> once ())->method ('getName ' )->willReturn ('param1 ' );
137
+ $ param ->expects ($ this -> once ())->method ('getType ' )->willReturn (null );
138
+ $ param ->expects ($ this -> once ())->method ('isDefaultValueAvailable ' )->willReturn (false );
140
139
141
- $ method ->expects (self :: once ())->method ('getParameters ' )->willReturn ([$ param ]);
140
+ $ method ->expects ($ this -> once ())->method ('getParameters ' )->willReturn ([$ param ]);
142
141
143
142
$ resolver = new class implements ArgumentResolverInterface {
144
143
use ArgumentResolverTrait;
0 commit comments