From 301a10b210d6a37c662da4a0d81574d3b7721e4f Mon Sep 17 00:00:00 2001 From: David Remer Date: Wed, 15 Mar 2023 11:08:22 +0200 Subject: [PATCH] Move TestAction to Stubs [MAILPOET-4935] --- .../Engine/Data/AutomationRunLogTest.php | 47 +--------------- .../Automation/Stubs/TestAction.php | 54 +++++++++++++++++++ 2 files changed, 56 insertions(+), 45 deletions(-) create mode 100644 mailpoet/tests/integration/Automation/Stubs/TestAction.php diff --git a/mailpoet/tests/integration/Automation/Engine/Data/AutomationRunLogTest.php b/mailpoet/tests/integration/Automation/Engine/Data/AutomationRunLogTest.php index 5e17d2d7fc..367ddc65e6 100644 --- a/mailpoet/tests/integration/Automation/Engine/Data/AutomationRunLogTest.php +++ b/mailpoet/tests/integration/Automation/Engine/Data/AutomationRunLogTest.php @@ -7,20 +7,16 @@ use MailPoet\Automation\Engine\Data\Automation; use MailPoet\Automation\Engine\Data\AutomationRun; use MailPoet\Automation\Engine\Data\AutomationRunLog; use MailPoet\Automation\Engine\Data\Step; -use MailPoet\Automation\Engine\Data\StepRunArgs; -use MailPoet\Automation\Engine\Data\StepValidationArgs; use MailPoet\Automation\Engine\Hooks; -use MailPoet\Automation\Engine\Integration\Action; use MailPoet\Automation\Engine\Registry; use MailPoet\Automation\Engine\Storage\AutomationRunLogStorage; use MailPoet\Automation\Engine\Storage\AutomationRunStorage; use MailPoet\Automation\Engine\Storage\AutomationStorage; -use MailPoet\Util\Security; -use MailPoet\Validator\Builder; -use MailPoet\Validator\Schema\ObjectSchema; +use MailPoet\Test\Automation\Stubs\TestAction; use MailPoet\WP\Functions as WPFunctions; use stdClass; +require_once __DIR__ . '/../../Stubs/TestAction.php'; //phpcs:disable Squiz.Classes.ClassFileName.NoMatch, Generic.Files.OneClassPerFile.MultipleFound, PSR1.Classes.ClassDeclaration.MultipleClasses class AutomationRunLogTest extends \MailPoetTest { @@ -271,42 +267,3 @@ class AutomationRunLogTest extends \MailPoetTest { return $action; } } - -class TestAction implements Action { - - private $callback; - private $key; - - public function __construct() { - $this->key = Security::generateRandomString(10); - } - - public function setCallback($callback) { - $this->callback = $callback; - } - - public function getSubjectKeys(): array { - return []; - } - - public function validate(StepValidationArgs $args): void { - } - - public function run(StepRunArgs $args): void { - if ($this->callback) { - ($this->callback)($args); - } - } - - public function getKey(): string { - return $this->key; - } - - public function getName(): string { - return 'Test Action'; - } - - public function getArgsSchema(): ObjectSchema { - return Builder::object(); - } -} diff --git a/mailpoet/tests/integration/Automation/Stubs/TestAction.php b/mailpoet/tests/integration/Automation/Stubs/TestAction.php new file mode 100644 index 0000000000..a314fd2c5f --- /dev/null +++ b/mailpoet/tests/integration/Automation/Stubs/TestAction.php @@ -0,0 +1,54 @@ +key = Security::generateRandomString(10); + } + + public function setCallback($callback) { + $this->callback = $callback; + } + + public function getSubjectKeys(): array { + return $this->subjectKeys; + } + + public function setSubjectKeys(string ...$subjectKeys): void { + $this->subjectKeys = $subjectKeys; + } + + public function validate(StepValidationArgs $args): void { + } + + public function run(StepRunArgs $args): void { + if ($this->callback) { + ($this->callback)($args); + } + } + + public function getKey(): string { + return $this->key; + } + + public function getName(): string { + return 'Test Action'; + } + + public function getArgsSchema(): ObjectSchema { + return Builder::object(); + } +}