-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
293 additions
and
21 deletions.
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ jobs: | |
os: | ||
- "ubuntu-latest" | ||
php: | ||
- 8.2 | ||
- 8.3 | ||
dependencies: | ||
- "highest" | ||
experimental: | ||
|
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 |
---|---|---|
|
@@ -15,6 +15,7 @@ jobs: | |
php: | ||
- 8.2 | ||
- 8.3 | ||
- 8.4 | ||
experimental: | ||
- true | ||
|
||
|
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ jobs: | |
os: | ||
- "ubuntu-latest" | ||
php: | ||
- 8.2 | ||
- 8.3 | ||
dependencies: | ||
- "highest" | ||
experimental: | ||
|
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ jobs: | |
php: | ||
- 8.2 | ||
- 8.3 | ||
- 8.4 | ||
dependencies: | ||
- "highest" | ||
- "lowest" | ||
|
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
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,69 @@ | ||
<?php | ||
|
||
namespace Orchestra\Canvas\Console; | ||
|
||
use Orchestra\Canvas\Core\Concerns\CodeGenerator; | ||
use Orchestra\Canvas\Core\Concerns\TestGenerator; | ||
use Orchestra\Canvas\Core\Concerns\UsesGeneratorOverrides; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
|
||
/** | ||
* @see https://github.com/laravel/framework/blob/11.x/src/Illuminate/Foundation/Console/JobMiddlewareMakeCommand.php | ||
*/ | ||
#[AsCommand(name: 'make:job-middleware', description: 'Create a new job middleware class')] | ||
class JobMiddlewareMakeCommand extends \Illuminate\Foundation\Console\JobMiddlewareMakeCommand | ||
{ | ||
use CodeGenerator; | ||
use TestGenerator; | ||
use UsesGeneratorOverrides; | ||
|
||
/** | ||
* Configures the current command. | ||
* | ||
* @return void | ||
*/ | ||
#[\Override] | ||
protected function configure() | ||
{ | ||
parent::configure(); | ||
|
||
$this->addGeneratorPresetOptions(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return bool|null | ||
* | ||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException | ||
*/ | ||
#[\Override] | ||
public function handle() | ||
{ | ||
/** @phpstan-ignore return.type */ | ||
return $this->generateCode() ? self::SUCCESS : self::FAILURE; | ||
} | ||
|
||
/** | ||
* Get the destination class path. | ||
* | ||
* @param string $name | ||
* @return string | ||
*/ | ||
#[\Override] | ||
protected function getPath($name) | ||
{ | ||
return $this->getPathUsingCanvas($name); | ||
} | ||
|
||
/** | ||
* Get the root namespace for the class. | ||
* | ||
* @return string | ||
*/ | ||
#[\Override] | ||
protected function rootNamespace() | ||
{ | ||
return $this->rootNamespaceUsingCanvas(); | ||
} | ||
} |
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
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,38 @@ | ||
<?php | ||
|
||
namespace Orchestra\Canvas\Tests\Feature\Console; | ||
|
||
use Orchestra\Canvas\Tests\Feature\TestCase; | ||
use PHPUnit\Framework\Attributes\Test; | ||
|
||
class JobMiddlewareMakeCommandTest extends TestCase | ||
{ | ||
protected $files = [ | ||
'app/Jobs/Middleware/Foo.php', | ||
'tests/Feature/Jobs/Middleware/FooTest.php', | ||
]; | ||
|
||
#[Test] | ||
public function it_can_generate_job_file() | ||
{ | ||
$this->artisan('make:job-middleware', ['name' => 'Foo']) | ||
->assertExitCode(0); | ||
|
||
$this->assertFileContains([ | ||
'namespace App\Jobs\Middleware;', | ||
'class Foo', | ||
], 'app/Jobs/Middleware/Foo.php'); | ||
|
||
$this->assertFilenameNotExists('tests/Feature/Jobs/Middleware/FooTest.php'); | ||
} | ||
|
||
#[Test] | ||
public function it_can_generate_job_file_with_tests() | ||
{ | ||
$this->artisan('make:job-middleware', ['name' => 'Foo', '--test' => true]) | ||
->assertExitCode(0); | ||
|
||
$this->assertFilenameExists('app/Jobs/Middleware/Foo.php'); | ||
$this->assertFilenameExists('tests/Feature/Jobs/Middleware/FooTest.php'); | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Generators; | ||
|
||
class JobMiddlewareMakeCommandTest extends TestCase | ||
{ | ||
protected $files = [ | ||
'app/Jobs/Middleware/Foo.php', | ||
'tests/Feature/Jobs/Middleware/FooTest.php', | ||
]; | ||
|
||
public function testItCanGenerateJobFile() | ||
{ | ||
$this->artisan('make:job-middleware', ['name' => 'Foo']) | ||
->assertExitCode(0); | ||
|
||
$this->assertFileContains([ | ||
'namespace App\Jobs\Middleware;', | ||
'class Foo', | ||
], 'app/Jobs/Middleware/Foo.php'); | ||
|
||
$this->assertFilenameNotExists('tests/Feature/Jobs/Middleware/FooTest.php'); | ||
} | ||
|
||
public function testItCanGenerateJobFileWithTest() | ||
{ | ||
$this->artisan('make:job-middleware', ['name' => 'Foo', '--test' => true]) | ||
->assertExitCode(0); | ||
|
||
$this->assertFilenameExists('app/Jobs/Middleware/Foo.php'); | ||
$this->assertFilenameExists('tests/Feature/Jobs/Middleware/FooTest.php'); | ||
} | ||
} |
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
Oops, something went wrong.