Code Duplication    Length = 8-12 lines in 4 locations

tests/JSendBasicTest.php 4 locations

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