public function testGetThrowsExceptionOnServiceConfiguration() { $c = new ProjectServiceContainer(); try { $c->get('throws_exception_on_service_configuration'); $this->fail('The container can not contain invalid service!'); } catch (\Exception $e) { $this->assertEquals('Something was terribly wrong while trying to configure the service!', $e->getMessage()); } $this->assertFalse($c->initialized('throws_exception_on_service_configuration')); try { $c->get('throws_exception_on_service_configuration'); $this->fail('The container can not contain invalid service!'); } catch (\Exception $e) { $this->assertEquals('Something was terribly wrong while trying to configure the service!', $e->getMessage()); } $this->assertFalse($c->initialized('throws_exception_on_service_configuration')); }
public function testGetThrowsExceptionOnServiceConfiguration() { $c = new ProjectServiceContainer(); try { $c->get('throws_exception_on_service_configuration'); } catch (\Exception $e) { // Do nothing. } $this->assertFalse($c->initialized('throws_exception_on_service_configuration')); // Retry, to make sure that get*Service() will be called. try { $c->get('throws_exception_on_service_configuration'); } catch (\Exception $e) { // Do nothing. } $this->assertFalse($c->initialized('throws_exception_on_service_configuration')); }
/** * @covers Symfony\Component\DependencyInjection\Container::initialized */ public function testInitialized() { $sc = new ProjectServiceContainer(); $sc->set('foo', new \stdClass()); $this->assertTrue($sc->initialized('foo'), '->initialized() returns true if service is loaded'); $this->assertFalse($sc->initialized('foo1'), '->initialized() returns false if service is not loaded'); $this->assertFalse($sc->initialized('bar'), '->initialized() returns false if a service is defined, but not currently loaded'); }