2019-01-27 14:35:00 +03:00
|
|
|
<?php
|
2019-10-05 18:26:10 +03:00
|
|
|
|
2019-01-27 14:35:00 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace ShlinkioApiTest\Shlink\Rest\Action;
|
|
|
|
|
2019-08-11 17:30:46 +03:00
|
|
|
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
|
2019-01-27 14:35:00 +03:00
|
|
|
|
|
|
|
class ListShortUrlsTest extends ApiTestCase
|
|
|
|
{
|
2019-02-17 22:28:34 +03:00
|
|
|
/** @test */
|
2019-08-11 15:21:35 +03:00
|
|
|
public function shortUrlsAreProperlyListed(): void
|
2019-01-27 14:35:00 +03:00
|
|
|
{
|
|
|
|
$resp = $this->callApiWithKey(self::METHOD_GET, '/short-urls');
|
|
|
|
$respPayload = $this->getJsonResponsePayload($resp);
|
|
|
|
|
|
|
|
$this->assertEquals(self::STATUS_OK, $resp->getStatusCode());
|
|
|
|
$this->assertEquals([
|
|
|
|
'shortUrls' => [
|
|
|
|
'data' => [
|
|
|
|
[
|
|
|
|
'shortCode' => 'abc123',
|
|
|
|
'shortUrl' => 'http://doma.in/abc123',
|
|
|
|
'longUrl' => 'https://shlink.io',
|
|
|
|
'dateCreated' => '2019-01-01T00:00:00+00:00',
|
|
|
|
'visitsCount' => 3,
|
|
|
|
'tags' => ['foo'],
|
2019-07-08 19:23:38 +03:00
|
|
|
'meta' => [
|
|
|
|
'validSince' => null,
|
|
|
|
'validUntil' => null,
|
|
|
|
'maxVisits' => null,
|
|
|
|
],
|
2019-01-27 14:35:00 +03:00
|
|
|
'originalUrl' => 'https://shlink.io',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'shortCode' => 'def456',
|
|
|
|
'shortUrl' => 'http://doma.in/def456',
|
|
|
|
'longUrl' =>
|
|
|
|
'https://blog.alejandrocelaya.com/2017/12/09'
|
|
|
|
. '/acmailer-7-0-the-most-important-release-in-a-long-time/',
|
|
|
|
'dateCreated' => '2019-01-01T00:00:00+00:00',
|
|
|
|
'visitsCount' => 2,
|
2019-11-01 19:16:56 +03:00
|
|
|
'tags' => ['bar', 'foo'],
|
2019-07-08 19:23:38 +03:00
|
|
|
'meta' => [
|
|
|
|
'validSince' => '2020-05-01T00:00:00+00:00',
|
|
|
|
'validUntil' => null,
|
|
|
|
'maxVisits' => null,
|
|
|
|
],
|
2019-01-27 14:35:00 +03:00
|
|
|
'originalUrl' =>
|
|
|
|
'https://blog.alejandrocelaya.com/2017/12/09'
|
|
|
|
. '/acmailer-7-0-the-most-important-release-in-a-long-time/',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'shortCode' => 'custom',
|
|
|
|
'shortUrl' => 'http://doma.in/custom',
|
|
|
|
'longUrl' => 'https://shlink.io',
|
|
|
|
'dateCreated' => '2019-01-01T00:00:00+00:00',
|
|
|
|
'visitsCount' => 0,
|
|
|
|
'tags' => [],
|
2019-07-08 19:23:38 +03:00
|
|
|
'meta' => [
|
|
|
|
'validSince' => null,
|
|
|
|
'validUntil' => null,
|
|
|
|
'maxVisits' => 2,
|
|
|
|
],
|
2019-01-27 14:35:00 +03:00
|
|
|
'originalUrl' => 'https://shlink.io',
|
|
|
|
],
|
2019-10-01 21:24:11 +03:00
|
|
|
[
|
|
|
|
'shortCode' => 'ghi789',
|
|
|
|
'shortUrl' => 'http://example.com/ghi789',
|
|
|
|
'longUrl' =>
|
|
|
|
'https://blog.alejandrocelaya.com/2019/04/27'
|
|
|
|
. '/considerations-to-properly-use-open-source-software-projects/',
|
|
|
|
'dateCreated' => '2019-01-01T00:00:00+00:00',
|
|
|
|
'visitsCount' => 0,
|
|
|
|
'tags' => [],
|
|
|
|
'meta' => [
|
|
|
|
'validSince' => null,
|
|
|
|
'validUntil' => null,
|
|
|
|
'maxVisits' => null,
|
|
|
|
],
|
|
|
|
'originalUrl' =>
|
|
|
|
'https://blog.alejandrocelaya.com/2019/04/27'
|
|
|
|
. '/considerations-to-properly-use-open-source-software-projects/',
|
|
|
|
],
|
2019-10-02 21:13:25 +03:00
|
|
|
[
|
|
|
|
'shortCode' => 'custom-with-domain',
|
|
|
|
'shortUrl' => 'http://some-domain.com/custom-with-domain',
|
|
|
|
'longUrl' => 'https://google.com',
|
|
|
|
'dateCreated' => '2019-01-01T00:00:00+00:00',
|
|
|
|
'visitsCount' => 0,
|
|
|
|
'tags' => [],
|
|
|
|
'meta' => [
|
|
|
|
'validSince' => null,
|
|
|
|
'validUntil' => null,
|
|
|
|
'maxVisits' => null,
|
|
|
|
],
|
|
|
|
'originalUrl' => 'https://google.com',
|
|
|
|
],
|
2019-01-27 14:35:00 +03:00
|
|
|
],
|
|
|
|
'pagination' => [
|
|
|
|
'currentPage' => 1,
|
|
|
|
'pagesCount' => 1,
|
|
|
|
'itemsPerPage' => 10,
|
2019-10-02 21:13:25 +03:00
|
|
|
'itemsInCurrentPage' => 5,
|
|
|
|
'totalItems' => 5,
|
2019-01-27 14:35:00 +03:00
|
|
|
],
|
|
|
|
],
|
|
|
|
], $respPayload);
|
|
|
|
}
|
|
|
|
}
|