Code Duplication    Length = 8-12 lines in 4 locations

tests/JSendBasicTest.php 4 locations

@@ 114-121 (lines=8) @@
111
        JSend::decode($json);
112
    }
113
114
    public function testSuccessResponseWithNullData()
115
    {
116
        $json     = '{ "status": "success", "data": null }';
117
        $response = JSend::decode($json);
118
        $this->assertTrue($response->getStatus()->isSuccess());
119
        $this->assertEmpty($response->getData());
120
        $this->assertJsonStringEqualsJsonString($json, json_encode($response));
121
    }
122
123
    public function testSuccessResponseWithEmptyData()
124
    {
@@ 123-130 (lines=8) @@
120
        $this->assertJsonStringEqualsJsonString($json, json_encode($response));
121
    }
122
123
    public function testSuccessResponseWithEmptyData()
124
    {
125
        $json     = '{ "status": "success", "data": [] }';
126
        $response = JSend::decode($json);
127
        $this->assertTrue($response->getStatus()->isSuccess());
128
        $this->assertEmpty($response->getData());
129
        $this->assertJsonStringEqualsJsonString($json, json_encode($response));
130
    }
131
132
    public function testFailResponse()
133
    {
@@ 132-143 (lines=12) @@
129
        $this->assertJsonStringEqualsJsonString($json, json_encode($response));
130
    }
131
132
    public function testFailResponse()
133
    {
134
        $json = '{
135
            "status" : "fail",
136
            "data" : { "title" : "A title is required" }
137
        }';
138
139
        $response = JSend::decode($json);
140
        $this->assertTrue($response->getStatus()->isFail());
141
        $this->assertEquals(['title' => 'A title is required'], $response->getData());
142
        $this->assertJsonStringEqualsJsonString($json, json_encode($response));
143
    }
144
145
    public function testGetErrorOnNoneError()
146
    {
@@ 153-164 (lines=12) @@
150
        $response->getError();
151
    }
152
153
    public function testErrorResponse()
154
    {
155
        $json = '{
156
            "status" : "error",
157
            "message" : "Unable to communicate with database"
158
        }';
159
160
        $response = JSend::decode($json);
161
        $this->assertTrue($response->getStatus()->isError());
162
        $this->assertEquals('Unable to communicate with database', $response->getError()->getMessage());
163
        $this->assertJsonStringEqualsJsonString($json, json_encode($response));
164
    }
165
}