summaryrefslogtreecommitdiff
path: root/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/AbstractVisitorTestCase.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/AbstractVisitorTestCase.php')
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/AbstractVisitorTestCase.php110
1 files changed, 110 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/AbstractVisitorTestCase.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/AbstractVisitorTestCase.php
new file mode 100644
index 0000000..46b472e
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/AbstractVisitorTestCase.php
@@ -0,0 +1,110 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
+
+use Guzzle\Http\Message\EntityEnclosingRequest;
+use Guzzle\Service\Description\Operation;
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Service\Description\SchemaValidator;
+use Guzzle\Service\Command\OperationCommand;
+use Guzzle\Tests\Service\Mock\Command\MockCommand;
+use Guzzle\Tests\Service\Mock\MockClient;
+
+abstract class AbstractVisitorTestCase extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected $command;
+ protected $request;
+ protected $param;
+ protected $validator;
+
+ public function setUp()
+ {
+ $this->command = new MockCommand();
+ $this->request = new EntityEnclosingRequest('POST', 'http://www.test.com/some/path.php');
+ $this->validator = new SchemaValidator();
+ }
+
+ protected function getCommand($location)
+ {
+ $command = new OperationCommand(array(), $this->getNestedCommand($location));
+ $command->setClient(new MockClient());
+
+ return $command;
+ }
+
+ protected function getNestedCommand($location)
+ {
+ return new Operation(array(
+ 'httpMethod' => 'POST',
+ 'parameters' => array(
+ 'foo' => new Parameter(array(
+ 'type' => 'object',
+ 'location' => $location,
+ 'sentAs' => 'Foo',
+ 'required' => true,
+ 'properties' => array(
+ 'test' => array(
+ 'type' => 'object',
+ 'required' => true,
+ 'properties' => array(
+ 'baz' => array(
+ 'type' => 'boolean',
+ 'default' => true
+ ),
+ 'jenga' => array(
+ 'type' => 'string',
+ 'default' => 'hello',
+ 'sentAs' => 'Jenga_Yall!',
+ 'filters' => array('strtoupper')
+ )
+ )
+ ),
+ 'bar' => array('default' => 123)
+ ),
+ 'additionalProperties' => array(
+ 'type' => 'string',
+ 'filters' => array('strtoupper'),
+ 'location' => $location
+ )
+ )),
+ 'arr' => new Parameter(array(
+ 'type' => 'array',
+ 'location' => $location,
+ 'items' => array(
+ 'type' => 'string',
+ 'filters' => array('strtoupper')
+ )
+ )),
+ )
+ ));
+ }
+
+ protected function getCommandWithArrayParamAndFilters()
+ {
+ $operation = new Operation(array(
+ 'httpMethod' => 'POST',
+ 'parameters' => array(
+ 'foo' => new Parameter(array(
+ 'type' => 'string',
+ 'location' => 'query',
+ 'sentAs' => 'Foo',
+ 'required' => true,
+ 'default' => 'bar',
+ 'filters' => array('strtoupper')
+ )),
+ 'arr' => new Parameter(array(
+ 'type' => 'array',
+ 'location' => 'query',
+ 'sentAs' => 'Arr',
+ 'required' => true,
+ 'default' => array(123, 456, 789),
+ 'filters' => array(array('method' => 'implode', 'args' => array(',', '@value')))
+ ))
+ )
+ ));
+ $command = new OperationCommand(array(), $operation);
+ $command->setClient(new MockClient());
+
+ return $command;
+ }
+}