diff --git a/mailpoet/lib/Automation/Integrations/Core/Filters/EnumArrayFilter.php b/mailpoet/lib/Automation/Integrations/Core/Filters/EnumArrayFilter.php index d57d8a869a..bf2d339b30 100644 --- a/mailpoet/lib/Automation/Integrations/Core/Filters/EnumArrayFilter.php +++ b/mailpoet/lib/Automation/Integrations/Core/Filters/EnumArrayFilter.php @@ -9,9 +9,9 @@ use MailPoet\Validator\Builder; use MailPoet\Validator\Schema\ObjectSchema; class EnumArrayFilter implements Filter { - public const CONDITION_MATCHES_ANY = 'matches-any'; - public const CONDITION_MATCHES_ALL = 'matches-all'; - public const CONDITION_MATCHES_NONE = 'matches-none'; + public const CONDITION_MATCHES_ANY_OF = 'matches-any-of'; + public const CONDITION_MATCHES_ALL_OF = 'matches-all-of'; + public const CONDITION_MATCHES_NONE_OF = 'matches-none-of'; public function getFieldType(): string { return Field::TYPE_ENUM_ARRAY; @@ -19,9 +19,9 @@ class EnumArrayFilter implements Filter { public function getConditions(): array { return [ - self::CONDITION_MATCHES_ANY => __('matches any', 'mailpoet'), - self::CONDITION_MATCHES_ALL => __('matches all', 'mailpoet'), - self::CONDITION_MATCHES_NONE => __('matches none', 'mailpoet'), + self::CONDITION_MATCHES_ANY_OF => __('matches any of', 'mailpoet'), + self::CONDITION_MATCHES_ALL_OF => __('matches all of', 'mailpoet'), + self::CONDITION_MATCHES_NONE_OF => __('matches none of', 'mailpoet'), ]; } @@ -46,11 +46,11 @@ class EnumArrayFilter implements Filter { $filterCount = count($filterValue); $matchedCount = count(array_intersect($value, $filterValue)); switch ($data->getCondition()) { - case self::CONDITION_MATCHES_ANY: + case self::CONDITION_MATCHES_ANY_OF: return $filterCount > 0 && $matchedCount > 0; - case self::CONDITION_MATCHES_ALL: + case self::CONDITION_MATCHES_ALL_OF: return $filterCount > 0 && $matchedCount === count($filterValue); - case self::CONDITION_MATCHES_NONE: + case self::CONDITION_MATCHES_NONE_OF: return $matchedCount === 0; default: return false; diff --git a/mailpoet/tests/integration/Automation/Engine/Control/TriggerHandlerTest.php b/mailpoet/tests/integration/Automation/Engine/Control/TriggerHandlerTest.php index 7d79406c9f..e215fdf8e0 100644 --- a/mailpoet/tests/integration/Automation/Engine/Control/TriggerHandlerTest.php +++ b/mailpoet/tests/integration/Automation/Engine/Control/TriggerHandlerTest.php @@ -171,7 +171,7 @@ class TriggerHandlerTest extends \MailPoetTest { // automation that doesn't match segments filter $unknownId = $segment->getId() + 1; - $filter = new Filter('enum_array', 'mailpoet:subscriber:segments', 'matches-any', ['value' => [$unknownId]]); + $filter = new Filter('enum_array', 'mailpoet:subscriber:segments', 'matches-any-of', ['value' => [$unknownId]]); $automation = $this->tester->createAutomation( 'Will not run', new Step('trigger', Step::TYPE_TRIGGER, $trigger->getKey(), [], [], [$filter]) @@ -182,7 +182,7 @@ class TriggerHandlerTest extends \MailPoetTest { $this->assertCount(0, $this->automationRunStorage->getAutomationRunsForAutomation($automation)); // matches segments filter - $filter = new Filter('enum_array', 'mailpoet:subscriber:segments', 'matches-any', ['value' => [$segment->getId()]]); + $filter = new Filter('enum_array', 'mailpoet:subscriber:segments', 'matches-any-of', ['value' => [$segment->getId()]]); $automation = $this->tester->createAutomation( 'Will run', new Step('trigger', Step::TYPE_TRIGGER, $trigger->getKey(), [], [], [$filter]) diff --git a/mailpoet/tests/unit/Automation/Integration/Core/Filters/EnumArrayFilterTest.php b/mailpoet/tests/unit/Automation/Integration/Core/Filters/EnumArrayFilterTest.php index e4134ca564..f47a18d349 100644 --- a/mailpoet/tests/unit/Automation/Integration/Core/Filters/EnumArrayFilterTest.php +++ b/mailpoet/tests/unit/Automation/Integration/Core/Filters/EnumArrayFilterTest.php @@ -13,9 +13,9 @@ class EnumArrayFilterTest extends MailPoetUnitTest { $this->assertSame('enum_array', $filter->getFieldType()); $this->assertSame([ - 'matches-any' => 'matches any', - 'matches-all' => 'matches all', - 'matches-none' => 'matches none', + 'matches-any-of' => 'matches any of', + 'matches-all-of' => 'matches all of', + 'matches-none-of' => 'matches none of', ], $filter->getConditions()); $this->assertSame([ @@ -49,42 +49,42 @@ class EnumArrayFilterTest extends MailPoetUnitTest { } public function testMatchesAnyCondition(): void { - $this->assertMatches('matches-any', [1, 2, 3], [1]); - $this->assertMatches('matches-any', [1, 2, 3], [1, 3, 9]); - $this->assertMatches('matches-any', [1], [1, 1, 1]); - $this->assertMatches('matches-any', [1, 1, 1], [1]); - $this->assertNotMatches('matches-any', [], []); - $this->assertNotMatches('matches-any', [], [1]); - $this->assertNotMatches('matches-any', [1, 2, 3], []); - $this->assertNotMatches('matches-any', [1, 2, 3], [7, 8, 9]); + $this->assertMatches('matches-any-of', [1, 2, 3], [1]); + $this->assertMatches('matches-any-of', [1, 2, 3], [1, 3, 9]); + $this->assertMatches('matches-any-of', [1], [1, 1, 1]); + $this->assertMatches('matches-any-of', [1, 1, 1], [1]); + $this->assertNotMatches('matches-any-of', [], []); + $this->assertNotMatches('matches-any-of', [], [1]); + $this->assertNotMatches('matches-any-of', [1, 2, 3], []); + $this->assertNotMatches('matches-any-of', [1, 2, 3], [7, 8, 9]); } public function testMatchesAllCondition(): void { - $this->assertMatches('matches-all', [1], [1]); - $this->assertMatches('matches-all', [1, 2], [2, 1]); - $this->assertMatches('matches-all', [1, 2], [2, 1, 3]); - $this->assertMatches('matches-all', [1], [1, 1, 1]); - $this->assertMatches('matches-all', [1, 1, 1], [1]); - $this->assertNotMatches('matches-all', [], []); - $this->assertNotMatches('matches-all', [], [1]); - $this->assertNotMatches('matches-all', [1, 2, 3], []); - $this->assertNotMatches('matches-all', [1, 2, 3], [2, 3, 4]); + $this->assertMatches('matches-all-of', [1], [1]); + $this->assertMatches('matches-all-of', [1, 2], [2, 1]); + $this->assertMatches('matches-all-of', [1, 2], [2, 1, 3]); + $this->assertMatches('matches-all-of', [1], [1, 1, 1]); + $this->assertMatches('matches-all-of', [1, 1, 1], [1]); + $this->assertNotMatches('matches-all-of', [], []); + $this->assertNotMatches('matches-all-of', [], [1]); + $this->assertNotMatches('matches-all-of', [1, 2, 3], []); + $this->assertNotMatches('matches-all-of', [1, 2, 3], [2, 3, 4]); } public function testMatchesNoneCondition(): void { - $this->assertMatches('matches-none', [], []); - $this->assertMatches('matches-none', [], [1]); - $this->assertMatches('matches-none', [1], []); - $this->assertMatches('matches-none', [1], [2]); - $this->assertMatches('matches-none', [1, 2, 3], []); - $this->assertMatches('matches-none', [1, 2, 3], [4, 5, 6]); - $this->assertMatches('matches-none', [1], [2, 2, 2]); - $this->assertMatches('matches-none', [1, 1, 1], [2]); - $this->assertNotMatches('matches-none', [1], [1]); - $this->assertNotMatches('matches-none', [1, 2, 3], [2]); - $this->assertNotMatches('matches-none', [1, 2, 3], [3, 4, 5]); - $this->assertNotMatches('matches-none', [1], [1, 1, 1]); - $this->assertNotMatches('matches-none', [1, 1, 1], [1]); + $this->assertMatches('matches-none-of', [], []); + $this->assertMatches('matches-none-of', [], [1]); + $this->assertMatches('matches-none-of', [1], []); + $this->assertMatches('matches-none-of', [1], [2]); + $this->assertMatches('matches-none-of', [1, 2, 3], []); + $this->assertMatches('matches-none-of', [1, 2, 3], [4, 5, 6]); + $this->assertMatches('matches-none-of', [1], [2, 2, 2]); + $this->assertMatches('matches-none-of', [1, 1, 1], [2]); + $this->assertNotMatches('matches-none-of', [1], [1]); + $this->assertNotMatches('matches-none-of', [1, 2, 3], [2]); + $this->assertNotMatches('matches-none-of', [1, 2, 3], [3, 4, 5]); + $this->assertNotMatches('matches-none-of', [1], [1, 1, 1]); + $this->assertNotMatches('matches-none-of', [1, 1, 1], [1]); } public function testUnknownCondition(): void {