File tree Expand file tree Collapse file tree 8 files changed +44
-6
lines changed
Expand file tree Collapse file tree 8 files changed +44
-6
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ public function getIsQueuedAttribute()
8787 return $ this ->status === self ::STATUS_QUEUED ;
8888 }
8989
90- public function getIsRetrying ()
90+ public function getIsRetryingAttribute ()
9191 {
9292 return $ this ->status === self ::STATUS_RETRYING ;
9393 }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ trait Trackable
1414 protected $ statusId ;
1515 protected $ progressNow = 0 ;
1616 protected $ progressMax = 0 ;
17+ protected $ shouldTrack = true ;
1718
1819 protected function setProgressMax ($ value )
1920 {
@@ -76,7 +77,7 @@ public function getJobStatusId()
7677
7778 public function __sleep ()
7879 {
79- if (!$ this ->statusId ) {
80+ if (!$ this ->statusId && $ this -> shouldTrack ) {
8081 $ this ->prepareStatus ();
8182 }
8283
Original file line number Diff line number Diff line change 1010use Imtigger \LaravelJobStatus \Tests \Data \TestJobWithDatabase ;
1111use Imtigger \LaravelJobStatus \Tests \Data \TestJobWithException ;
1212use Imtigger \LaravelJobStatus \Tests \Data \TestJobWithoutConstruct ;
13+ use Imtigger \LaravelJobStatus \Tests \Data \TestJobWithoutTracking ;
1314
1415class TrackableTest extends TestCase
1516{
@@ -75,4 +76,17 @@ public function testWithoutPrepareStatus()
7576
7677 $ this ->assertEquals (1 , JobStatus::query ()->count ());
7778 }
79+
80+ public function testWithoutPrepareStatusAndTrackingDisabled ()
81+ {
82+ $ job = new TestJobWithoutTracking ();
83+
84+ $ this ->assertNull ($ job ->getJobStatusId ());
85+
86+ $ this ->assertEquals (0 , JobStatus::query ()->count ());
87+
88+ app (Dispatcher::class)->dispatch ($ job );
89+
90+ $ this ->assertEquals (0 , JobStatus::query ()->count ());
91+ }
7892}
Original file line number Diff line number Diff line change 66use Illuminate \Contracts \Queue \ShouldQueue ;
77use Illuminate \Foundation \Bus \Dispatchable ;
88use Illuminate \Queue \InteractsWithQueue ;
9- use Illuminate \Queue \SerializesModels ;
109use Imtigger \LaravelJobStatus \Trackable ;
1110use Imtigger \LaravelJobStatus \TrackableJob ;
1211
Original file line number Diff line number Diff line change 88use Illuminate \Foundation \Testing \Concerns \InteractsWithDatabase ;
99use Illuminate \Foundation \Testing \Constraints \HasInDatabase ;
1010use Illuminate \Queue \InteractsWithQueue ;
11- use Illuminate \Queue \SerializesModels ;
1211use Imtigger \LaravelJobStatus \Tests \Feature \TestCase ;
1312use Imtigger \LaravelJobStatus \Trackable ;
1413use Imtigger \LaravelJobStatus \TrackableJob ;
Original file line number Diff line number Diff line change 66use Illuminate \Contracts \Queue \ShouldQueue ;
77use Illuminate \Foundation \Bus \Dispatchable ;
88use Illuminate \Queue \InteractsWithQueue ;
9- use Illuminate \Queue \SerializesModels ;
109use Imtigger \LaravelJobStatus \Trackable ;
1110use Imtigger \LaravelJobStatus \TrackableJob ;
1211
Original file line number Diff line number Diff line change 66use Illuminate \Contracts \Queue \ShouldQueue ;
77use Illuminate \Foundation \Bus \Dispatchable ;
88use Illuminate \Queue \InteractsWithQueue ;
9- use Illuminate \Queue \SerializesModels ;
109use Imtigger \LaravelJobStatus \Trackable ;
1110use Imtigger \LaravelJobStatus \TrackableJob ;
1211
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Imtigger \LaravelJobStatus \Tests \Data ;
4+
5+ use Illuminate \Bus \Queueable ;
6+ use Illuminate \Contracts \Queue \ShouldQueue ;
7+ use Illuminate \Foundation \Bus \Dispatchable ;
8+ use Illuminate \Queue \InteractsWithQueue ;
9+ use Imtigger \LaravelJobStatus \Trackable ;
10+ use Imtigger \LaravelJobStatus \TrackableJob ;
11+
12+ class TestJobWithoutTracking implements ShouldQueue, TrackableJob
13+ {
14+ use InteractsWithQueue;
15+ use Queueable;
16+ use Dispatchable;
17+ use Trackable;
18+
19+ public function __construct ()
20+ {
21+ $ this ->shouldTrack = false ;
22+ }
23+
24+ public function handle ()
25+ {
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments