mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-21 16:38:37 -06:00
Add API test for short URL path prefix
This commit is contained in:
parent
f30c74b987
commit
ff963a9df4
@ -8,6 +8,7 @@ use Cake\Chronos\Chronos;
|
||||
use GuzzleHttp\RequestOptions;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\Attributes\TestWith;
|
||||
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
|
||||
|
||||
use function array_map;
|
||||
@ -339,6 +340,21 @@ class CreateShortUrlTest extends ApiTestCase
|
||||
self::assertNull($payload['title']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestWith([null])]
|
||||
#[TestWith(['my-custom-slug'])]
|
||||
public function prefixCanBeSet(?string $customSlug): void
|
||||
{
|
||||
[$statusCode, $payload] = $this->createShortUrl([
|
||||
'longUrl' => 'https://github.com/shlinkio/shlink/issues/1557',
|
||||
'pathPrefix' => 'foo/b ar-baz',
|
||||
'customSlug' => $customSlug,
|
||||
]);
|
||||
|
||||
self::assertEquals(self::STATUS_OK, $statusCode);
|
||||
self::assertStringStartsWith('foo-b--ar-baz', $payload['shortCode']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{int, array}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user