File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
tests/lib/Integration/Queue Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ public function resourceId(): ?string
65
65
}
66
66
67
67
/**
68
- * Set the resource that the job relates to .
68
+ * Set the resource that was created by the job .
69
69
*
70
70
* If a job is creating a new resource, this method can be used to update
71
71
* the client job with the created resource. This method does nothing if the
@@ -74,7 +74,7 @@ public function resourceId(): ?string
74
74
* @param $resource
75
75
* @return void
76
76
*/
77
- public function setResource ($ resource ): void
77
+ public function didCreate ($ resource ): void
78
78
{
79
79
if ($ this ->wasClientDispatched ()) {
80
80
$ this ->clientJob ->setResource ($ resource )->save ();
Original file line number Diff line number Diff line change 5
5
use Carbon \Carbon ;
6
6
use CloudCreativity \LaravelJsonApi \Queue \ClientJob ;
7
7
use CloudCreativity \LaravelJsonApi \Tests \Integration \TestCase ;
8
+ use DummyApp \Download ;
8
9
9
10
class QueueEventsTest extends TestCase
10
11
{
@@ -31,6 +32,10 @@ public function testCompletes()
31
32
'completed_at ' => Carbon::now ()->format ('Y-m-d H:i:s ' ),
32
33
'failed ' => false ,
33
34
]);
35
+
36
+ $ clientJob = $ job ->clientJob ->refresh ();
37
+
38
+ $ this ->assertInstanceOf (Download::class, $ clientJob ->getResource ());
34
39
}
35
40
36
41
public function testFails ()
Original file line number Diff line number Diff line change 3
3
namespace CloudCreativity \LaravelJsonApi \Tests \Integration \Queue ;
4
4
5
5
use CloudCreativity \LaravelJsonApi \Queue \ClientDispatchable ;
6
+ use DummyApp \Download ;
6
7
use Illuminate \Bus \Queueable ;
7
8
use Illuminate \Contracts \Queue \ShouldQueue ;
8
9
use Illuminate \Foundation \Bus \Dispatchable ;
@@ -29,12 +30,20 @@ class TestJob implements ShouldQueue
29
30
public $ tries = 2 ;
30
31
31
32
/**
33
+ * Execute the job.
34
+ *
35
+ * @return Download
32
36
* @throws \Exception
33
37
*/
34
- public function handle (): void
38
+ public function handle (): Download
35
39
{
36
40
if ($ this ->ex ) {
37
41
throw new \LogicException ('Boom. ' );
38
42
}
43
+
44
+ $ download = factory (Download::class)->create ();
45
+ $ this ->didCreate ($ download );
46
+
47
+ return $ download ;
39
48
}
40
49
}
You can’t perform that action at this time.
0 commit comments