Code Duplication    Length = 8-12 lines in 4 locations

tests/JSendBasicTest.php 4 locations

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