summaryrefslogtreecommitdiff
path: root/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/QueryVisitorTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/QueryVisitorTest.php')
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/QueryVisitorTest.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/QueryVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/QueryVisitorTest.php
new file mode 100644
index 0000000..607af76
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/QueryVisitorTest.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
+
+use Guzzle\Service\Command\LocationVisitor\Request\QueryVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\QueryVisitor
+ */
+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'));
+ }
+
+ /**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\QueryVisitor
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\AbstractRequestVisitor::resolveRecursively
+ */
+ 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())
+ );
+ }
+
+ /**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\AbstractRequestVisitor::resolveRecursively
+ */
+ public function testFiltersAreAppliedToArrayParamType()
+ {
+ $command = $this->getCommandWithArrayParamAndFilters();
+ $request = $command->prepare();
+ $query = $request->getQuery();
+ // param type 'string'
+ $this->assertEquals('BAR', $query->get('Foo'));
+ // param type 'array'
+ $this->assertEquals('123,456,789', $query->get('Arr'));
+ }
+}