1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
<?php
namespace Illuminate\Tests\Integration\Generators;
class NotificationMakeCommandTest extends TestCase
{
protected $files = [
'app/Notifications/FooNotification.php',
'resources/views/foo-notification.blade.php',
'tests/Feature/Notifications/FooNotificationTest.php',
];
public function testItCanGenerateNotificationFile()
{
$this->artisan('make:notification', ['name' => 'FooNotification'])
->assertExitCode(0);
$this->assertFileContains([
'namespace App\Notifications;',
'use Illuminate\Notifications\Notification;',
'class FooNotification extends Notification',
'return (new MailMessage)',
], 'app/Notifications/FooNotification.php');
$this->assertFilenameNotExists('resources/views/foo-notification.blade.php');
$this->assertFilenameNotExists('tests/Feature/Notifications/FooNotificationTest.php');
}
public function testItCanGenerateNotificationFileWithMarkdownOption()
{
$this->artisan('make:notification', ['name' => 'FooNotification', '--markdown' => 'foo-notification'])
->assertExitCode(0);
$this->assertFileContains([
'namespace App\Notifications;',
'class FooNotification extends Notification',
"return (new MailMessage)->markdown('foo-notification')",
], 'app/Notifications/FooNotification.php');
$this->assertFileContains([
'<x-mail::message>',
], 'resources/views/foo-notification.blade.php');
}
public function testItCanGenerateNotificationFileWithTest()
{
$this->artisan('make:notification', ['name' => 'FooNotification', '--test' => true])
->assertExitCode(0);
$this->assertFilenameExists('app/Notifications/FooNotification.php');
$this->assertFilenameNotExists('resources/views/foo-notification.blade.php');
$this->assertFilenameExists('tests/Feature/Notifications/FooNotificationTest.php');
}
public function testItCanGenerateNotificationFileWithNotInitialInput()
{
$this->artisan('make:notification')
->expectsQuestion('What should the notification be named?', 'FooNotification')
->expectsQuestion('Would you like to create a markdown view?', false)
->assertExitCode(0);
$this->assertFilenameExists('app/Notifications/FooNotification.php');
$this->assertFileDoesNotExist('resources/views/foo-notification.blade.php');
}
public function testItCanGenerateNotificationFileWithMarkdownTemplateWithNotInitialInput()
{
$this->artisan('make:notification')
->expectsQuestion('What should the notification be named?', 'FooNotification')
->expectsQuestion('Would you like to create a markdown view?', true)
->expectsQuestion('What should the markdown view be named?', 'foo-notification')
->assertExitCode(0);
$this->assertFilenameExists('app/Notifications/FooNotification.php');
$this->assertFilenameExists('resources/views/foo-notification.blade.php');
}
}
|