summaryrefslogtreecommitdiff
path: root/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock')
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/IterableCommand.php31
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/MockCommand.php32
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/OtherCommand.php30
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/Sub/Sub.php7
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/MockClient.php36
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Model/MockCommandIterator.php42
6 files changed, 178 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/IterableCommand.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/IterableCommand.php
new file mode 100644
index 0000000..4ab423e
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/IterableCommand.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Guzzle\Tests\Service\Mock\Command;
+
+use Guzzle\Service\Description\Operation;
+
+class IterableCommand extends MockCommand
+{
+ protected function createOperation()
+ {
+ return new Operation(array(
+ 'name' => 'iterable_command',
+ 'parameters' => array(
+ 'page_size' => array('type' => 'integer'),
+ 'next_token' => array('type' => 'string')
+ )
+ ));
+ }
+
+ protected function build()
+ {
+ $this->request = $this->client->createRequest('GET');
+
+ // Add the next token and page size query string values
+ $this->request->getQuery()->set('next_token', $this->get('next_token'));
+
+ if ($this->get('page_size')) {
+ $this->request->getQuery()->set('page_size', $this->get('page_size'));
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/MockCommand.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/MockCommand.php
new file mode 100644
index 0000000..831a7e7
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/MockCommand.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Guzzle\Tests\Service\Mock\Command;
+
+use Guzzle\Service\Description\Operation;
+
+class MockCommand extends \Guzzle\Service\Command\AbstractCommand
+{
+ protected function createOperation()
+ {
+ return new Operation(array(
+ 'name' => get_called_class() == __CLASS__ ? 'mock_command' : 'sub.sub',
+ 'httpMethod' => 'POST',
+ 'parameters' => array(
+ 'test' => array(
+ 'default' => 123,
+ 'required' => true,
+ 'doc' => 'Test argument'
+ ),
+ '_internal' => array(
+ 'default' => 'abc'
+ ),
+ 'foo' => array('filters' => array('strtoupper'))
+ )
+ ));
+ }
+
+ protected function build()
+ {
+ $this->request = $this->client->createRequest();
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/OtherCommand.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/OtherCommand.php
new file mode 100644
index 0000000..72ae1f6
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/OtherCommand.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Guzzle\Tests\Service\Mock\Command;
+
+use Guzzle\Service\Description\Operation;
+
+class OtherCommand extends MockCommand
+{
+ protected function createOperation()
+ {
+ return new Operation(array(
+ 'name' => 'other_command',
+ 'parameters' => array(
+ 'test' => array(
+ 'default' => '123',
+ 'required' => true,
+ 'doc' => 'Test argument'
+ ),
+ 'other' => array(),
+ 'arg' => array('type' => 'string'),
+ 'static' => array('static' => true, 'default' => 'this is static')
+ )
+ ));
+ }
+
+ protected function build()
+ {
+ $this->request = $this->client->getRequest('HEAD');
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/Sub/Sub.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/Sub/Sub.php
new file mode 100644
index 0000000..d348480
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/Sub/Sub.php
@@ -0,0 +1,7 @@
+<?php
+
+namespace Guzzle\Tests\Service\Mock\Command\Sub;
+
+use Guzzle\Tests\Service\Mock\Command\MockCommand;
+
+class Sub extends MockCommand {}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/MockClient.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/MockClient.php
new file mode 100644
index 0000000..6b9f55a
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/MockClient.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Guzzle\Tests\Service\Mock;
+
+use Guzzle\Common\Collection;
+use Guzzle\Service\Client;
+
+/**
+ * Mock Guzzle Service
+ */
+class MockClient extends Client
+{
+ /**
+ * Factory method to create a new mock client
+ *
+ * @param array|Collection $config Configuration data. Array keys:
+ * base_url - Base URL of web service
+ * api_version - API version
+ * scheme - URI scheme: http or https
+ * * username - API username
+ * * password - API password
+ * * subdomain - Unfuddle account subdomain
+ *
+ * @return MockClient
+ */
+ public static function factory($config = array())
+ {
+ $config = Collection::fromConfig($config, array(
+ 'base_url' => '{scheme}://127.0.0.1:8124/{api_version}/{subdomain}',
+ 'scheme' => 'http',
+ 'api_version' => 'v1'
+ ), array('username', 'password', 'subdomain'));
+
+ return new self($config->get('base_url'), $config);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Model/MockCommandIterator.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Model/MockCommandIterator.php
new file mode 100644
index 0000000..8faf412
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Model/MockCommandIterator.php
@@ -0,0 +1,42 @@
+<?php
+
+namespace Guzzle\Tests\Service\Mock\Model;
+
+use Guzzle\Service\Resource\ResourceIterator;
+
+class MockCommandIterator extends ResourceIterator
+{
+ public $calledNext = 0;
+
+ protected function sendRequest()
+ {
+ if ($this->nextToken) {
+ $this->command->set('next_token', $this->nextToken);
+ }
+
+ $this->command->set('page_size', (int) $this->calculatePageSize());
+ $this->command->execute();
+
+ $data = json_decode($this->command->getResponse()->getBody(true), true);
+
+ $this->nextToken = $data['next_token'];
+
+ return $data['resources'];
+ }
+
+ public function next()
+ {
+ $this->calledNext++;
+ parent::next();
+ }
+
+ public function getResources()
+ {
+ return $this->resources;
+ }
+
+ public function getIteratedCount()
+ {
+ return $this->iteratedCount;
+ }
+}