mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Add tests covering country code validation
This commit is contained in:
parent
fd34332e69
commit
7ddb3e7a70
@ -63,6 +63,18 @@ class RedirectRulesDataTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
]]])]
|
]]])]
|
||||||
|
#[TestWith([['redirectRules' => [
|
||||||
|
[
|
||||||
|
'longUrl' => 'https://example.com',
|
||||||
|
'conditions' => [
|
||||||
|
[
|
||||||
|
'type' => 'geolocation-country-code',
|
||||||
|
'matchKey' => null,
|
||||||
|
'matchValue' => 'not an country code',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]]])]
|
||||||
public function throwsWhenProvidedDataIsInvalid(array $invalidData): void
|
public function throwsWhenProvidedDataIsInvalid(array $invalidData): void
|
||||||
{
|
{
|
||||||
$this->expectException(ValidationException::class);
|
$this->expectException(ValidationException::class);
|
||||||
@ -118,6 +130,18 @@ class RedirectRulesDataTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
]]], 'in-between IP wildcard pattern')]
|
]]], 'in-between IP wildcard pattern')]
|
||||||
|
#[TestWith([['redirectRules' => [
|
||||||
|
[
|
||||||
|
'longUrl' => 'https://example.com',
|
||||||
|
'conditions' => [
|
||||||
|
[
|
||||||
|
'type' => 'geolocation-country-code',
|
||||||
|
'matchKey' => null,
|
||||||
|
'matchValue' => 'US',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]]], 'country code')]
|
||||||
public function allowsValidDataToBeSet(array $validData): void
|
public function allowsValidDataToBeSet(array $validData): void
|
||||||
{
|
{
|
||||||
$result = RedirectRulesData::fromRawData($validData);
|
$result = RedirectRulesData::fromRawData($validData);
|
||||||
|
@ -96,6 +96,20 @@ class SetRedirectRulesTest extends ApiTestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
]], 'invalid IP address')]
|
]], 'invalid IP address')]
|
||||||
|
#[TestWith([[
|
||||||
|
'redirectRules' => [
|
||||||
|
[
|
||||||
|
'longUrl' => 'https://example.com',
|
||||||
|
'conditions' => [
|
||||||
|
[
|
||||||
|
'type' => 'geolocation-country-code',
|
||||||
|
'matchKey' => null,
|
||||||
|
'matchValue' => 'not a country code',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]], 'invalid country code')]
|
||||||
public function errorIsReturnedWhenInvalidDataIsProvided(array $bodyPayload): void
|
public function errorIsReturnedWhenInvalidDataIsProvided(array $bodyPayload): void
|
||||||
{
|
{
|
||||||
$response = $this->callApiWithKey(self::METHOD_POST, '/short-urls/abc123/redirect-rules', [
|
$response = $this->callApiWithKey(self::METHOD_POST, '/short-urls/abc123/redirect-rules', [
|
||||||
|
Loading…
Reference in New Issue
Block a user