-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API test to verify QR codes return a 404 for disabled short URLs
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ShlinkioApiTest\Shlink\Core\Action; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase; | ||
|
||
class QrCodeTest extends ApiTestCase | ||
{ | ||
#[Test] | ||
public function returnsNotFoundWhenShortUrlIsNotEnabled(): void | ||
{ | ||
// The QR code successfully resolves at first | ||
$response = $this->callShortUrl('custom/qr-code'); | ||
self::assertEquals(200, $response->getStatusCode()); | ||
|
||
// This short URL allow max 2 visits | ||
$this->callShortUrl('custom'); | ||
$this->callShortUrl('custom'); | ||
|
||
// After 2 visits, the QR code should return a 404 | ||
$response = $this->callShortUrl('custom/qr-code'); | ||
self::assertEquals(404, $response->getStatusCode()); | ||
} | ||
} |