diff --git a/src/Testing/Queue/Contracts/RunJobActionContractAssert.php b/src/Testing/Queue/Contracts/RunJobActionContractAssert.php index c6eec0be..4aa3a74e 100644 --- a/src/Testing/Queue/Contracts/RunJobActionContractAssert.php +++ b/src/Testing/Queue/Contracts/RunJobActionContractAssert.php @@ -21,11 +21,15 @@ public function __construct(array $execute = []) $this->setExpectations(RunJobActionContractExpectation::class, $execute); } - public function execute(Job $job, Command $command = null, ?string $method = null): mixed + public function execute(Job $job, Command $command = null, string $method = null): mixed { $_expectation = $this->getExpectation(RunJobActionContractExpectation::class); $_message = $this->getDebugMessage(); + if (is_callable($_expectation->_preHook)) { + call_user_func($_expectation->_preHook, $job, $command, $method, $_expectation); + } + Assert::assertEquals($_expectation->job, $job, $_message); Assert::assertEquals($_expectation->command, $command, $_message); Assert::assertEquals($_expectation->method, $method, $_message); diff --git a/src/Testing/Queue/Contracts/RunJobActionContractExpectation.php b/src/Testing/Queue/Contracts/RunJobActionContractExpectation.php index bb1292c6..9ccb3a92 100644 --- a/src/Testing/Queue/Contracts/RunJobActionContractExpectation.php +++ b/src/Testing/Queue/Contracts/RunJobActionContractExpectation.php @@ -12,6 +12,7 @@ final class RunJobActionContractExpectation { /** * @param Closure(Job, Command, string|null, self):void|null $_hook + * @param Closure(Job, Command, string|null, self):void|null $_preHook */ public function __construct( public readonly mixed $return, @@ -19,6 +20,7 @@ public function __construct( public readonly ?Command $command = null, public readonly ?string $method = null, public readonly ?Closure $_hook = null, + public readonly ?Closure $_preHook = null, ) { } }