Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Jul 16, 2024
1 parent 9c7e3ed commit 772ddd1
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 10 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
"php": "^8.2",
"composer-runtime-api": "^2.2",
"composer/semver": "^3.0",
"illuminate/console": "^11.13",
"illuminate/database": "^11.13",
"illuminate/filesystem": "^11.13",
"illuminate/support": "^11.13",
"illuminate/console": "^11.16",
"illuminate/database": "^11.16",
"illuminate/filesystem": "^11.16",
"illuminate/support": "^11.16",
"orchestra/canvas-core": "^9.0",
"orchestra/testbench-core": "^9.2",
"symfony/polyfill-php83": "^1.28",
"symfony/yaml": "^7.0"
},
"require-dev": {
"laravel/framework": "^11.13",
"laravel/framework": "^11.16",
"laravel/pint": "^1.6",
"mockery/mockery": "^1.6",
"phpstan/phpstan": "^1.11",
Expand Down
10 changes: 9 additions & 1 deletion tests/Feature/Console/JobMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ public function it_can_generate_job_file()

$this->assertFileContains([
'namespace App\Jobs;',
'use Illuminate\Bus\Queueable;',
'use Illuminate\Contracts\Queue\ShouldQueue;',
'use Illuminate\Foundation\Bus\Dispatchable;',
'use Illuminate\Foundation\Queue\Queueable;',
'use Illuminate\Queue\InteractsWithQueue;',
'use Illuminate\Queue\SerializesModels;',
'class FooCreated implements ShouldQueue',
' use Queueable;',
], 'app/Jobs/FooCreated.php');

$this->assertFileNotContains([
'use Illuminate\Bus\Queueable;',
], 'app/Jobs/FooCreated.php');

$this->assertFilenameNotExists('tests/Feature/Jobs/FooCreatedTest.php');
Expand All @@ -41,10 +46,13 @@ public function it_can_generate_synced_job_file()
'namespace App\Jobs;',
'use Illuminate\Foundation\Bus\Dispatchable;',
'class FooCreated',
' use Dispatchable;',
], 'app/Jobs/FooCreated.php');

$this->assertFileNotContains([
'use Illuminate\Bus\Queueable;',
'use Illuminate\Contracts\Queue\ShouldQueue;',
'use Illuminate\Foundation\Queue\Queueable;',
'use Illuminate\Queue\InteractsWithQueue;',
'use Illuminate\Queue\SerializesModels;',
], 'app/Jobs/FooCreated.php');
Expand Down
9 changes: 6 additions & 3 deletions workbench/tests/ClassMakeCommandTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php

namespace Integration\Generators;

use Illuminate\Tests\Integration\Generators\TestCase;
namespace Illuminate\Tests\Integration\Generators;

class ClassMakeCommandTest extends TestCase
{
protected array $files = [
'app/Reverb.php',
'app/Notification.php',
];

public function testItCanGenerateClassFile()
{
$this->artisan('make:class', ['name' => 'Reverb'])
Expand Down
5 changes: 4 additions & 1 deletion workbench/tests/JobMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ public function testItCanGenerateJobFile()

$this->assertFileContains([
'namespace App\Jobs;',
'use Illuminate\Bus\Queueable;',
'use Illuminate\Contracts\Queue\ShouldQueue;',
'use Illuminate\Foundation\Bus\Dispatchable;',
'use Illuminate\Foundation\Queue\Queueable;',
'use Illuminate\Queue\InteractsWithQueue;',
'use Illuminate\Queue\SerializesModels;',
'class FooCreated implements ShouldQueue',
'use Queueable;',
], 'app/Jobs/FooCreated.php');

$this->assertFilenameNotExists('tests/Feature/Jobs/FooCreatedTest.php');
Expand All @@ -36,10 +37,12 @@ public function testItCanGenerateSyncJobFile()
'namespace App\Jobs;',
'use Illuminate\Foundation\Bus\Dispatchable;',
'class FooCreated',
'use Dispatchable;',
], 'app/Jobs/FooCreated.php');

$this->assertFileNotContains([
'use Illuminate\Contracts\Queue\ShouldQueue;',
'use Illuminate\Foundation\Queue\Queueable;',
'use Illuminate\Queue\InteractsWithQueue;',
'use Illuminate\Queue\SerializesModels;',
], 'app/Jobs/FooCreated.php');
Expand Down
16 changes: 16 additions & 0 deletions workbench/tests/MailMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ public function testItCanGenerateMailFileWithMarkdownOption()
], 'resources/views/foo-mail.blade.php');
}

public function testItCanGenerateMailFileWithViewOption()
{
$this->artisan('make:mail', ['name' => 'FooMail', '--view' => 'foo-mail'])
->assertExitCode(0);

$this->assertFileContains([
'namespace App\Mail;',
'use Illuminate\Mail\Mailable;',
'class FooMail extends Mailable',
'return new Content(',
"view: 'foo-mail',",
], 'app/Mail/FooMail.php');

$this->assertFilenameExists('resources/views/foo-mail.blade.php');
}

public function testItCanGenerateMailFileWithTest()
{
$this->artisan('make:mail', ['name' => 'FooMail', '--test' => true])
Expand Down
34 changes: 34 additions & 0 deletions workbench/tests/ViewMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,38 @@ public function testItCanGenerateViewFileWithTest()
$this->assertFilenameExists('resources/views/foo.blade.php');
$this->assertFilenameExists('tests/Feature/View/FooTest.php');
}

public function testItCanGenerateMailWithNoInitialInput()
{
$this->artisan('make:mail')
->expectsQuestion('What should the mailable be named?', 'FooMail')
->expectsQuestion('Would you like to create a view?', 'none')
->assertExitCode(0);

$this->assertFilenameExists('app/Mail/FooMail.php');
$this->assertFilenameDoesNotExists('resources/views/mail/foo-mail.blade.php');
}

public function testItCanGenerateMailWithViewWithNoInitialInput()
{
$this->artisan('make:mail')
->expectsQuestion('What should the mailable be named?', 'MyFooMail')
->expectsQuestion('Would you like to create a view?', 'view')
->assertExitCode(0);

$this->assertFilenameExists('app/Mail/MyFooMail.php');
$this->assertFilenameExists('resources/views/mail/my-foo-mail.blade.php');
}

public function testItCanGenerateMailWithMarkdownViewWithNoInitialInput()
{
$this->artisan('make:mail')

->expectsQuestion('What should the mailable be named?', 'FooMail')
->expectsQuestion('Would you like to create a view?', 'markdown')
->assertExitCode(0);

$this->assertFilenameExists('app/Mail/MyFooMail.php');
$this->assertFilenameExists('resources/views/mail/my-foo-mail.blade.php');
}
}

0 comments on commit 772ddd1

Please sign in to comment.