Skip to content

Commit

Permalink
[11.x] Fix attribute inheritance for nested scheduled groups (laravel…
Browse files Browse the repository at this point in the history
…#53626)

* fix nested group

* refactor tests
  • Loading branch information
istiak-tridip authored Nov 21, 2024
1 parent ac3d32e commit d8438ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Scheduling/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public function __call($method, $parameters)
}

if (method_exists(PendingEventAttributes::class, $method)) {
$this->attributes ??= new PendingEventAttributes($this);
$this->attributes ??= end($this->groupStack) ?: new PendingEventAttributes($this);

return $this->attributes->$method(...$parameters);
}
Expand Down
11 changes: 3 additions & 8 deletions tests/Integration/Console/Scheduling/ScheduleGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,14 @@ public function testGroupedScheduleCanBeNested()
->timezone('UTC')
->group(function () {
Schedule::command('inspire');
Schedule::timezone('Asia/Dhaka')
->everyMinute()
->group(function () {
Schedule::command('inspire');
});
Schedule::timezone('Asia/Dhaka')->group(function () {
Schedule::command('inspire');
});
});

$events = Schedule::events();
$this->assertSame('UTC', $events[0]->timezone);
$this->assertSame('0 0 * * *', $events[0]->expression);

$this->assertSame('Asia/Dhaka', $events[1]->timezone);
$this->assertSame('* * * * *', $events[1]->expression);
}

#[DataProvider('groupAttributes')]
Expand Down

0 comments on commit d8438ec

Please sign in to comment.