25 'documentationUrl' =>
'http://www.example.com',
26 'httpMethod' =>
'POST',
28 'responseClass' =>
'array',
29 'responseNotes' =>
'returns the json_decoded response',
31 'parameters' => array(
45 $this->assertEquals(
'test', $c->getName());
46 $this->assertEquals(
'doc', $c->getSummary());
47 $this->assertEquals(
'http://www.example.com', $c->getDocumentationUrl());
48 $this->assertEquals(
'POST', $c->getHttpMethod());
49 $this->assertEquals(
'/api/v1', $c->getUri());
50 $this->assertEquals(
'array', $c->getResponseClass());
51 $this->assertEquals(
'returns the json_decoded response', $c->getResponseNotes());
52 $this->assertTrue($c->getDeprecated());
53 $this->assertEquals(
'Guzzle\\Service\\Command\\OperationCommand', $c->getClass());
54 $this->assertEquals(array(
77 )), $c->getParam(
'key_2'));
79 $this->assertNull($c->getParam(
'afefwef'));
80 $this->assertArrayNotHasKey(
'parent', $c->getParam(
'key_2')->toArray());
87 'class' =>
'Guzzle\\Service\\Command\ClosureCommand',
88 'parameters' => array(
94 $this->assertEquals(
'Guzzle\\Service\\Command\ClosureCommand', $c->getClass());
101 'class' =>
'Guzzle\\Service\\Command\ClosureCommand',
103 'documentationUrl' =>
'http://www.example.com',
104 'httpMethod' =>
'PUT',
106 'parameters' => array(
'p' => array(
'name' =>
'foo'))
109 $toArray = $c->toArray();
110 unset($data[
'name']);
111 $this->assertArrayHasKey(
'parameters', $toArray);
112 $this->assertInternalType(
'array', $toArray[
'parameters']);
115 unset($data[
'parameters']);
116 unset($toArray[
'parameters']);
118 $data[
'responseType'] =
'primitive';
119 $data[
'responseClass'] =
'array';
120 $this->assertEquals($data, $toArray);
126 $this->assertTrue($command->hasParam(
'data'));
127 $this->assertFalse($command->hasParam(
'baz'));
133 $this->assertEquals(array(
'data'), $command->getParamNames());
139 'parameters' => array(
152 ->setDeprecated(
false)
153 ->setSummary(
'summary')
154 ->setDocumentationUrl(
'http://www.foo.com')
155 ->setHttpMethod(
'PUT')
156 ->setResponseNotes(
'oh')
157 ->setResponseClass(
'string')
163 $this->assertEquals(
'foo', $c->getName());
164 $this->assertEquals(
'Baz', $c->getClass());
165 $this->assertEquals(
false, $c->getDeprecated());
166 $this->assertEquals(
'summary', $c->getSummary());
167 $this->assertEquals(
'http://www.foo.com', $c->getDocumentationUrl());
168 $this->assertEquals(
'PUT', $c->getHttpMethod());
169 $this->assertEquals(
'oh', $c->getResponseNotes());
170 $this->assertEquals(
'string', $c->getResponseClass());
171 $this->assertEquals(
'/foo/bar', $c->getUri());
172 $this->assertEquals(array(
'test'), $c->getParamNames());
178 $c->addParam(
new Parameter(array(
'name' =>
'foo')));
179 $this->assertTrue($c->hasParam(
'foo'));
180 $c->removeParam(
'foo');
181 $this->assertFalse($c->hasParam(
'foo'));
186 $command =
new Operation(array(
'parameters' => array(
'foo' =>
new Parameter(array()))));
187 $this->assertEquals(
'foo', $command->getParam(
'foo')->getName());
193 $this->assertEquals(1, count($command->getErrorResponses()));
194 $arr = $command->toArray();
195 $this->assertEquals(1, count($arr[
'errorResponses']));
196 $command->addErrorResponse(400,
'Foo',
'Baz\\Bar');
197 $this->assertEquals(2, count($command->getErrorResponses()));
198 $command->setErrorResponses(array());
199 $this->assertEquals(0, count($command->getErrorResponses()));
204 $o =
new Operation(array(
'notes' =>
'foo'));
205 $this->assertEquals(
'foo', $o->getNotes());
207 $this->assertEquals(
'bar', $o->getNotes());
212 $o =
new Operation(array(
'data' => array(
'foo' =>
'baz',
'bar' => 123)));
213 $o->setData(
'test',
false);
214 $this->assertEquals(
'baz', $o->getData(
'foo'));
215 $this->assertEquals(123, $o->getData(
'bar'));
216 $this->assertNull($o->getData(
'wfefwe'));
217 $this->assertEquals(array(
218 'parameters' => array(),
219 'class' =>
'Guzzle\Service\Command\OperationCommand',
220 'data' => array(
'foo' =>
'baz',
'bar' => 123,
'test' =>
false),
221 'responseClass' =>
'array',
222 'responseType' =>
'primitive'
230 $this->assertSame($s, $o->getServiceDescription());
238 $o =
new Operation(array(
'responseClass' =>
'array',
'responseType' =>
'foo'));
244 $o->setServiceDescription(
new ServiceDescription(array(
'models' => array(
'Foo' => array()))));
245 $this->assertEquals(
'primitive', $o->getResponseType());
246 $this->assertEquals(
'primitive', $o->setResponseClass(
'boolean')->getResponseType());
247 $this->assertEquals(
'primitive', $o->setResponseClass(
'array')->getResponseType());
248 $this->assertEquals(
'primitive', $o->setResponseClass(
'integer')->getResponseType());
249 $this->assertEquals(
'primitive', $o->setResponseClass(
'string')->getResponseType());
250 $this->assertEquals(
'class', $o->setResponseClass(
'foo')->getResponseType());
251 $this->assertEquals(
'class', $o->setResponseClass(__CLASS__)->getResponseType());
252 $this->assertEquals(
'model', $o->setResponseClass(
'Foo')->getResponseType());
258 $o =
new Operation(array(
'responseClass' =>
'array'));
259 $this->assertEquals(
'primitive', $o->getResponseType());
262 $this->assertEquals(
'primitive', $o->getResponseType());
263 $this->assertEquals(
'model', $o->setResponseType(
'model')->getResponseType());
269 'additionalParameters' => array(
270 'type' =>
'string',
'name' =>
'binks'
272 'parameters' => array(
273 'foo' => array(
'type' =>
'integer')
276 $this->assertEquals(
'string', $o->getAdditionalParameters()->getType());
277 $arr = $o->toArray();
278 $this->assertEquals(array(
280 ), $arr[
'additionalParameters']);
289 'name' =>
'OperationTest',
290 'class' => get_class($this),
291 'parameters' => array(
292 'test' => array(
'type' =>
'object'),
293 'bool_1' => array(
'default' =>
true,
'type' =>
'boolean'),
294 'bool_2' => array(
'default' =>
false),
295 'float' => array(
'type' =>
'numeric'),
296 'int' => array(
'type' =>
'integer'),
297 'date' => array(
'type' =>
'string'),
298 'timestamp' => array(
'type' =>
'string'),
299 'string' => array(
'type' =>
'string'),
300 'username' => array(
'type' =>
'string',
'required' =>
true,
'filters' =>
'strtolower'),
301 'test_function' => array(
'type' =>
'string',
'filters' => __CLASS__ .
'::strtoupper')
303 'errorResponses' => array(
304 array(
'code' => 503,
'reason' =>
'InsufficientCapacity',
'class' =>
'Guzzle\\Exception\\RuntimeException')