Skip to content

Commit

Permalink
feat(Queue): Add _preHook closure to RunJobActionContractExpectation
Browse files Browse the repository at this point in the history
  • Loading branch information
pionl committed Feb 28, 2024
1 parent d6e8e02 commit 3429635
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Testing/Queue/Contracts/RunJobActionContractAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ 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,
public readonly Job $job,
public readonly ?Command $command = null,
public readonly ?string $method = null,
public readonly ?Closure $_hook = null,
public readonly ?Closure $_preHook = null,
) {
}
}

0 comments on commit 3429635

Please sign in to comment.