@@ -50,22 +50,34 @@ public function testCreateNoArgs()
50
50
}
51
51
52
52
/**
53
- * @expectedException \UnexpectedValueException
53
+ * @expectedException \UnexpectedValueException
54
54
* @expectedExceptionMessage Invalid parameter configuration provided for $firstParam argument
55
55
*/
56
56
public function testResolveArgumentsException ()
57
57
{
58
58
$ configMock = $ this ->createMock (\Magento \Framework \ObjectManager \Config \Config::class);
59
- $ configMock ->expects ($ this ->once ())->method ('getArguments ' )
60
- ->will ($ this ->returnValue ([
61
- 'firstParam ' => 1 ,
62
- ]));
59
+ $ configMock ->expects ($ this ->once ())->method ('getArguments ' )->will (
60
+ $ this ->returnValue (
61
+ [
62
+ 'firstParam ' => 1 ,
63
+ ]
64
+ )
65
+ );
63
66
64
67
$ definitionsMock = $ this ->createMock (\Magento \Framework \ObjectManager \DefinitionInterface::class);
65
- $ definitionsMock ->expects ($ this ->once ())->method ('getParameters ' )
66
- ->will ($ this ->returnValue ([[
67
- 'firstParam ' , 'string ' , true , 'default_val ' , false
68
- ]]));
68
+ $ definitionsMock ->expects ($ this ->once ())->method ('getParameters ' )->will (
69
+ $ this ->returnValue (
70
+ [
71
+ [
72
+ 'firstParam ' ,
73
+ 'string ' ,
74
+ true ,
75
+ 'default_val ' ,
76
+ false
77
+ ]
78
+ ]
79
+ )
80
+ );
69
81
70
82
$ this ->factory = new Developer (
71
83
$ configMock ,
@@ -80,9 +92,14 @@ public function testResolveArgumentsException()
80
92
);
81
93
}
82
94
95
+ /**
96
+ * Test create with one arg
97
+ */
83
98
public function testCreateOneArg ()
84
99
{
85
- /** @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar $result */
100
+ /**
101
+ * @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar $result
102
+ */
86
103
$ result = $ this ->factory ->create (
87
104
\Magento \Framework \ObjectManager \Test \Unit \Factory \Fixture \OneScalar::class,
88
105
['foo ' => 'bar ' ]
@@ -91,6 +108,9 @@ public function testCreateOneArg()
91
108
$ this ->assertEquals ('bar ' , $ result ->getFoo ());
92
109
}
93
110
111
+ /**
112
+ * Test create with injectable
113
+ */
94
114
public function testCreateWithInjectable ()
95
115
{
96
116
// let's imitate that One is injectable by providing DI configuration for it
@@ -101,7 +121,9 @@ public function testCreateWithInjectable()
101
121
],
102
122
]
103
123
);
104
- /** @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Two $result */
124
+ /**
125
+ * @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Two $result
126
+ */
105
127
$ result = $ this ->factory ->create (\Magento \Framework \ObjectManager \Test \Unit \Factory \Fixture \Two::class);
106
128
$ this ->assertInstanceOf (\Magento \Framework \ObjectManager \Test \Unit \Factory \Fixture \Two::class, $ result );
107
129
$ this ->assertInstanceOf (
@@ -113,8 +135,8 @@ public function testCreateWithInjectable()
113
135
}
114
136
115
137
/**
116
- * @param string $startingClass
117
- * @param string $terminationClass
138
+ * @param string $startingClass
139
+ * @param string $terminationClass
118
140
* @dataProvider circularDataProvider
119
141
*/
120
142
public function testCircular ($ startingClass , $ terminationClass )
@@ -139,23 +161,30 @@ public function circularDataProvider()
139
161
];
140
162
}
141
163
164
+ /**
165
+ * Test create using reflection
166
+ */
142
167
public function testCreateUsingReflection ()
143
168
{
144
169
$ type = \Magento \Framework \ObjectManager \Test \Unit \Factory \Fixture \Polymorphous::class;
145
170
$ definitions = $ this ->createMock (\Magento \Framework \ObjectManager \DefinitionInterface::class);
146
171
// should be more than defined in "switch" of create() method
147
- $ definitions ->expects ($ this ->once ())->method ('getParameters ' )->with ($ type )->will ($ this ->returnValue ([
148
- ['one ' , null , false , null , false ],
149
- ['two ' , null , false , null , false ],
150
- ['three ' , null , false , null , false ],
151
- ['four ' , null , false , null , false ],
152
- ['five ' , null , false , null , false ],
153
- ['six ' , null , false , null , false ],
154
- ['seven ' , null , false , null , false ],
155
- ['eight ' , null , false , null , false ],
156
- ['nine ' , null , false , null , false ],
157
- ['ten ' , null , false , null , false ],
158
- ]));
172
+ $ definitions ->expects ($ this ->once ())->method ('getParameters ' )->with ($ type )->will (
173
+ $ this ->returnValue (
174
+ [
175
+ ['one ' , null , false , null , false ],
176
+ ['two ' , null , false , null , false ],
177
+ ['three ' , null , false , null , false ],
178
+ ['four ' , null , false , null , false ],
179
+ ['five ' , null , false , null , false ],
180
+ ['six ' , null , false , null , false ],
181
+ ['seven ' , null , false , null , false ],
182
+ ['eight ' , null , false , null , false ],
183
+ ['nine ' , null , false , null , false ],
184
+ ['ten ' , null , false , null , false ],
185
+ ]
186
+ )
187
+ );
159
188
$ factory = new Developer ($ this ->config , null , $ definitions );
160
189
$ result = $ factory ->create (
161
190
$ type ,
@@ -178,9 +207,9 @@ public function testCreateUsingReflection()
178
207
/**
179
208
* Test create objects with variadic argument in constructor
180
209
*
181
- * @param $createArgs
182
- * @param $expectedArg0
183
- * @param $expectedArg1
210
+ * @param $createArgs
211
+ * @param $expectedArg0
212
+ * @param $expectedArg1
184
213
* @dataProvider testCreateUsingVariadicDataProvider
185
214
*/
186
215
public function testCreateUsingVariadic (
@@ -191,20 +220,24 @@ public function testCreateUsingVariadic(
191
220
$ type = \Magento \Framework \ObjectManager \Test \Unit \Factory \Fixture \Variadic::class;
192
221
$ definitions = $ this ->createMock (\Magento \Framework \ObjectManager \DefinitionInterface::class);
193
222
194
- $ definitions ->expects ($ this ->once ())->method ('getParameters ' )->with ($ type )->will ($ this ->returnValue ([
195
- [
223
+ $ definitions ->expects ($ this ->once ())->method ('getParameters ' )->with ($ type )->will (
224
+ $ this ->returnValue (
225
+ [
226
+ [
196
227
'oneScalars ' ,
197
228
\Magento \Framework \ObjectManager \Test \Unit \Factory \Fixture \OneScalar::class,
198
229
false ,
199
230
[],
200
231
true
201
- ],
202
- ]));
232
+ ],
233
+ ]
234
+ )
235
+ );
203
236
$ factory = new Developer ($ this ->config , null , $ definitions );
204
237
205
-
206
-
207
- /** @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Variadic $variadic */
238
+ /**
239
+ * @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Variadic $variadic
240
+ */
208
241
$ variadic = is_null ($ createArgs )
209
242
? $ factory ->create ($ type )
210
243
: $ factory ->create ($ type , $ createArgs );
@@ -216,7 +249,8 @@ public function testCreateUsingVariadic(
216
249
/**
217
250
* @return array
218
251
*/
219
- public function testCreateUsingVariadicDataProvider () {
252
+ public function testCreateUsingVariadicDataProvider ()
253
+ {
220
254
$ oneScalar1 = $ this ->createMock (\Magento \Framework \ObjectManager \Test \Unit \Factory \Fixture \OneScalar::class);
221
255
$ oneScalar2 = $ this ->createMock (\Magento \Framework \ObjectManager \Test \Unit \Factory \Fixture \OneScalar::class);
222
256
@@ -272,7 +306,9 @@ public function testCreateVariadicFromDiConfig()
272
306
],
273
307
]
274
308
);
275
- /** @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Variadic $variadic */
309
+ /**
310
+ * @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Variadic $variadic
311
+ */
276
312
$ variadic = $ this ->factory ->create (\Magento \Framework \ObjectManager \Test \Unit \Factory \Fixture \Variadic::class);
277
313
278
314
$ this ->assertSame ($ oneScalar1 , $ variadic ->getOneScalarByKey (0 ));
0 commit comments