1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49:
<?php
namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
use Guzzle\Service\Description\Parameter;
use Guzzle\Service\Command\LocationVisitor\Request\HeaderVisitor as Visitor;
class HeaderVisitorTest extends AbstractVisitorTestCase
{
public function testValidatesHeaderMapsAreArrays()
{
$visitor = new Visitor();
$param = $this->getNestedCommand('header')->getParam('foo')->setSentAs('test');
$param->setAdditionalProperties(new Parameter(array()));
$visitor->visit($this->command, $this->request, $param, 'test');
}
public function testVisitsLocation()
{
$visitor = new Visitor();
$param = $this->getNestedCommand('header')->getParam('foo')->setSentAs('test');
$param->setAdditionalProperties(false);
$visitor->visit($this->command, $this->request, $param, '123');
$this->assertEquals('123', (string) $this->request->getHeader('test'));
}
public function testVisitsMappedPrefixHeaders()
{
$visitor = new Visitor();
$param = $this->getNestedCommand('header')->getParam('foo')->setSentAs('test');
$param->setSentAs('x-foo-');
$param->setAdditionalProperties(new Parameter(array(
'type' => 'string'
)));
$visitor->visit($this->command, $this->request, $param, array(
'bar' => 'test',
'baz' => '123'
));
$this->assertEquals('test', (string) $this->request->getHeader('x-foo-bar'));
$this->assertEquals('123', (string) $this->request->getHeader('x-foo-baz'));
}
}