/** * @covers Symfony\Component\HttpFoundation\HeaderBag::replace */ public function testReplace() { $bag = new HeaderBag(array('foo' => 'bar')); $bag->replace(array('NOPE' => 'BAR')); $this->assertEquals(array('nope' => array('BAR')), $bag->all(), '->replace() replaces the input with the argument'); $this->assertFalse($bag->has('foo'), '->replace() overrides previously set the input'); }
public function testCacheControlDirectiveOverrideWithReplace() { $bag = new HeaderBag(array('cache-control' => 'private, max-age=100')); $bag->replace(array('cache-control' => 'public, max-age=10')); $this->assertTrue($bag->hasCacheControlDirective('public')); $this->assertTrue($bag->getCacheControlDirective('public')); $this->assertTrue($bag->hasCacheControlDirective('max-age')); $this->assertEquals(10, $bag->getCacheControlDirective('max-age')); }
/** * {@inheritdoc} * * @api */ public function replace(array $headers = array()) { $this->headerNames = array(); parent::replace($headers); }