File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed
src/Illuminate/Console/Scheduling
tests/Integration/Console/Scheduling Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -312,7 +312,8 @@ public function group(Closure $events)
312
312
throw new RuntimeException ('Invoke an attribute method such as Schedule::daily() before defining a schedule group. ' );
313
313
}
314
314
315
- $ this ->groupStack [] = clone $ this ->attributes ;
315
+ $ this ->groupStack [] = $ this ->attributes ;
316
+ $ this ->attributes = null ;
316
317
317
318
$ events ($ this );
318
319
@@ -327,17 +328,17 @@ public function group(Closure $events)
327
328
*/
328
329
protected function mergePendingAttributes (Event $ event )
329
330
{
330
- if (isset ($ this ->attributes )) {
331
- $ this ->attributes ->mergeAttributes ($ event );
332
-
333
- $ this ->attributes = null ;
334
- }
335
-
336
331
if (! empty ($ this ->groupStack )) {
337
332
$ group = array_last ($ this ->groupStack );
338
333
339
334
$ group ->mergeAttributes ($ event );
340
335
}
336
+
337
+ if (isset ($ this ->attributes )) {
338
+ $ this ->attributes ->mergeAttributes ($ event );
339
+
340
+ $ this ->attributes = null ;
341
+ }
341
342
}
342
343
343
344
/**
@@ -476,7 +477,7 @@ public function __call($method, $parameters)
476
477
}
477
478
478
479
if (method_exists (PendingEventAttributes::class, $ method )) {
479
- $ this ->attributes ??= array_last ($ this ->groupStack ) ? : new PendingEventAttributes ($ this );
480
+ $ this ->attributes ??= $ this -> groupStack ? clone array_last ($ this ->groupStack ) : new PendingEventAttributes ($ this );
480
481
481
482
return $ this ->attributes ->$ method (...$ parameters );
482
483
}
Original file line number Diff line number Diff line change @@ -180,4 +180,19 @@ public static function scheduleTestCases()
180
180
],
181
181
];
182
182
}
183
+
184
+ public function testGroupedPendingEventAttribute ()
185
+ {
186
+ $ schedule = new ScheduleClass ;
187
+ $ schedule ->weekdays ()->group (function ($ schedule ) {
188
+ $ schedule ->command ('inspire ' )->at ('00:00 ' ); // this is event, not pending attribute
189
+ $ schedule ->at ('01:00 ' )->command ('inspire ' ); // this is pending attribute
190
+ $ schedule ->command ('inspire ' ); // this goes back to group pending attribute
191
+ });
192
+
193
+ $ events = $ schedule ->events ();
194
+ $ this ->assertSame ('0 0 * * 1-5 ' , $ events [0 ]->expression );
195
+ $ this ->assertSame ('0 1 * * 1-5 ' , $ events [1 ]->expression );
196
+ $ this ->assertSame ('* * * * 1-5 ' , $ events [2 ]->expression );
197
+ }
183
198
}
You can’t perform that action at this time.
0 commit comments