@@ -69,7 +69,6 @@ public function testCreateDeprecatedService()
69
69
70
70
$ builder = new ContainerBuilder ();
71
71
$ builder ->setDefinition ('deprecated_foo ' , $ definition );
72
- $ builder ->compile ();
73
72
$ builder ->get ('deprecated_foo ' );
74
73
}
75
74
@@ -98,14 +97,12 @@ public function testHas()
98
97
public function testGetThrowsExceptionIfServiceDoesNotExist ()
99
98
{
100
99
$ builder = new ContainerBuilder ();
101
- $ builder ->compile ();
102
100
$ builder ->get ('foo ' );
103
101
}
104
102
105
103
public function testGetReturnsNullIfServiceDoesNotExistAndInvalidReferenceIsUsed ()
106
104
{
107
105
$ builder = new ContainerBuilder ();
108
- $ builder ->compile ();
109
106
110
107
$ this ->assertNull ($ builder ->get ('foo ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ), '->get() returns null if the service does not exist and NULL_ON_INVALID_REFERENCE is passed as a second argument ' );
111
108
}
@@ -117,15 +114,13 @@ public function testGetThrowsCircularReferenceExceptionIfServiceHasReferenceToIt
117
114
{
118
115
$ builder = new ContainerBuilder ();
119
116
$ builder ->register ('baz ' , 'stdClass ' )->setArguments (array (new Reference ('baz ' )));
120
- $ builder ->compile ();
121
117
$ builder ->get ('baz ' );
122
118
}
123
119
124
120
public function testGetReturnsSameInstanceWhenServiceIsShared ()
125
121
{
126
122
$ builder = new ContainerBuilder ();
127
123
$ builder ->register ('bar ' , 'stdClass ' );
128
- $ builder ->compile ();
129
124
130
125
$ this ->assertTrue ($ builder ->get ('bar ' ) === $ builder ->get ('bar ' ), '->get() always returns the same instance if the service is shared ' );
131
126
}
@@ -134,7 +129,6 @@ public function testGetCreatesServiceBasedOnDefinition()
134
129
{
135
130
$ builder = new ContainerBuilder ();
136
131
$ builder ->register ('foo ' , 'stdClass ' );
137
- $ builder ->compile ();
138
132
139
133
$ this ->assertInternalType ('object ' , $ builder ->get ('foo ' ), '->get() returns the service definition associated with the id ' );
140
134
}
@@ -143,7 +137,6 @@ public function testGetReturnsRegisteredService()
143
137
{
144
138
$ builder = new ContainerBuilder ();
145
139
$ builder ->set ('bar ' , $ bar = new \stdClass ());
146
- $ builder ->compile ();
147
140
148
141
$ this ->assertSame ($ bar , $ builder ->get ('bar ' ), '->get() returns the service associated with the id ' );
149
142
}
@@ -153,7 +146,6 @@ public function testRegisterDoesNotOverrideExistingService()
153
146
$ builder = new ContainerBuilder ();
154
147
$ builder ->set ('bar ' , $ bar = new \stdClass ());
155
148
$ builder ->register ('bar ' , 'stdClass ' );
156
- $ builder ->compile ();
157
149
158
150
$ this ->assertSame ($ bar , $ builder ->get ('bar ' ), '->get() returns the service associated with the id even if a definition has been defined ' );
159
151
}
@@ -163,8 +155,6 @@ public function testNonSharedServicesReturnsDifferentInstances()
163
155
$ builder = new ContainerBuilder ();
164
156
$ builder ->register ('bar ' , 'stdClass ' )->setShared (false );
165
157
166
- $ builder ->compile ();
167
-
168
158
$ this ->assertNotSame ($ builder ->get ('bar ' ), $ builder ->get ('bar ' ));
169
159
}
170
160
@@ -177,8 +167,6 @@ public function testGetUnsetLoadingServiceWhenCreateServiceThrowsAnException()
177
167
$ builder = new ContainerBuilder ();
178
168
$ builder ->register ('foo ' , 'stdClass ' )->setSynthetic (true );
179
169
180
- $ builder ->compile ();
181
-
182
170
// we expect a RuntimeException here as foo is synthetic
183
171
try {
184
172
$ builder ->get ('foo ' );
@@ -207,9 +195,6 @@ public function testAliases()
207
195
$ this ->assertFalse ($ builder ->hasAlias ('foobar ' ), '->hasAlias() returns false if the alias does not exist ' );
208
196
$ this ->assertEquals ('foo ' , (string ) $ builder ->getAlias ('bar ' ), '->getAlias() returns the aliased service ' );
209
197
$ this ->assertTrue ($ builder ->has ('bar ' ), '->setAlias() defines a new service ' );
210
-
211
- $ builder ->compile ();
212
-
213
198
$ this ->assertTrue ($ builder ->get ('bar ' ) === $ builder ->get ('foo ' ), '->setAlias() creates a service that is an alias to another one ' );
214
199
215
200
try {
@@ -277,9 +262,6 @@ public function testSetReplacesAlias()
277
262
$ builder ->set ('aliased ' , new \stdClass ());
278
263
279
264
$ builder ->set ('alias ' , $ foo = new \stdClass ());
280
-
281
- $ builder ->compile ();
282
-
283
265
$ this ->assertSame ($ foo , $ builder ->get ('alias ' ), '->set() replaces an existing alias ' );
284
266
}
285
267
@@ -303,9 +285,6 @@ public function testCreateService()
303
285
$ builder ->register ('foo1 ' , 'Bar\FooClass ' )->setFile (__DIR__ .'/Fixtures/includes/foo.php ' );
304
286
$ builder ->register ('foo2 ' , 'Bar\FooClass ' )->setFile (__DIR__ .'/Fixtures/includes/%file%.php ' );
305
287
$ builder ->setParameter ('file ' , 'foo ' );
306
-
307
- $ builder ->compile ();
308
-
309
288
$ this ->assertInstanceOf ('\Bar\FooClass ' , $ builder ->get ('foo1 ' ), '->createService() requires the file defined by the service definition ' );
31
E377
0
289
$ this ->assertInstanceOf ('\Bar\FooClass ' , $ builder ->get ('foo2 ' ), '->createService() replaces parameters in the file provided by the service definition ' );
311
290
}
@@ -317,8 +296,6 @@ public function testCreateProxyWithRealServiceInstantiator()
317
296
$ builder ->register ('foo1 ' , 'Bar\FooClass ' )->setFile (__DIR__ .'/Fixtures/includes/foo.php ' );
318
297
$ builder ->getDefinition ('foo1 ' )->setLazy (true );
319
298
320
- $ builder ->compile ();
321
-
322
299
$ foo1 = $ builder ->get ('foo1 ' );
323
300
324
301
$ this ->assertSame ($ foo1 , $ builder ->get ('foo1 ' ), 'The same proxy is retrieved on multiple subsequent calls ' );
@@ -330,9 +307,6 @@ public function testCreateServiceClass()
330
307
$ builder = new ContainerBuilder ();
331
308
$ builder ->register ('foo1 ' , '%class% ' );
332
309
$ builder ->setParameter ('class ' , 'stdClass ' );
333
-
334
- $ builder ->compile ();
335
-
336
310
$ this ->assertInstanceOf ('\stdClass ' , $ builder ->get ('foo1 ' ), '->createService() replaces parameters in the class provided by the service definition ' );
337
311
}
338
312
@@ -342,9 +316,6 @@ public function testCreateServiceArguments()
342
316
$ builder ->register ('bar ' , 'stdClass ' );
343
317
$ builder ->register ('foo1 ' , 'Bar\FooClass ' )->addArgument (array ('foo ' => '%value% ' , '%value% ' => 'foo ' , new Reference ('bar ' ), '%%unescape_it%% ' ));
344
318
$ builder ->setParameter ('value ' , 'bar ' );
345
-
346
- $ builder ->compile ();
347
-
348
319
$ this ->assertEquals (array ('foo ' => 'bar ' , 'bar ' => 'foo ' , $ builder ->get ('bar ' ), '%unescape_it% ' ), $ builder ->get ('foo1 ' )->arguments , '->createService() replaces parameters and service references in the arguments provided by the service definition ' );
349
320
}
350
321
@@ -356,8 +327,6 @@ public function testCreateServiceFactory()
356
327
$ builder ->register ('bar ' , 'Bar\FooClass ' )->setFactory (array (new Definition ('Bar\FooClass ' ), 'getInstance ' ));
357
328
$ builder ->register ('baz ' , 'Bar\FooClass ' )->setFactory (array (new Reference ('bar ' ), 'getInstance ' ));
358
329
359
- $ builder ->compile ();
360
-
361
330
$ this ->assertTrue ($ builder ->get ('foo ' )->called , '->createService() calls the factory method to create the service instance ' );
362
331
$ this ->assertTrue ($ builder ->get ('qux ' )->called , '->createService() calls the factory method to create the service instance ' );
363
332
$ this ->assertTrue ($ builder ->get ('bar ' )->called , '->createService() uses anonymous service as factory ' );
@@ -370,9 +339,6 @@ public function testCreateServiceMethodCalls()
370
339
$ builder ->register ('bar ' , 'stdClass ' );
371
340
$ builder ->register ('foo1 ' , 'Bar\FooClass ' )->addMethodCall ('setBar ' , array (array ('%value% ' , new Reference ('bar ' ))));
372
341
$ builder ->setParameter ('value ' , 'bar ' );
373
-
374
- $ builder ->compile ();
375
-
376
342
$ this ->assertEquals (array ('bar ' , $ builder ->get ('bar ' )), $ builder ->get ('foo1 ' )->bar , '->createService() replaces the values in the method calls arguments ' );
377
343
}
378
344
@@ -382,9 +348,6 @@ public function testCreateServiceMethodCallsWithEscapedParam()
382
348
$ builder ->register ('bar ' , 'stdClass ' );
383
349
$ builder ->register ('foo1 ' , 'Bar\FooClass ' )->addMethodCall ('setBar ' , array (array ('%%unescape_it%% ' )));
384
350
$ builder ->setParameter ('value ' , 'bar ' );
385
-
386
- $ builder ->compile ();
387
-
388
351
$ this ->assertEquals (array ('%unescape_it% ' ), $ builder ->get ('foo1 ' )->bar , '->createService() replaces the values in the method calls arguments ' );
389
352
}
390
353
@@ -394,9 +357,6 @@ public function testCreateServiceProperties()
394
357
$ builder ->register ('bar ' , 'stdClass ' );
395
358
$ builder ->register ('foo1 ' , 'Bar\FooClass ' )->setProperty ('bar ' , array ('%value% ' , new Reference ('bar ' ), '%%unescape_it%% ' ));
396
359
$ builder ->setParameter ('value ' , 'bar ' );
397
-
398
- $ builder ->compile ();
399
-
400
360
$ this ->assertEquals (array ('bar ' , $ builder ->get ('bar ' ), '%unescape_it% ' ), $ builder ->get ('foo1 ' )->bar , '->createService() replaces the values in the properties ' );
401
361
}
402
362
@@ -411,8 +371,6 @@ public function testCreateServiceConfigurator()
411
371
$ builder ->register ('foo4 ' , 'Bar\FooClass ' )->setConfigurator (array ($ builder ->getDefinition ('baz ' ), 'configure ' ));
412
372
$ builder ->register ('foo5 ' , 'Bar\FooClass ' )->setConfigurator ('foo ' );
413
373
414
- $ builder ->compile ();
415
-
416
374
$ this ->assertTrue ($ builder ->get ('foo1 ' )->configured , '->createService() calls the configurator ' );
417
375
$ this ->assertTrue ($ builder ->get ('foo2 ' )->configured , '->createService() calls the configurator ' );
418
376
$ this ->assertTrue ($ builder ->get ('foo3 ' )->configured , '->createService() calls the configurator ' );
@@ -433,9 +391,6 @@ public function testCreateSyntheticService()
433
391
{
434
392
$ builder = new ContainerBuilder ();
435
393
$ builder ->register ('foo ' , 'Bar\FooClass ' )->setSynthetic (true );
436
-
437
- $ builder ->compile ();
438
-
439
394
$ builder ->get ('foo ' );
440
395
}
441
396
@@ -445,18 +400,13 @@ public function testCreateServiceWithExpression()
445
400
$ builder ->setParameter ('bar ' , 'bar ' );
446
401
$ builder ->register ('bar ' , 'BarClass ' );
447
402
$ builder ->register ('foo ' , 'Bar\FooClass ' )->addArgument (array ('foo ' => new Expression ('service("bar").foo ~ parameter("bar") ' )));
448
-
449
- $ builder ->compile ();
450
-
451
403
$ this ->assertEquals ('foobar ' , $ builder ->get ('foo ' )->arguments ['foo ' ]);
452
404
}
453
405
454
406
public function testResolveServices ()
455
407
{
456
408
$ builder = new ContainerBuilder ();
457
409
$ builder ->register ('foo ' , 'Bar\FooClass ' );
458
- $ builder ->compile ();
459
-
460
410
$ this ->assertEquals ($ builder ->get ('foo ' ), $ builder ->resolveServices (new Reference ('foo ' )), '->resolveServices() resolves service references to service instances ' );
461
411
$ this ->assertEquals (array ('foo ' => array ('foo ' , $ builder ->get ('foo ' ))), $ builder ->resolveServices (array ('foo ' => array ('foo ' , new Reference ('foo ' )))), '->resolveServices() resolves service references to service instances in nested arrays ' );
462
412
$ this ->assertEquals ($ builder ->get ('foo ' ), $ builder ->resolveServices (new Expression ('service("foo") ' )), '->resolveServices() resolves expressions ' );
0 commit comments