-
Notifications
You must be signed in to change notification settings - Fork 1
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
9 changed files
with
101 additions
and
15 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM php:8.1-cli | ||
FROM php:8.3-cli | ||
|
||
WORKDIR /workdir | ||
|
||
|
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,15 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\LaravelUtils\Mail; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class MailServiceProvider extends ServiceProvider | ||
{ | ||
public function register(): void | ||
{ | ||
$this->commands([ | ||
SendTestMailCommand::class, | ||
]); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace MLL\LaravelUtils\Mail; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Mail\Message; | ||
use Illuminate\Mail\PendingMail; | ||
use Illuminate\Support\Facades\Mail; | ||
|
||
class SendTestMailCommand extends Command | ||
{ | ||
protected $signature = ' | ||
send-test-mail | ||
{--to= : Recipient} | ||
'; | ||
|
||
public function handle(): void | ||
{ | ||
Mail::to($this->option('to')) | ||
->send(new TestMail()); | ||
} | ||
} |
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,15 @@ | ||
<?php | ||
|
||
namespace MLL\LaravelUtils\Mail; | ||
|
||
use Illuminate\Mail\Mailable; | ||
|
||
class TestMail extends Mailable | ||
{ | ||
/** @return $this */ | ||
public function build(): self | ||
{ | ||
return $this->subject('This is a test mail sent by php artisan send-test-mail') | ||
->html(/** @lang HTML */ "<p>This is a test mail sent by php artisan send-test-mail</p>"); | ||
} | ||
} |
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,29 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\LaravelUtils\Tests\Mail; | ||
|
||
use Illuminate\Support\Facades\Mail; | ||
use MLL\LaravelUtils\Mail\TestMail; | ||
use MLL\LaravelUtils\Tests\TestCase; | ||
|
||
final class SendTestMailCommandTest extends TestCase | ||
{ | ||
public function testSendsTestMail(): void | ||
{ | ||
Mail::fake(); | ||
|
||
$to = '[email protected]'; | ||
|
||
$this->artisan('send-test-mail', [ | ||
'--to' => $to, | ||
]); | ||
|
||
$sent = Mail::sent(TestMail::class); | ||
|
||
$this->assertCount(1, $sent); | ||
Check failure on line 23 in tests/Mail/SendTestMailCommandTest.php
|
||
|
||
$testMail = $sent->firstOrFail(); | ||
assert($testMail instanceof TestMail); | ||
$testMail->assertTo($to); | ||
} | ||
} |
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