You are here

public function HelperSetTest::testGet in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Tests/Helper/HelperSetTest.php \Symfony\Component\Console\Tests\Helper\HelperSetTest::testGet()

@covers \Symfony\Component\Console\Helper\HelperSet::get

File

vendor/symfony/console/Tests/Helper/HelperSetTest.php, line 65

Class

HelperSetTest

Namespace

Symfony\Component\Console\Tests\Helper

Code

public function testGet() {
  $helper_01 = $this
    ->getGenericMockHelper('fake_helper_01');
  $helper_02 = $this
    ->getGenericMockHelper('fake_helper_02');
  $helperset = new HelperSet(array(
    'fake_helper_01_alias' => $helper_01,
    'fake_helper_02_alias' => $helper_02,
  ));
  $this
    ->assertEquals($helper_01, $helperset
    ->get('fake_helper_01'), '->get() returns correct helper by name');
  $this
    ->assertEquals($helper_01, $helperset
    ->get('fake_helper_01_alias'), '->get() returns correct helper by alias');
  $this
    ->assertEquals($helper_02, $helperset
    ->get('fake_helper_02'), '->get() returns correct helper by name');
  $this
    ->assertEquals($helper_02, $helperset
    ->get('fake_helper_02_alias'), '->get() returns correct helper by alias');
  $helperset = new HelperSet();
  try {
    $helperset
      ->get('foo');
    $this
      ->fail('->get() throws \\InvalidArgumentException when helper not found');
  } catch (\Exception $e) {
    $this
      ->assertInstanceOf('\\InvalidArgumentException', $e, '->get() throws \\InvalidArgumentException when helper not found');
    $this
      ->assertContains('The helper "foo" is not defined.', $e
      ->getMessage(), '->get() throws \\InvalidArgumentException when helper not found');
  }
}