Esempio n. 1
0
 /**
  * @inheritDoc
  */
 public function mock(RequestInterface $request)
 {
     $body = $request->getBody()->getContents();
     $bodyArray = QueryString::fromString($body);
     $post = new Post();
     $post->setId(101);
     $post->setTitle($bodyArray['title']);
     $post->setUserId($bodyArray['userId']);
     $post->setBody($bodyArray['body']);
     return new Response(200, [], SerializerBuilder::create()->build()->serialize($post, 'json'));
 }
    public function testWithXmlBody()
    {
        $post = new Post();
        $post->setId(1);
        $post->setTitle('title');
        $post->setBody('body');
        $post->setUserId(1);
        $this->rb->withXMLBody($post);
        $xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<result>
  <userId>1</userId>
  <id>1</id>
  <title><![CDATA[title]]></title>
  <body><![CDATA[body]]></body>
</result>

XML;
        static::assertEquals($xml, $this->rb->getBody());
    }