Code Duplication    Length = 18-18 lines in 4 locations

tests/Connection/ClientTest.php 4 locations

@@ 140-157 (lines=18) @@
137
        $this->assertEquals('Third pending notification', $notifications->get(2)->getMessage());
138
    }
139
140
    public function testGetUserBadges()
141
    {
142
        $badgesData = json_decode(file_get_contents(__DIR__ . '/../dummy_response_data/getUserBadges.json'), true);
143
        $badgesData = $badgesData['badges'];
144
        // Set mocked response
145
        $body = new Stream(fopen(__DIR__ . '/../dummy_response_data/getUserBadges.json', 'r'));
146
        $this->subscriber->addResponse(new Response(200, [], $body));
147
148
        $badges = $this->client->getUserBadges('');
149
        $this->assertCount(2, $badges);
150
        foreach ($badges as $key => $badge) {
151
            $this->assertEquals($badgesData[$key]['type'], $badge->getType());
152
            $this->assertInstanceOf('DateTime', $badge->getNotificationDate());
153
            $this->assertEquals($badgesData[$key]['imageUrl'], $badge->getImageUrl());
154
            $this->assertEquals($badgesData[$key]['name'], $badge->getName());
155
            $this->assertEquals($badgesData[$key]['description'], $badge->getDescription());
156
        }
157
    }
158
159
    public function testGetUserAchievements()
160
    {
@@ 195-212 (lines=18) @@
192
        }
193
    }
194
195
    public function testGetQuests()
196
    {
197
        $questsData = json_decode(file_get_contents(__DIR__ . '/../dummy_response_data/getQuests.json'), true);
198
        $questsData = $questsData['quests'];
199
        // Set mocked response
200
        $body = new Stream(fopen(__DIR__ . '/../dummy_response_data/getQuests.json', 'r'));
201
        $this->subscriber->addResponse(new Response(200, [], $body));
202
203
        $quests = $this->client->getQuests();
204
        $this->assertCount(3, $quests);
205
        foreach ($quests as $key => $quest) {
206
            $this->assertInstanceof('DateTime', $quest->getStartDate());
207
            $this->assertEquals($questsData[$key]['code'], $quest->getCode());
208
            $this->assertEquals($questsData[$key]['generatesNotification'], $quest->getGeneratesNotification());
209
            $this->assertEquals($questsData[$key]['name'], $quest->getName());
210
            $this->assertEquals($questsData[$key]['description'], $quest->getDescription());
211
        }
212
    }
213
214
    public function testGetLevels()
215
    {
@@ 275-292 (lines=18) @@
272
        $this->assertEquals('VCM', $level->getScenario()->getName());
273
    }
274
275
    public function testGetTeamsLeaderboard()
276
    {
277
        $teamsData = json_decode(file_get_contents(__DIR__ . '/../dummy_response_data/getTeamsLeaderboard.json'), true);
278
        $teamsData = $teamsData['scores'];
279
        // Set mocked response
280
        $body = new Stream(fopen(__DIR__ . '/../dummy_response_data/getTeamsLeaderboard.json', 'r'));
281
        $this->subscriber->addResponse(new Response(200, [], $body));
282
283
        $teams = $this->client->getTeamsLeaderboard();
284
        $this->assertCount(4, $teams);
285
        foreach ($teams as $key => $team) {
286
            $this->assertEquals($teamsData[$key]['teamName'], $team->getTeamName());
287
            $this->assertEquals($teamsData[$key]['avatar'], $team->getAvatar());
288
            $this->assertEquals($teamsData[$key]['description'], $team->getDescription());
289
            $this->assertEquals($teamsData[$key]['position'], $team->getPosition());
290
            $this->assertEquals($teamsData[$key]['score'], $team->getScore());
291
        }
292
    }
293
294
    public function testGetTeamsLeaderboardWithParams()
295
    {
@@ 314-331 (lines=18) @@
311
        $this->assertEquals('12345', $queryParams['userId']);
312
    }
313
314
    public function testGetItemsLeaderboard()
315
    {
316
        $itemsData = json_decode(file_get_contents(__DIR__ . '/../dummy_response_data/getItemsLeaderboard.json'), true);
317
        $itemsData = $itemsData['leaderboard'];
318
        // Set mocked response
319
        $body = new Stream(fopen(__DIR__ . '/../dummy_response_data/getItemsLeaderboard.json', 'r'));
320
        $this->subscriber->addResponse(new Response(200, [], $body));
321
322
        $items = $this->client->getItemsLeaderboard();
323
        $this->assertCount(3, $items);
324
        foreach ($items as $key => $item) {
325
            $this->assertEquals($itemsData[$key]['id'], $item->getItemId());
326
            $this->assertEquals($itemsData[$key]['title'], $item->getTitle());
327
            $this->assertEquals($itemsData[$key]['description'], $item->getDescription());
328
            $this->assertEquals($itemsData[$key]['author'], $item->getAuthor());
329
            $this->assertInstanceOf('DateTime', $item->getDateCreated());
330
        }
331
    }
332
333
    public function testRateItem()
334
    {