mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 17:23:12 +08:00
Enhance RedirectConditionTest with new query-param-related conditions
This commit is contained in:
@@ -32,6 +32,33 @@ class RedirectConditionTest extends TestCase
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestWith(['nop', '', false])] // param not present
|
||||
#[TestWith(['foo', '', true])]
|
||||
#[TestWith(['foo', 'something', true])]
|
||||
#[TestWith(['foo', 'something else', true])]
|
||||
public function matchesAnyValueQueryParams(string $param, string $value, bool $expectedResult): void
|
||||
{
|
||||
$request = ServerRequestFactory::fromGlobals()->withQueryParams(['foo' => $value]);
|
||||
$result = RedirectCondition::forAnyValueQueryParam($param)->matchesRequest($request);
|
||||
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestWith(['nop', '', false])] // param not present
|
||||
#[TestWith(['foo', '', true])]
|
||||
#[TestWith(['foo', null, true])]
|
||||
#[TestWith(['foo', 'something', false])]
|
||||
#[TestWith(['foo', 'something else', false])]
|
||||
public function matchesValuelessQueryParams(string $param, string|null $value, bool $expectedResult): void
|
||||
{
|
||||
$request = ServerRequestFactory::fromGlobals()->withQueryParams(['foo' => $value]);
|
||||
$result = RedirectCondition::forValuelessQueryParam($param)->matchesRequest($request);
|
||||
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
#[TestWith([null, '', false], 'no accept language')]
|
||||
#[TestWith(['', '', false], 'empty accept language')]
|
||||
@@ -141,6 +168,8 @@ class RedirectConditionTest extends TestCase
|
||||
#[TestWith([RedirectConditionType::DEVICE->value, RedirectConditionType::DEVICE])]
|
||||
#[TestWith([RedirectConditionType::LANGUAGE->value, RedirectConditionType::LANGUAGE])]
|
||||
#[TestWith([RedirectConditionType::QUERY_PARAM->value, RedirectConditionType::QUERY_PARAM])]
|
||||
#[TestWith([RedirectConditionType::ANY_VALUE_QUERY_PARAM->value, RedirectConditionType::ANY_VALUE_QUERY_PARAM])]
|
||||
#[TestWith([RedirectConditionType::VALUELESS_QUERY_PARAM->value, RedirectConditionType::VALUELESS_QUERY_PARAM])]
|
||||
#[TestWith([RedirectConditionType::IP_ADDRESS->value, RedirectConditionType::IP_ADDRESS])]
|
||||
#[TestWith(
|
||||
[RedirectConditionType::GEOLOCATION_COUNTRY_CODE->value, RedirectConditionType::GEOLOCATION_COUNTRY_CODE],
|
||||
|
||||
Reference in New Issue
Block a user