16 $visitor =
new Visitor();
17 $command = $this->getMockBuilder(
'Guzzle\Service\Command\AbstractCommand')
18 ->setMethods(array(
'getResponse'))
19 ->getMockForAbstractClass();
21 ->method(
'getResponse')
22 ->will($this->returnValue(
new Response(200,
null,
'<foo><Bar>test</Bar></foo>')));
25 $this->assertEquals(array(
'Bar' =>
'test'), $result);
30 $this->markTestSkipped(
"Response/XmlVisitor cannot accept 'xmlns' in response, see #368 (http://git.io/USa1mA).");
32 $visitor =
new Visitor();
33 $command = $this->getMockBuilder(
'Guzzle\Service\Command\AbstractCommand')
34 ->setMethods(array(
'getResponse'))
35 ->getMockForAbstractClass();
37 ->method(
'getResponse')
38 ->will($this->returnValue(
new Response(200,
null,
'<foo xmlns="urn:foo"><bar:Bar xmlns:bar="urn:bar">test</bar:Bar></foo>')));
41 $this->assertEquals(array(
'Bar' =>
'test'), $result);
46 $visitor =
new Visitor();
47 $command = $this->getMockBuilder(
'Guzzle\Service\Command\AbstractCommand')
48 ->setMethods(array(
'getResponse'))
49 ->getMockForAbstractClass();
51 ->method(
'getResponse')
52 ->will($this->returnValue(
new Response(200,
null,
'<foo><Items><Bar>test</Bar></Items></foo>')));
55 $this->assertEquals(array(
'Items' => array(
'Bar' =>
'test')), $result);
60 $visitor =
new Visitor();
66 $value = array(
'Bar' =>
'test');
67 $visitor->visit($this->command, $this->response, $param,
$value);
68 $this->assertArrayHasKey(
'foo',
$value);
69 $this->assertEquals(
'test',
$value[
'foo']);
74 $visitor =
new Visitor();
82 'properties' => array(
83 'Bar' => array(
'type' =>
'string'),
84 'Baz' => array(
'type' =>
'string'),
85 'Bam' => array(
'type' =>
'string')
90 $xml = new \SimpleXMLElement(
'<Test><Foo><Bar>1</Bar><Baz>2</Baz></Foo></Test>');
91 $value = json_decode(json_encode($xml),
true);
92 $visitor->visit($this->command, $this->response, $param,
$value);
93 $this->assertEquals(array(
105 $visitor =
new Visitor();
110 'items' => array(
'type' =>
'string')
113 $value = array(
'foo' => array(
'bar',
'baz'));
114 $visitor->visit($this->command, $this->response, $param,
$value);
115 $this->assertEquals(array(
'foo' => array(
'bar',
'baz')),
$value);
117 $value = array(
'foo' =>
'bar');
118 $visitor->visit($this->command, $this->response, $param,
$value);
119 $this->assertEquals(array(
'foo' => array(
'bar')),
$value);
131 'properties' => array(
132 'Bar' => array(
'type' =>
'string'),
133 'Baz' => array(
'type' =>
'string')
139 array($param,
'<Test><Items><Item><Bar>1</Bar></Item><Item><Bar>2</Bar></Item></Items></Test>', array(
145 array($param,
'<Test><Items><Item><Bar>1</Bar></Item></Items></Test>', array(
150 array($param,
'<Test><Items /></Test>', array(
161 $visitor =
new Visitor();
162 $xml = new \SimpleXMLElement($xml);
163 $value = json_decode(json_encode($xml),
true);
164 $visitor->visit($this->command, $this->response, $param,
$value);
165 $this->assertEquals($result,
$value);
170 $visitor =
new Visitor();
172 'name' =>
'TerminatingInstances',
175 'sentAs' =>
'instancesSet',
180 'properties' => array(
181 'InstanceId' => array(
183 'sentAs' =>
'instanceId',
185 'CurrentState' => array(
187 'sentAs' =>
'currentState',
188 'properties' => array(
199 'PreviousState' => array(
201 'sentAs' =>
'previousState',
202 'properties' => array(
218 'instancesSet' => array (
220 'instanceId' =>
'i-3ea74257',
221 'currentState' => array(
223 'name' =>
'shutting-down',
225 'previousState' => array(
233 $visitor->visit($this->command, $this->response, $param,
$value);
235 $this->assertEquals(array(
236 'TerminatingInstances' => array(
238 'InstanceId' =>
'i-3ea74257',
239 'CurrentState' => array(
241 'Name' =>
'shutting-down',
243 'PreviousState' => array(
254 $visitor =
new Visitor();
256 'name' =>
'RunningQueues',
262 'properties' => array(
265 'sentAs' =>
'queue_id',
267 'xmlAttribute' =>
true,
270 'CurrentState' => array(
272 'properties' => array(
277 'xmlAttribute' =>
true,
283 'xmlAttribute' =>
true,
288 'PreviousState' => array(
290 'properties' => array(
295 'xmlAttribute' =>
true,
301 'xmlAttribute' =>
true,
310 $xml =
'<wrap><RunningQueues><item queue_id="q-3ea74257"><CurrentState code="32" name="processing" /><PreviousState code="16" name="wait" /></item></RunningQueues></wrap>';
311 $value = json_decode(json_encode(
new \SimpleXMLElement($xml)),
true);
312 $visitor->visit($this->command, $this->response, $param,
$value);
314 $this->assertEquals(array(
315 'RunningQueues' => array(
317 'QueueId' =>
'q-3ea74257',
318 'CurrentState' => array(
320 'Name' =>
'processing',
322 'PreviousState' => array(
333 $visitor =
new Visitor();
340 'properties' => array(
341 'Baz' => array(
'type' =>
'array'),
344 'properties' => array(
345 'Baz' => array(
'type' =>
'array'),
353 $visitor->visit($this->command, $this->response, $param,
$value);
360 $visitor->visit($this->command, $this->response, $param,
$value);
361 $this->assertEquals(array(
376 $visitor =
new Visitor();
380 'additionalProperties' =>
false,
381 'properties' => array(
388 $this->value = array(
'foo' => array(
'bar' => 15,
'unknown' =>
'Unknown'));
389 $visitor->visit($this->command, $this->response, $param, $this->value);
390 $this->assertEquals(array(
'foo' => array(
'bar' => 15)), $this->value);
399 $visitor =
new Visitor();
403 'additionalProperties' =>
false,
404 'properties' => array(
411 $this->value = array(
'foo' => array(
'baz' => 15,
'unknown' =>
'Unknown'));
412 $visitor->visit($this->command, $this->response, $param, $this->value);
413 $this->assertEquals(array(
'foo' => array(
'bar' => 15)), $this->value);
418 $visitor =
new Visitor();
422 'properties' => array(
423 'bar' => array(
'type' =>
'string')
426 $xml =
'<wrapper><foo><bar /></foo></wrapper>';
427 $value = json_decode(json_encode(
new \SimpleXMLElement($xml)),
true);
428 $visitor->visit($this->command, $this->response, $param,
$value);
429 $this->assertEquals(array(
'foo' => array(
'bar' =>
'')),
$value);