mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Remove name and uniqueness in redirect condition table
This commit is contained in:
@@ -13,13 +13,11 @@ use function sprintf;
|
||||
class ListRedirectRulesTest extends ApiTestCase
|
||||
{
|
||||
private const LANGUAGE_EN_CONDITION = [
|
||||
'name' => 'language-en',
|
||||
'type' => 'language',
|
||||
'matchKey' => null,
|
||||
'matchValue' => 'en',
|
||||
];
|
||||
private const QUERY_FOO_BAR_CONDITION = [
|
||||
'name' => 'query-foo-bar',
|
||||
'type' => 'query',
|
||||
'matchKey' => 'foo',
|
||||
'matchValue' => 'bar',
|
||||
@@ -54,13 +52,12 @@ class ListRedirectRulesTest extends ApiTestCase
|
||||
'longUrl' => 'https://example.com/multiple-query-params',
|
||||
'priority' => 2,
|
||||
'conditions' => [
|
||||
self::QUERY_FOO_BAR_CONDITION,
|
||||
[
|
||||
'name' => 'query-hello-world',
|
||||
'type' => 'query',
|
||||
'matchKey' => 'hello',
|
||||
'matchValue' => 'world',
|
||||
],
|
||||
self::QUERY_FOO_BAR_CONDITION,
|
||||
],
|
||||
],
|
||||
[
|
||||
@@ -73,7 +70,6 @@ class ListRedirectRulesTest extends ApiTestCase
|
||||
'priority' => 4,
|
||||
'conditions' => [
|
||||
[
|
||||
'name' => 'device-android',
|
||||
'type' => 'device',
|
||||
'matchKey' => null,
|
||||
'matchValue' => 'android',
|
||||
@@ -85,7 +81,6 @@ class ListRedirectRulesTest extends ApiTestCase
|
||||
'priority' => 5,
|
||||
'conditions' => [
|
||||
[
|
||||
'name' => 'device-ios',
|
||||
'type' => 'device',
|
||||
'matchKey' => null,
|
||||
'matchValue' => 'ios',
|
||||
|
||||
@@ -25,27 +25,14 @@ class ShortUrlRedirectRulesFixture extends AbstractFixture implements DependentF
|
||||
/** @var ShortUrl $defShortUrl */
|
||||
$defShortUrl = $this->getReference('def456_short_url');
|
||||
|
||||
$englishCondition = RedirectCondition::forLanguage('en');
|
||||
$manager->persist($englishCondition);
|
||||
|
||||
$fooQueryCondition = RedirectCondition::forQueryParam('foo', 'bar');
|
||||
$manager->persist($fooQueryCondition);
|
||||
|
||||
$helloQueryCondition = RedirectCondition::forQueryParam('hello', 'world');
|
||||
$manager->persist($helloQueryCondition);
|
||||
|
||||
$androidCondition = RedirectCondition::forDevice(DeviceType::ANDROID);
|
||||
$manager->persist($androidCondition);
|
||||
|
||||
$iosCondition = RedirectCondition::forDevice(DeviceType::IOS);
|
||||
$manager->persist($iosCondition);
|
||||
|
||||
// Create rules disordered to make sure the order by priority works
|
||||
$multipleQueryParamsRule = new ShortUrlRedirectRule(
|
||||
shortUrl: $defShortUrl,
|
||||
priority: 2,
|
||||
longUrl: 'https://example.com/multiple-query-params',
|
||||
conditions: new ArrayCollection([$helloQueryCondition, $fooQueryCondition]),
|
||||
conditions: new ArrayCollection(
|
||||
[RedirectCondition::forQueryParam('hello', 'world'), RedirectCondition::forQueryParam('foo', 'bar')],
|
||||
),
|
||||
);
|
||||
$manager->persist($multipleQueryParamsRule);
|
||||
|
||||
@@ -53,7 +40,9 @@ class ShortUrlRedirectRulesFixture extends AbstractFixture implements DependentF
|
||||
shortUrl: $defShortUrl,
|
||||
priority: 1,
|
||||
longUrl: 'https://example.com/english-and-foo-query',
|
||||
conditions: new ArrayCollection([$englishCondition, $fooQueryCondition]),
|
||||
conditions: new ArrayCollection(
|
||||
[RedirectCondition::forLanguage('en'), RedirectCondition::forQueryParam('foo', 'bar')],
|
||||
),
|
||||
);
|
||||
$manager->persist($englishAndFooQueryRule);
|
||||
|
||||
@@ -61,7 +50,7 @@ class ShortUrlRedirectRulesFixture extends AbstractFixture implements DependentF
|
||||
shortUrl: $defShortUrl,
|
||||
priority: 4,
|
||||
longUrl: 'https://blog.alejandrocelaya.com/android',
|
||||
conditions: new ArrayCollection([$androidCondition]),
|
||||
conditions: new ArrayCollection([RedirectCondition::forDevice(DeviceType::ANDROID)]),
|
||||
);
|
||||
$manager->persist($androidRule);
|
||||
|
||||
@@ -69,7 +58,7 @@ class ShortUrlRedirectRulesFixture extends AbstractFixture implements DependentF
|
||||
shortUrl: $defShortUrl,
|
||||
priority: 3,
|
||||
longUrl: 'https://example.com/only-english',
|
||||
conditions: new ArrayCollection([$englishCondition]),
|
||||
conditions: new ArrayCollection([RedirectCondition::forLanguage('en')]),
|
||||
);
|
||||
$manager->persist($onlyEnglishRule);
|
||||
|
||||
@@ -77,7 +66,7 @@ class ShortUrlRedirectRulesFixture extends AbstractFixture implements DependentF
|
||||
shortUrl: $defShortUrl,
|
||||
priority: 5,
|
||||
longUrl: 'https://blog.alejandrocelaya.com/ios',
|
||||
conditions: new ArrayCollection([$iosCondition]),
|
||||
conditions: new ArrayCollection([RedirectCondition::forDevice(DeviceType::IOS)]),
|
||||
);
|
||||
$manager->persist($iosRule);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user