9
9
10
10
namespace Zend \ContainerTest ;
11
11
12
+ use Generator ;
13
+
12
14
trait DelegatorTestTrait
13
15
{
14
- public function testDelegatorForInvokable ()
16
+ public function testDelegatorForInvokable () : void
15
17
{
16
18
$ config = [
17
19
'invokables ' => [
@@ -30,9 +32,10 @@ public function testDelegatorForInvokable()
30
32
$ delegator = $ container ->get ('foo-bar ' );
31
33
self ::assertInstanceOf (TestAsset \Delegator::class, $ delegator );
32
34
self ::assertInstanceOf (TestAsset \Service::class, ($ delegator ->callback )());
35
+ self ::assertSame ($ delegator , $ container ->get ('foo-bar ' ));
33
36
}
34
37
35
- public function testDelegatorForService ()
38
+ public function testDelegatorForService () : void
36
39
{
37
40
$ myService = new TestAsset \Service ();
38
41
$ config = [
@@ -52,9 +55,10 @@ public function testDelegatorForService()
52
55
$ delegator = $ container ->get ('foo-bar ' );
53
56
self ::assertInstanceOf (TestAsset \Delegator::class, $ delegator );
54
57
self ::assertSame ($ myService , ($ delegator ->callback )());
58
+ self ::assertSame ($ delegator , $ container ->get ('foo-bar ' ));
55
59
}
56
60
57
- public function testDelegatorForFactory ()
61
+ public function testDelegatorForFactory () : void
58
62
{
59
63
$ config = [
60
64
'factories ' => [
@@ -73,9 +77,10 @@ public function testDelegatorForFactory()
73
77
$ delegator = $ container ->get ('foo-bar ' );
74
78
self ::assertInstanceOf (TestAsset \Delegator::class, $ delegator );
75
79
self ::assertInstanceOf (TestAsset \Service::class, ($ delegator ->callback )());
80
+ self ::assertSame ($ delegator , $ container ->get ('foo-bar ' ));
76
81
}
77
82
78
- public function testDelegatorForAliasInvokable ()
83
+ public function testDelegatorForAliasInvokable () : void
79
84
{
80
85
$ config = [
81
86
'aliases ' => [
@@ -97,9 +102,10 @@ public function testDelegatorForAliasInvokable()
97
102
$ delegator = $ container ->get ('foo-bar ' );
98
103
self ::assertInstanceOf (TestAsset \Delegator::class, $ delegator );
99
104
self ::assertInstanceOf (TestAsset \Service::class, ($ delegator ->callback )());
105
+ self ::assertSame ($ delegator , $ container ->get ('foo-bar ' ));
100
106
}
101
107
102
- public function testDelegatorForAliasService ()
108
+ public function testDelegatorForAliasService () : void
103
109
{
104
110
$ myService = new TestAsset \Service ();
105
111
$ config = [
@@ -122,9 +128,10 @@ public function testDelegatorForAliasService()
122
128
$ delegator = $ container ->get ('foo-bar ' );
123
129
self ::assertInstanceOf (TestAsset \Delegator::class, $ delegator );
124
130
self ::assertSame ($ myService , ($ delegator ->callback )());
131
+ self ::assertSame ($ delegator , $ container ->get ('foo-bar ' ));
125
132
}
126
133
127
- public function testDelegatorForAliasFactory ()
134
+ public function testDelegatorForAliasFactory () : void
128
135
{
129
136
$ config = [
130
137
'aliases ' => [
@@ -146,9 +153,10 @@ public function testDelegatorForAliasFactory()
146
153
$ delegator = $ container ->get ('foo-bar ' );
147
154
self ::assertInstanceOf (TestAsset \Delegator::class, $ delegator );
148
155
self ::assertInstanceOf (TestAsset \Service::class, ($ delegator ->callback )());
156
+ self ::assertSame ($ delegator , $ container ->get ('foo-bar ' ));
149
157
}
150
158
151
- public function delegatorService ()
159
+ public function delegatorService () : Generator
152
160
{
153
161
yield 'invokable ' => [
154
162
[
@@ -172,7 +180,7 @@ public function delegatorService()
172
180
/**
173
181
* @dataProvider delegatorService
174
182
*/
175
- public function testDelegatorMultipleDelegators (array $ config )
183
+ public function testDelegatorMultipleDelegators (array $ config ) : void
176
184
{
177
185
$ config += [
178
186
'delegators ' => [
@@ -195,5 +203,6 @@ public function testDelegatorMultipleDelegators(array $config)
195
203
],
196
204
$ service ->injected
197
205
);
206
+ self ::assertSame ($ service , $ container ->get ('foo-bar ' ));
198
207
}
199
208
}
0 commit comments