mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Update RedirectRuleHandlerTest
This commit is contained in:
parent
b5b5f92eda
commit
f2371b6124
@ -117,6 +117,7 @@ class RedirectRuleHandlerTest extends TestCase
|
|||||||
'Query param name?' => 'foo',
|
'Query param name?' => 'foo',
|
||||||
'Query param value?' => 'bar',
|
'Query param value?' => 'bar',
|
||||||
'IP address, CIDR block or wildcard-pattern (1.2.*.*)' => '1.2.3.4',
|
'IP address, CIDR block or wildcard-pattern (1.2.*.*)' => '1.2.3.4',
|
||||||
|
'Country code to match?' => 'FR',
|
||||||
default => '',
|
default => '',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -165,6 +166,10 @@ class RedirectRuleHandlerTest extends TestCase
|
|||||||
true,
|
true,
|
||||||
];
|
];
|
||||||
yield 'IP address' => [RedirectConditionType::IP_ADDRESS, [RedirectCondition::forIpAddress('1.2.3.4')]];
|
yield 'IP address' => [RedirectConditionType::IP_ADDRESS, [RedirectCondition::forIpAddress('1.2.3.4')]];
|
||||||
|
yield 'Geolocation country code' => [
|
||||||
|
RedirectConditionType::GEOLOCATION_COUNTRY_CODE,
|
||||||
|
[RedirectCondition::forGeolocationCountryCode('FR')],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
|
@ -97,8 +97,11 @@ class RedirectConditionTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Test, DataProvider('provideVisits')]
|
#[Test, DataProvider('provideVisits')]
|
||||||
public function matchesGeolocationCountryCode(Location|null $location, string $countryCodeToMatch, bool $expected): void
|
public function matchesGeolocationCountryCode(
|
||||||
{
|
Location|null $location,
|
||||||
|
string $countryCodeToMatch,
|
||||||
|
bool $expected,
|
||||||
|
): void {
|
||||||
$request = ServerRequestFactory::fromGlobals()->withAttribute(Location::class, $location);
|
$request = ServerRequestFactory::fromGlobals()->withAttribute(Location::class, $location);
|
||||||
$result = RedirectCondition::forGeolocationCountryCode($countryCodeToMatch)->matchesRequest($request);
|
$result = RedirectCondition::forGeolocationCountryCode($countryCodeToMatch)->matchesRequest($request);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user