summaryrefslogtreecommitdiffstats
path: root/test/unit/SparkPostResponseTest.php
blob: d6b3a9f4710ac919332ff8fd3b769f3f3c74ca6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php

namespace SparkPost\Test;

use SparkPost\SparkPostResponse;
use Mockery;

class SparkPostResponseTest extends \PHPUnit_Framework_TestCase
{
    /**
     * (non-PHPdoc).
     *
     * @before
     *
     * @see PHPUnit_Framework_TestCase::setUp()
     */
    public function setUp()
    {
        $this->returnValue = 'some_value_to_return';
        $this->responseMock = Mockery::mock('Psr\Http\Message\ResponseInterface');
    }

    public function testGetProtocolVersion()
    {
        $this->responseMock->shouldReceive('getProtocolVersion')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->getProtocolVersion(), $sparkpostResponse->getProtocolVersion());
    }

    public function testWithProtocolVersion()
    {
        $param = 'protocol version';

        $this->responseMock->shouldReceive('withProtocolVersion')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->withProtocolVersion($param), $sparkpostResponse->withProtocolVersion($param));
    }

    public function testGetHeaders()
    {
        $this->responseMock->shouldReceive('getHeaders')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->getHeaders(), $sparkpostResponse->getHeaders());
    }

    public function testHasHeader()
    {
        $param = 'header';

        $this->responseMock->shouldReceive('hasHeader')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->hasHeader($param), $sparkpostResponse->hasHeader($param));
    }

    public function testGetHeader()
    {
        $param = 'header';

        $this->responseMock->shouldReceive('getHeader')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->getHeader($param), $sparkpostResponse->getHeader($param));
    }

    public function testGetHeaderLine()
    {
        $param = 'header';

        $this->responseMock->shouldReceive('getHeaderLine')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->getHeaderLine($param), $sparkpostResponse->getHeaderLine($param));
    }

    public function testWithHeader()
    {
        $param = 'header';
        $param2 = 'value';

        $this->responseMock->shouldReceive('withHeader')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->withHeader($param, $param2), $sparkpostResponse->withHeader($param, $param2));
    }

    public function testWithAddedHeader()
    {
        $param = 'header';
        $param2 = 'value';

        $this->responseMock->shouldReceive('withAddedHeader')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->withAddedHeader($param, $param2), $sparkpostResponse->withAddedHeader($param, $param2));
    }

    public function testWithoutHeader()
    {
        $param = 'header';

        $this->responseMock->shouldReceive('withoutHeader')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->withoutHeader($param), $sparkpostResponse->withoutHeader($param));
    }

    public function testGetRequest()
    {
        $request = ['some' => 'request'];
        $this->responseMock->shouldReceive('getRequest')->andReturn($request);
        $sparkpostResponse = new SparkPostResponse($this->responseMock, $request);
        $this->assertEquals($sparkpostResponse->getRequest(), $request);
    }

    public function testWithBody()
    {
        $param = Mockery::mock('Psr\Http\Message\StreamInterface');

        $this->responseMock->shouldReceive('withBody')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->withBody($param), $sparkpostResponse->withBody($param));
    }

    public function testGetStatusCode()
    {
        $this->responseMock->shouldReceive('getStatusCode')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->getStatusCode(), $sparkpostResponse->getStatusCode());
    }

    public function testWithStatus()
    {
        $param = 'status';

        $this->responseMock->shouldReceive('withStatus')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->withStatus($param), $sparkpostResponse->withStatus($param));
    }

    public function testGetReasonPhrase()
    {
        $this->responseMock->shouldReceive('getReasonPhrase')->andReturn($this->returnValue);
        $sparkpostResponse = new SparkPostResponse($this->responseMock);
        $this->assertEquals($this->responseMock->getReasonPhrase(), $sparkpostResponse->getReasonPhrase());
    }
}