Exemple #1
0
 public function testCreatePost()
 {
     $post = new Post();
     $post->setTitle('optio reprehenderit');
     $post->setBody('facere repellat provident occaecati excepturi optio reprehenderit');
     $post->setUserId('1');
     $postCreated = $this->api->posts()->create($post);
     static::assertEquals(101, $postCreated->getId());
 }
 /**
  * @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());
    }