mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 09:13:11 +08:00
Added validateUrl optional flag for create/edit short URLs
This commit is contained in:
@@ -104,7 +104,10 @@ class ShortUrlServiceTest extends TestCase
|
||||
$this->assertEquals($shortUrlEdit->longUrl() ?? $originalLongUrl, $shortUrl->getLongUrl());
|
||||
$findShortUrl->shouldHaveBeenCalled();
|
||||
$flush->shouldHaveBeenCalled();
|
||||
$this->urlValidator->validateUrl($shortUrlEdit->longUrl())->shouldHaveBeenCalledTimes($expectedValidateCalls);
|
||||
$this->urlValidator->validateUrl(
|
||||
$shortUrlEdit->longUrl(),
|
||||
$shortUrlEdit->doValidateUrl(),
|
||||
)->shouldHaveBeenCalledTimes($expectedValidateCalls);
|
||||
}
|
||||
|
||||
public function provideShortUrlEdits(): iterable
|
||||
@@ -123,5 +126,11 @@ class ShortUrlServiceTest extends TestCase
|
||||
'longUrl' => 'modifiedLongUrl',
|
||||
],
|
||||
)];
|
||||
yield 'long URL with validation' => [1, ShortUrlEdit::fromRawData(
|
||||
[
|
||||
'longUrl' => 'modifiedLongUrl',
|
||||
'validateUrl' => true,
|
||||
],
|
||||
)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class UrlShortenerTest extends TestCase
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->urlValidator = $this->prophesize(UrlValidatorInterface::class);
|
||||
$this->urlValidator->validateUrl('http://foobar.com/12345/hello?foo=bar')->will(
|
||||
$this->urlValidator->validateUrl('http://foobar.com/12345/hello?foo=bar', null)->will(
|
||||
function (): void {
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user