| 1 | <?php |
||
| 12 | class ResponseTest extends TestCase |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var StreamInterface|MockInterface |
||
| 16 | */ |
||
| 17 | private $body; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var ResponseInterface|MockInterface |
||
| 21 | */ |
||
| 22 | private $psr; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var Response |
||
| 26 | */ |
||
| 27 | private $response; |
||
| 28 | |||
| 29 | public function setUp() |
||
| 30 | { |
||
| 31 | $this->body = Mockery::spy(StreamInterface::class); |
||
| 32 | $this->psr = Mockery::spy(ResponseInterface::class, ['getBody' => $this->body]); |
||
| 33 | $this->response = new Response($this->psr); |
||
| 34 | } |
||
| 35 | |||
| 36 | public function tearDown() |
||
| 37 | { |
||
| 38 | Mockery::close(); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @test |
||
| 43 | */ |
||
| 44 | public function canAppendStringToBody() |
||
| 45 | { |
||
| 46 | $result = $this->response->append('abc'); |
||
| 47 | |||
| 48 | $this->assertInstanceOf(\Venta\Contracts\Http\Response::class, $result); |
||
| 49 | $this->assertSame($this->response, $result); |
||
| 50 | $this->body->shouldHaveReceived('write')->with('abc'); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @return @test |
||
| 55 | */ |
||
| 56 | public function canBeInitialized() |
||
| 57 | { |
||
| 58 | $this->body->shouldReceive('__toString')->andReturn(''); |
||
| 59 | |||
| 60 | $this->assertEmpty($this->response->getContent()); |
||
| 61 | |||
| 62 | $this->body->shouldHaveReceived('__toString')->withNoArgs(); |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @test |
||
| 67 | */ |
||
| 68 | public function implementsResponseContract() |
||
| 69 | { |
||
| 70 | $this->assertInstanceOf(\Venta\Contracts\Http\Response::class, $this->response); |
||
| 71 | } |
||
| 72 | } |