Completed
Pull Request — master (#339)
by Alejandro
09:39 queued 07:20
created

ListShortUrlsTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 39
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A shortUrlsAreProperlyListed() 0 50 1
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioApiTest\Shlink\Rest\Action;
5
6
use ShlinkioTest\Shlink\Common\ApiTest\ApiTestCase;
7
8
class ListShortUrlsTest extends ApiTestCase
9
{
10
    /**
11
     * @test
12
     */
13
    public function shortUrlsAreProperlyListed()
14
    {
15
        $resp = $this->callApiWithKey(self::METHOD_GET, '/short-urls');
16
        $respPayload = $this->getJsonResponsePayload($resp);
17
18
        $this->assertEquals(self::STATUS_OK, $resp->getStatusCode());
19
        $this->assertEquals([
20
            'shortUrls' => [
21
                'data' => [
22
                    [
23
                        'shortCode' => 'abc123',
24
                        'shortUrl' => 'http://doma.in/abc123',
25
                        'longUrl' => 'https://shlink.io',
26
                        'dateCreated' => '2019-01-01T00:00:00+00:00',
27
                        'visitsCount' => 3,
28
                        'tags' => ['foo'],
29
                        'originalUrl' => 'https://shlink.io',
30
                    ],
31
                    [
32
                        'shortCode' => 'def456',
33
                        'shortUrl' => 'http://doma.in/def456',
34
                        'longUrl' =>
35
                            'https://blog.alejandrocelaya.com/2017/12/09'
36
                            . '/acmailer-7-0-the-most-important-release-in-a-long-time/',
37
                        'dateCreated' => '2019-01-01T00:00:00+00:00',
38
                        'visitsCount' => 2,
39
                        'tags' => ['foo', 'bar'],
40
                        'originalUrl' =>
41
                            'https://blog.alejandrocelaya.com/2017/12/09'
42
                            . '/acmailer-7-0-the-most-important-release-in-a-long-time/',
43
                    ],
44
                    [
45
                        'shortCode' => 'custom',
46
                        'shortUrl' => 'http://doma.in/custom',
47
                        'longUrl' => 'https://shlink.io',
48
                        'dateCreated' => '2019-01-01T00:00:00+00:00',
49
                        'visitsCount' => 0,
50
                        'tags' => [],
51
                        'originalUrl' => 'https://shlink.io',
52
                    ],
53
                ],
54
                'pagination' => [
55
                    'currentPage' => 1,
56
                    'pagesCount' => 1,
57
                    'itemsPerPage' => 10,
58
                    'itemsInCurrentPage' => 3,
59
                    'totalItems' => 3,
60
                ],
61
            ],
62
        ], $respPayload);
63
    }
64
}
65