You are here

public function ContainerTest::testHas in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/dependency-injection/Tests/ContainerTest.php \Symfony\Component\DependencyInjection\Tests\ContainerTest::testHas()
  2. 8 core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php \Drupal\Tests\Component\DependencyInjection\ContainerTest::testHas()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/Tests/ContainerTest.php \Symfony\Component\DependencyInjection\Tests\ContainerTest::testHas()

@covers Symfony\Component\DependencyInjection\Container::has

File

vendor/symfony/dependency-injection/Tests/ContainerTest.php, line 286

Class

ContainerTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

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');
  $this
    ->assertTrue($sc
    ->has('foo\\baz'), '->has() returns true if a get*Method() is defined');
}