public function testBodyMutatorReturnsCloneWithChanges()
 {
     $stream = $this->getMock('Psr\\Http\\Message\\StreamInterface');
     $message = $this->message->withBody($stream);
     $this->assertNotSame($this->message, $message);
     $this->assertSame($stream, $message->getBody());
 }
Esempio n. 2
0
 public function testWithBody()
 {
     $mockBody = Mockery::mock(StreamInterface::class);
     $messageWithBody = $this->message->withBody($mockBody);
     static::assertNull($this->message->getBody());
     // return null
     // The body MUST be a StreamInterface object.
     static::assertNotSame($this->message, $messageWithBody);
     // This method MUST be implemented in such a way as to retain the
     // immutability of the message, and MUST return a new instance that has the
     // new body stream.
     static::assertInstanceOf(StreamInterface::class, $messageWithBody->getBody());
     static::assertSame($mockBody, $messageWithBody->getBody());
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function withBody(StreamInterface $body)
 {
     $new = clone $this;
     $new->message = $this->message->withBody($body);
     return $new;
 }