mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 17:44:44 +08:00
Added locking to short URL creation when checking if URL exists
This commit is contained in:
@@ -11,6 +11,7 @@ use Shlinkio\Shlink\Common\Util\DateRange;
|
||||
use Shlinkio\Shlink\Core\Entity\Domain;
|
||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||
use Shlinkio\Shlink\Core\Model\ShortUrlIdentifier;
|
||||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||
use Shlinkio\Shlink\Core\Model\ShortUrlsOrdering;
|
||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||
@@ -180,12 +181,18 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
|
||||
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
self::assertTrue($this->repo->shortCodeIsInUse('my-cool-slug'));
|
||||
self::assertFalse($this->repo->shortCodeIsInUse('my-cool-slug', 'doma.in'));
|
||||
self::assertFalse($this->repo->shortCodeIsInUse('slug-not-in-use'));
|
||||
self::assertFalse($this->repo->shortCodeIsInUse('another-slug'));
|
||||
self::assertFalse($this->repo->shortCodeIsInUse('another-slug', 'example.com'));
|
||||
self::assertTrue($this->repo->shortCodeIsInUse('another-slug', 'doma.in'));
|
||||
self::assertTrue($this->repo->shortCodeIsInUse(ShortUrlIdentifier::fromShortCodeAndDomain('my-cool-slug')));
|
||||
self::assertFalse($this->repo->shortCodeIsInUse(
|
||||
ShortUrlIdentifier::fromShortCodeAndDomain('my-cool-slug', 'doma.in'),
|
||||
));
|
||||
self::assertFalse($this->repo->shortCodeIsInUse(ShortUrlIdentifier::fromShortCodeAndDomain('slug-not-in-use')));
|
||||
self::assertFalse($this->repo->shortCodeIsInUse(ShortUrlIdentifier::fromShortCodeAndDomain('another-slug')));
|
||||
self::assertFalse($this->repo->shortCodeIsInUse(
|
||||
ShortUrlIdentifier::fromShortCodeAndDomain('another-slug', 'example.com'),
|
||||
));
|
||||
self::assertTrue($this->repo->shortCodeIsInUse(
|
||||
ShortUrlIdentifier::fromShortCodeAndDomain('another-slug', 'doma.in'),
|
||||
));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
||||
Reference in New Issue
Block a user