|
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
|
|
|
|