You are here

public function HeaderBagTest::testGet in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Tests/HeaderBagTest.php \Symfony\Component\HttpFoundation\Tests\HeaderBagTest::testGet()

@covers Symfony\Component\HttpFoundation\HeaderBag::get

File

vendor/symfony/http-foundation/Tests/HeaderBagTest.php, line 97

Class

HeaderBagTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

public function testGet() {
  $bag = new HeaderBag(array(
    'foo' => 'bar',
    'fuzz' => 'bizz',
  ));
  $this
    ->assertEquals('bar', $bag
    ->get('foo'), '->get return current value');
  $this
    ->assertEquals('bar', $bag
    ->get('FoO'), '->get key in case insensitive');
  $this
    ->assertEquals(array(
    'bar',
  ), $bag
    ->get('foo', 'nope', false), '->get return the value as array');

  // defaults
  $this
    ->assertNull($bag
    ->get('none'), '->get unknown values returns null');
  $this
    ->assertEquals('default', $bag
    ->get('none', 'default'), '->get unknown values returns default');
  $this
    ->assertEquals(array(
    'default',
  ), $bag
    ->get('none', 'default', false), '->get unknown values returns default as array');
  $bag
    ->set('foo', 'bor', false);
  $this
    ->assertEquals('bar', $bag
    ->get('foo'), '->get return first value');
  $this
    ->assertEquals(array(
    'bar',
    'bor',
  ), $bag
    ->get('foo', 'nope', false), '->get return all values as array');
}