mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-09 16:53:11 +08:00
Added validateUrl optional flag for create/edit short URLs
This commit is contained in:
@@ -37,7 +37,7 @@ class UrlValidatorTest extends TestCase
|
||||
$request->shouldBeCalledOnce();
|
||||
$this->expectException(InvalidUrlException::class);
|
||||
|
||||
$this->urlValidator->validateUrl('http://foobar.com/12345/hello?foo=bar');
|
||||
$this->urlValidator->validateUrl('http://foobar.com/12345/hello?foo=bar', null);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
@@ -54,19 +54,29 @@ class UrlValidatorTest extends TestCase
|
||||
],
|
||||
)->willReturn(new Response());
|
||||
|
||||
$this->urlValidator->validateUrl($expectedUrl);
|
||||
$this->urlValidator->validateUrl($expectedUrl, null);
|
||||
|
||||
$request->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function noCheckIsPerformedWhenUrlValidationIsDisabled(): void
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideDisabledCombinations
|
||||
*/
|
||||
public function noCheckIsPerformedWhenUrlValidationIsDisabled(?bool $doValidate, bool $validateUrl): void
|
||||
{
|
||||
$request = $this->httpClient->request(Argument::cetera())->willReturn(new Response());
|
||||
$this->options->validateUrl = false;
|
||||
$this->options->validateUrl = $validateUrl;
|
||||
|
||||
$this->urlValidator->validateUrl('');
|
||||
$this->urlValidator->validateUrl('', $doValidate);
|
||||
|
||||
$request->shouldNotHaveBeenCalled();
|
||||
}
|
||||
|
||||
public function provideDisabledCombinations(): iterable
|
||||
{
|
||||
yield 'config is disabled and no runtime option is provided' => [null, false];
|
||||
yield 'config is enabled but runtime option is disabled' => [false, true];
|
||||
yield 'both config and runtime option are disabled' => [false, false];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user