-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[11.x] Name of job set by displayName() must be honoured by Schedule #50961
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Illuminate\Tests\Console\Fixtures; | ||
|
||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
|
||
final class JobToTestWithSchedule implements ShouldQueue | ||
{ | ||
public function __invoke(): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Illuminate\Tests\Console\Scheduling; | ||
|
||
use Illuminate\Console\Scheduling\EventMutex; | ||
use Illuminate\Console\Scheduling\Schedule; | ||
use Illuminate\Console\Scheduling\SchedulingMutex; | ||
use Illuminate\Container\Container; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Tests\Console\Fixtures\JobToTestWithSchedule; | ||
use Mockery as m; | ||
use Mockery\MockInterface; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[CoversClass(Schedule::class)] | ||
final class ScheduleTest extends TestCase | ||
{ | ||
private Container $container; | ||
private EventMutex&MockInterface $eventMutex; | ||
private SchedulingMutex&MockInterface $schedulingMutex; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->container = new Container; | ||
Container::setInstance($this->container); | ||
$this->eventMutex = m::mock(EventMutex::class); | ||
$this->container->instance(EventMutex::class, $this->eventMutex); | ||
$this->schedulingMutex = m::mock(SchedulingMutex::class); | ||
$this->container->instance(SchedulingMutex::class, $this->schedulingMutex); | ||
} | ||
|
||
#[DataProvider('jobHonoursDisplayNameIfMethodExistsProvider')] | ||
public function testJobHonoursDisplayNameIfMethodExists(string|object $job, string $jobName): void | ||
{ | ||
$schedule = new Schedule(); | ||
$scheduledJob = $schedule->job($job); | ||
self::assertSame($jobName, $scheduledJob->description); | ||
} | ||
|
||
public static function jobHonoursDisplayNameIfMethodExistsProvider(): array | ||
{ | ||
$job = new class implements ShouldQueue | ||
{ | ||
public function displayName(): string | ||
{ | ||
return 'testJob-123'; | ||
} | ||
}; | ||
|
||
return [ | ||
[JobToTestWithSchedule::class, JobToTestWithSchedule::class], | ||
[new JobToTestWithSchedule, JobToTestWithSchedule::class], | ||
[$job, 'testJob-123'], | ||
]; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it will be better to make the signature properly typed as it can be done with php8.2. On one hand this is a BC for those extending this class. On another hand this is internal class and should not be extended.
Let me know what do you think. In case you consider this is as a major BC break, I would revert back signature as don't want to wait v12 to get this fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this as we currently do not fully type method signatures in the framework.