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\Command\LocationVisitor\Request\QueryVisitor as Visitor;
class QueryVisitorTest extends AbstractVisitorTestCase
{
public function testVisitsLocation()
{
$visitor = new Visitor();
$param = $this->getNestedCommand('query')->getParam('foo')->setSentAs('test');
$visitor->visit($this->command, $this->request, $param, '123');
$this->assertEquals('123', $this->request->getQuery()->get('test'));
}
public function testRecursivelyBuildsQueryStrings()
{
$command = $this->getCommand('query');
$command->getOperation()->getParam('foo')->setSentAs('Foo');
$request = $command->prepare();
$this->assertEquals(
'Foo[test][baz]=1&Foo[test][Jenga_Yall!]=HELLO&Foo[bar]=123',
rawurldecode($request->getQuery())
);
}
public function testFiltersAreAppliedToArrayParamType()
{
$command = $this->getCommandWithArrayParamAndFilters();
$request = $command->prepare();
$query = $request->getQuery();
$this->assertEquals('BAR', $query->get('Foo'));
$this->assertEquals('123,456,789', $query->get('Arr'));
}
}