Skip to content

Commit

Permalink
Add API test to verify QR codes return a 404 for disabled short URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Dec 24, 2023
1 parent 0f0301a commit e12bda3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions module/Core/test-api/Action/QrCodeTest.php
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());
}
}

0 comments on commit e12bda3

Please sign in to comment.