Пример #1
0
 public function testAllowsXmlEncoding()
 {
     $location = new XmlLocation('xml');
     $operation = new Operation(['data' => ['xmlEncoding' => 'UTF-8']], new Description([]));
     $command = $this->getCommand($operation);
     $request = new Request('POST', 'http://httbin.org');
     $param = new Parameter(['name' => 'foo']);
     $command['foo'] = 'bar';
     $location->visit($command, $request, $param, []);
     $location->after($command, $request, $operation, []);
     $xml = (string) $request->getBody();
     $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<Request><foo>bar</foo></Request>' . "\n", $xml);
 }
 /**
  * {@inheritdoc}
  */
 public function after(CommandInterface $command, RequestInterface $request, Operation $operation, array $context)
 {
     parent::after($command, $request, $operation, $context);
     /** @var \GuzzleHttp\Stream\StreamInterface $xml */
     $xml = $request->getBody();
     if ($xml) {
         $request->getQuery()->set('xml', $this->trimXml($xml->getContents()));
         $request->setBody(null);
     }
 }