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');
     $this->assertFalse($sc->initialized('alias'), '->initialized() returns false if an aliased service is not initialized');
     $sc->set('bar', new \stdClass());
     $this->assertTrue($sc->initialized('alias'), '->initialized() returns true for alias if aliased service is initialized');
 }
Beispiel #2
0
 /**
  * @group legacy
  * @expectedDeprecation Setting the "internal" private service is deprecated since Symfony 3.2 and won't be supported anymore in Symfony 4.0. A new public service will be created instead.
  */
 public function testChangeInternalPrivateServiceIsDeprecated()
 {
     $c = new ProjectServiceContainer();
     $c->set('internal', new \stdClass());
 }
Beispiel #3
0
 /**
  * @covers Symfony\Component\DependencyInjection\Container::has
  */
 public function testHas()
 {
     $sc = new ProjectServiceContainer();
     $sc->set('foo', new \stdClass());
     $this->assertFalse($sc->has('foo1'), '->has() returns false if the service does not exist');
     $this->assertTrue($sc->has('foo'), '->has() returns true if the service exists');
     $this->assertTrue($sc->has('bar'), '->has() returns true if a get*Method() is defined');
     $this->assertTrue($sc->has('foo_bar'), '->has() returns true if a get*Method() is defined');
     $this->assertTrue($sc->has('foo.baz'), '->has() returns true if a get*Method() is defined');
 }
Beispiel #4
0
 /**
  * @group legacy
  * @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
  */
 public function testChangeInternalPrivateServiceIsDeprecated()
 {
     $deprecations = array('Setting the "internal" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0. A new public service will be created instead.');
     ErrorAssert::assertDeprecationsAreTriggered($deprecations, function () {
         $c = new ProjectServiceContainer();
         $c->set('internal', new \stdClass());
     });
 }