34 public function setUp()
37 $this->client =
new Client(
'http://foo.com/baz');
38 $this->operation =
new Operation(array(
'httpMethod' =>
'POST'));
39 $this->command = $this->getMockBuilder(
'Guzzle\Service\Command\AbstractCommand')
40 ->setConstructorArgs(array(array(), $this->operation))
41 ->getMockForAbstractClass();
42 $this->command->setClient($this->client);
48 $this->command[
'test'] =
'123';
49 $this->operation->addParam(
new Parameter(array(
'name' =>
'test',
'location' =>
'custom')));
50 $request = $this->serializer->prepare($this->command);
51 $this->assertEquals(
'123', (
string)
$request->getHeader(
'test'));
56 $this->operation->setUri(
'bar');
57 $request = $this->serializer->prepare($this->command);
58 $this->assertEquals(
'http://foo.com/baz/bar', (
string)
$request->getUrl());
63 $this->command[
'test'] =
'123';
64 $this->operation->setUri(
'bar/{test}');
65 $this->operation->addParam(
new Parameter(array(
'name' =>
'test',
'location' =>
'uri')));
66 $request = $this->serializer->prepare($this->command);
67 $this->assertEquals(
'http://foo.com/baz/bar/123', (
string)
$request->getUrl());
74 $this->assertSame($f, $this->readAttribute(
$serializer,
'factory'));
79 $this->operation->setUri(
'bar{?limit,fields}');
80 $this->operation->addParam(
new Parameter(array(
91 $this->command[
'fields'] = array(
'id',
'name');
93 $request = $this->serializer->prepare($this->command);
94 $this->assertEquals(
'http://foo.com/baz/bar?fields='.urlencode(
'id,name'), (
string)
$request->getUrl());
100 'operations' => array(
102 'httpMethod' =>
'PUT',
103 'parameters' => array(
104 'bar' => array(
'location' =>
'header')
106 'additionalParameters' => array(
114 $client->setDescription($description);
119 $this->assertEquals(
'test', (
string)
$request->getHeader(
'bar'));
120 $this->assertEquals(
'{"hello":"abc"}', (
string)
$request->getBody());