File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ public function failed(Throwable $exception)
102102 public function handle ()
103103 {
104104 $ action = app ($ this ->actionClass );
105+ $ action ->job = $ this ->job ;
105106 $ action ->{$ action ->queueMethod ()}(...$ this ->parameters );
106107 }
107108
Original file line number Diff line number Diff line change 1212use Illuminate \Support \Facades \Schema ;
1313use Spatie \QueueableAction \ActionJob ;
1414use Spatie \QueueableAction \Exceptions \InvalidConfiguration ;
15+ use Spatie \QueueableAction \Tests \TestClasses \ActionReturningJob ;
1516use Spatie \QueueableAction \Tests \TestClasses \ActionWithFailedMethod ;
1617use Spatie \QueueableAction \Tests \TestClasses \BackoffAction ;
1718use Spatie \QueueableAction \Tests \TestClasses \BackoffPropertyAction ;
2930use Spatie \QueueableAction \Tests \TestClasses \SimpleAction ;
3031use Spatie \QueueableAction \Tests \TestClasses \TaggedAction ;
3132use stdClass ;
33+ use function PHPUnit \Framework \assertInstanceOf ;
34+ use function PHPUnit \Framework \assertTrue ;
3235
3336beforeEach (function () {
3437 config ()->set ('database.default ' , 'testing ' );
4952 Queue::assertPushed (ActionJob::class);
5053});
5154
55+ test ('an action can be queued and receives job property ' , function () {
56+ $ action = new ActionReturningJob ();
57+ $ job = $ action ->onQueue ()->execute ();
58+ expect ($ job )->toBeInstanceOf (\Illuminate \Foundation \Bus \PendingDispatch::class);
59+ });
60+
5261test ('an action with dependencies and input can be executed on the queue ' , function () {
5362 /** @var \Spatie\QueueableAction\Tests\TestClasses\ComplexAction $action */
5463 $ action = app (ComplexAction::class);
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Spatie \QueueableAction \Tests \TestClasses ;
4+
5+ use Spatie \QueueableAction \QueueableAction ;
6+
7+ /**
8+ * @property $job
9+ */
10+ class ActionReturningJob
11+ {
12+ use QueueableAction;
13+
14+ public function execute ()
15+ {
16+ return $ this ->job ;
17+ }
18+ }
You can’t perform that action at this time.
0 commit comments