Make RedirectCondition->matchValue nullable

This commit is contained in:
Alejandro Celaya
2025-07-22 08:20:21 +02:00
parent 56df880a93
commit 5b5d0aae49
10 changed files with 66 additions and 33 deletions

View File

@@ -17,11 +17,6 @@ class ListRedirectRulesTest extends ApiTestCase
'matchKey' => null,
'matchValue' => 'en',
];
private const array QUERY_FOO_BAR_CONDITION = [
'type' => 'query-param',
'matchKey' => 'foo',
'matchValue' => 'bar',
];
#[Test]
public function errorIsReturnedWhenInvalidUrlIsFetched(): void
@@ -45,7 +40,11 @@ class ListRedirectRulesTest extends ApiTestCase
'priority' => 1,
'conditions' => [
self::LANGUAGE_EN_CONDITION,
self::QUERY_FOO_BAR_CONDITION,
[
'type' => 'any-value-query-param',
'matchKey' => 'foo',
'matchValue' => null,
],
],
],
[
@@ -57,7 +56,11 @@ class ListRedirectRulesTest extends ApiTestCase
'matchKey' => 'hello',
'matchValue' => 'world',
],
self::QUERY_FOO_BAR_CONDITION,
[
'type' => 'query-param',
'matchKey' => 'foo',
'matchValue' => 'bar',
],
],
],
[

View File

@@ -18,11 +18,6 @@ class SetRedirectRulesTest extends ApiTestCase
'matchKey' => null,
'matchValue' => 'en',
];
private const array QUERY_FOO_BAR_CONDITION = [
'type' => 'query-param',
'matchKey' => 'foo',
'matchValue' => 'bar',
];
#[Test]
public function errorIsReturnedWhenInvalidUrlIsProvided(): void
@@ -132,7 +127,11 @@ class SetRedirectRulesTest extends ApiTestCase
'priority' => 1,
'conditions' => [
self::LANGUAGE_EN_CONDITION,
self::QUERY_FOO_BAR_CONDITION,
[
'type' => 'any-value-query-param',
'matchKey' => 'foo',
'matchValue' => null,
],
],
],
[
@@ -144,7 +143,11 @@ class SetRedirectRulesTest extends ApiTestCase
'matchKey' => 'hello',
'matchValue' => 'world',
],
self::QUERY_FOO_BAR_CONDITION,
[
'type' => 'query-param',
'matchKey' => 'foo',
'matchValue' => 'bar',
],
],
],
]])]

View File

@@ -41,7 +41,7 @@ class ShortUrlRedirectRulesFixture extends AbstractFixture implements DependentF
priority: 1,
longUrl: 'https://example.com/english-and-foo-query',
conditions: new ArrayCollection(
[RedirectCondition::forLanguage('en'), RedirectCondition::forQueryParam('foo', 'bar')],
[RedirectCondition::forLanguage('en'), RedirectCondition::forAnyValueQueryParam('foo')],
),
);
$manager->persist($englishAndFooQueryRule);