Skip to content

Commit 4308839

Browse files
committed
Add API test for type-filtering in orphan visits list
1 parent f17b641 commit 4308839

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

module/Rest/test-api/Action/OrphanVisitsTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PHPUnit\Framework\Attributes\DataProvider;
99
use PHPUnit\Framework\Attributes\Test;
1010
use Shlinkio\Shlink\Common\Paginator\Paginator;
11+
use Shlinkio\Shlink\Core\Visit\Model\OrphanVisitType;
1112
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
1213

1314
class OrphanVisitsTest extends ApiTestCase
@@ -68,6 +69,23 @@ public static function provideQueries(): iterable
6869
1,
6970
[self::REGULAR_NOT_FOUND],
7071
];
72+
yield 'base_url only' => [['type' => OrphanVisitType::BASE_URL->value], 1, 1, [self::BASE_URL]];
73+
yield 'regular_404 only' => [['type' => OrphanVisitType::REGULAR_404->value], 1, 1, [self::REGULAR_NOT_FOUND]];
74+
yield 'invalid_short_url only' => [
75+
['type' => OrphanVisitType::INVALID_SHORT_URL->value],
76+
1,
77+
1,
78+
[self::INVALID_SHORT_URL],
79+
];
80+
}
81+
82+
#[Test]
83+
public function errorIsReturnedForInvalidType(): void
84+
{
85+
$resp = $this->callApiWithKey(self::METHOD_GET, '/visits/orphan', [
86+
RequestOptions::QUERY => ['type' => 'invalid'],
87+
]);
88+
self::assertEquals(400, $resp->getStatusCode());
7189
}
7290

7391
#[Test]

0 commit comments

Comments
 (0)