Passed
Branch master (e8fd46)
by Alexey
02:50
created

ResponseTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 61
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 3
1
<?php
2
3
use Mockery\MockInterface;
4
use PHPUnit\Framework\TestCase;
5
use Psr\Http\Message\ResponseInterface;
6
use Psr\Http\Message\StreamInterface;
7
use Venta\Http\Response;
8
9
/**
10
 * Class ResponseTest
11
 */
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
}