29 'doc' =>
'documentationForCommand',
31 'class' =>
'Guzzle\\Tests\\Service\\Mock\\Command\\MockCommand',
48 $client =
new Mock\MockClient(
null, array(
51 $command = $client->getCommand(
'mock_command');
58 'base_url' =>
'http://www.test.com/',
62 $this->assertEquals(
'http://www.test.com/', $client->getBaseUrl());
63 $this->assertEquals(
'123', $client->getConfig(
'test'));
79 $this->
getServer()->enqueue(
"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
83 $client->execute($cmd);
85 $this->assertInstanceOf(
'Guzzle\\Http\\Message\\Response', $cmd->getResponse());
86 $this->assertInstanceOf(
'Guzzle\\Http\\Message\\Response', $cmd->getResult());
87 $this->assertEquals(1, count($this->
getServer()->getReceivedRequests(
false)));
92 $client =
new Client(
'http://www.test.com/');
93 $client->getEventDispatcher()->addSubscriber(
new MockPlugin(array(
100 $client->execute($set);
103 $this->assertTrue($set[0]->isExecuted());
104 $this->assertTrue($set[1]->isExecuted());
113 $client->execute(
new \stdClass());
123 $mock = $this->getMock(
'Guzzle\\Service\\Command\\Factory\\FactoryInterface');
124 $mock->expects($this->any())
126 ->with($this->equalTo(
'test'))
127 ->will($this->returnValue(
null));
129 $client->setCommandFactory($mock);
130 $client->getCommand(
'test');
137 $client =
new Mock\MockClient();
138 $mock = $this->getMock(
'Guzzle\\Service\\Command\\Factory\\FactoryInterface');
139 $mock->expects($this->any())
141 ->with($this->equalTo(
'foo'))
142 ->will($this->returnValue($mockCommand));
144 $client->setCommandFactory($mock);
146 $command = $client->getCommand(
'foo', array(
'acl' =>
'123'));
147 $this->assertSame($mockCommand, $command);
148 $command = $client->getCommand(
'foo', array(
'acl' =>
'123'));
149 $this->assertSame($mockCommand, $command);
150 $this->assertSame($client, $command->getClient());
155 $client =
new Mock\MockClient();
156 $this->assertNull($client->getDescription());
158 $description = $this->getMock(
'Guzzle\\Service\\Description\\ServiceDescription');
159 $this->assertSame($client, $client->setDescription($description));
160 $this->assertSame($description, $client->getDescription());
165 $client =
new Mock\MockClient();
167 $method = new \ReflectionMethod($client,
'getResourceIteratorFactory');
168 $method->setAccessible(TRUE);
169 $rf1 = $method->invoke($client);
171 $rf = $this->readAttribute($client,
'resourceIteratorFactory');
172 $this->assertInstanceOf(
'Guzzle\\Service\\Resource\\ResourceIteratorClassFactory', $rf);
173 $this->assertSame($rf1, $rf);
176 $client->setResourceIteratorFactory($rf);
177 $this->assertNotSame($rf1, $rf);
184 "HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nHi",
185 "HTTP/1.1 200 OK\r\nContent-Length: 1\r\n\r\nI"
188 $client =
new Mock\MockClient($this->
getServer()->getUrl());
190 $command = $client->getCommand(
'mock_command');
191 $client->execute($command);
192 $client->execute($command);
193 $this->assertEquals(
'I', $command->getResponse()->getBody(
true));
198 $client =
new Mock\MockClient();
200 $iterator = $client->getIterator(
'mock_command', array(
206 $this->assertInstanceOf(
'Guzzle\Tests\Service\Mock\Model\MockCommandIterator', $iterator);
207 $this->assertEquals(10, $this->readAttribute($iterator,
'limit'));
209 $command = $this->readAttribute($iterator,
'originalCommand');
210 $this->assertEquals(
'bar', $command->get(
'foo'));
215 $client =
new Mock\MockClient();
216 $iterator = $client->getIterator(
'mock_command');
217 $this->assertInstanceOf(
'Guzzle\Tests\Service\Mock\Model\MockCommandIterator', $iterator);
222 $client =
new Mock\MockClient();
224 $iterator = $client->getIterator($command);
225 $this->assertInstanceOf(
'Guzzle\Tests\Service\Mock\Model\MockCommandIterator', $iterator);
226 $iteratorCommand = $this->readAttribute($iterator,
'originalCommand');
227 $this->assertSame($command, $iteratorCommand);
232 $client =
new Mock\MockClient();
233 $this->assertInstanceOf(
'Guzzle\Inflection\MemoizingInflector', $client->getInflector());
236 $client->setInflector($inflector);
237 $this->assertSame($inflector, $client->getInflector());
242 $client =
new Mock\MockClient(
'http://www.foo.com', array(
247 $command = $client->getCommand(
'mock_command');
248 $this->assertEquals(
'bar', $command->get(
'mesa'));
255 $client->setDescription($description);
256 $this->assertEquals(
'http://foo.com', $client->getBaseUrl());
261 $client =
new Mock\MockClient(
'http://www.foo.com', array(
267 $command = $client->getCommand(
'mock_command', array(
'jar' =>
'test'));
268 $this->assertEquals(
'bar', $command->get(
'mesa'));
269 $this->assertEquals(
'test', $command->get(
'jar'));
277 $client =
new Mock\MockClient(
'http://foobaz.com');
279 $client->addSubscriber($mock);
285 $client =
new Mock\MockClient(
'http://foobaz.com');
287 $client->addSubscriber($mock);
291 $client->execute($cmds);
299 $this->assertTrue($c->getResponse()->isSuccessful());
303 $this->assertFalse($c->getRequest()->getResponse()->isSuccessful());
313 $client =
new Mock\MockClient();
315 $client->setDescription($service1);
316 $client->getCommand(
'foo_bar');
317 $client->setDescription($service2);
318 $client->getCommand(
'baz_qux');