File tree 1 file changed +21
-0
lines changed
src/Symfony/Component/DependencyInjection/Tests
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 19
19
use Symfony \Component \DependencyInjection \ContainerBuilder ;
20
20
use Symfony \Component \DependencyInjection \ContainerInterface ;
21
21
use Symfony \Component \DependencyInjection \Definition ;
22
+ use Symfony \Component \DependencyInjection \Exception \RuntimeException ;
22
23
use Symfony \Component \DependencyInjection \Reference ;
23
24
use Symfony \Component \DependencyInjection \ParameterBag \ParameterBag ;
24
25
use Symfony \Component \Config \Resource \FileResource ;
@@ -116,6 +117,26 @@ public function testGet()
116
117
$ this ->assertTrue ($ builder ->get ('bar ' ) === $ builder ->get ('bar ' ), '->get() always returns the same instance if the service is shared ' );
117
118
}
118
119
120
+ /**
121
+ * @covers \Symfony\Component\DependencyInjection\ContainerBuilder::get
122
+ * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
123
+ * @expectedExceptionMessage You have requested a synthetic service ("foo"). The DIC does not know how to construct this service.
124
+ */
125
+ public function testGetXXX ()
126
+ {
127
+ $ builder = new ContainerBuilder ();
128
+ $ builder ->register ('foo ' , 'stdClass ' )->setSynthetic (true );
129
+
130
+ // we expect a RuntimeException here as foo is synthetic
131
+ try {
132
+ $ builder ->get ('foo ' );
133
+ } catch (RuntimeException $ e ) {
134
+ }
135
+
136
+ // we must also have the same RuntimeException here
137
+ $ builder ->get ('foo ' );
138
+ }
139
+
119
140
/**
120
141
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::getServiceIds
121
142
*/
You can’t perform that action at this time.
0 commit comments