public function testAlias() { $c = new ProjectServiceContainer(); $this->assertTrue($c->has('alias')); $this->assertSame($c->get('alias'), $c->get('bar')); }
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()); } }
/** * @group legacy * @expectedDeprecation Requesting the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. */ public function testRequestAnInternalSharedPrivateServiceIsDeprecated() { $c = new ProjectServiceContainer(); $c->get('internal'); }
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')); }
/** * @group legacy * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered */ public function testRequestAnInternalSharedPrivateServiceIsDeprecated() { $deprecations = array('Requesting the "internal" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.'); ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () { $c = new ProjectServiceContainer(); $c->get('internal'); }); }