|
@@ -98,7 +98,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
|
|
$this->assertEquals(array('service_container', 'foo', 'bar'), $sc->getServiceIds(), '->getServiceIds() returns all defined service ids');
|
|
$this->assertEquals(array('service_container', 'foo', 'bar'), $sc->getServiceIds(), '->getServiceIds() returns all defined service ids');
|
|
|
|
|
|
$sc = new ProjectServiceContainer();
|
|
$sc = new ProjectServiceContainer();
|
|
- $this->assertEquals(array('scoped', 'scoped_foo', 'bar', 'foo_bar', 'foo.baz', 'circular', 'service_container'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by getXXXService() methods');
|
|
|
|
|
|
+ $this->assertEquals(array('scoped', 'scoped_foo', 'bar', 'foo_bar', 'foo.baz', 'circular', 'throw_exception', 'service_container'), $sc->getServiceIds(), '->getServiceIds() returns defined service ids by getXXXService() methods');
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -337,6 +337,25 @@ class ContainerTest extends \PHPUnit_Framework_TestCase
|
|
$this->assertFalse($c->isScopeActive('foo'));
|
|
$this->assertFalse($c->isScopeActive('foo'));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function testGetThrowsException()
|
|
|
|
+ {
|
|
|
|
+ $c = new ProjectServiceContainer();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ $c->get('throw_exception');
|
|
|
|
+ $this->fail();
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ $this->assertEquals('Something went terribly wrong!', $e->getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ $c->get('throw_exception');
|
|
|
|
+ $this->fail();
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
+ $this->assertEquals('Something went terribly wrong!', $e->getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public function getInvalidParentScopes()
|
|
public function getInvalidParentScopes()
|
|
{
|
|
{
|
|
return array(
|
|
return array(
|
|
@@ -412,4 +431,9 @@ class ProjectServiceContainer extends Container
|
|
{
|
|
{
|
|
return $this->get('circular');
|
|
return $this->get('circular');
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ protected function getThrowExceptionService()
|
|
|
|
+ {
|
|
|
|
+ throw new \Exception('Something went terribly wrong!');
|
|
|
|
+ }
|
|
}
|
|
}
|