|
2 | 2 |
|
3 | 3 | namespace Illuminate\Tests\Integration\Mail; |
4 | 4 |
|
| 5 | +use Illuminate\Foundation\Auth\User; |
| 6 | +use Illuminate\Foundation\Testing\LazilyRefreshDatabase; |
5 | 7 | use Illuminate\Mail\Mailable; |
6 | 8 | use Illuminate\Mail\Mailables\Content; |
7 | 9 | use Illuminate\Mail\Mailables\Envelope; |
| 10 | +use Orchestra\Testbench\Attributes\WithMigration; |
| 11 | +use Orchestra\Testbench\Factories\UserFactory; |
8 | 12 | use Orchestra\Testbench\TestCase; |
9 | 13 | use PHPUnit\Framework\Attributes\DataProvider; |
10 | 14 |
|
11 | 15 | class MailableTest extends TestCase |
12 | 16 | { |
C12A
tr>
| 17 | + use LazilyRefreshDatabase; |
| 18 | + |
13 | 19 | /** {@inheritdoc} */ |
14 | 20 | #[\Override] |
15 | 21 | protected function defineEnvironment($app) |
@@ -69,4 +75,55 @@ public static function markdownEncodedDataProvider() |
69 | 75 | 'My message is: Visit <span>https://laravel.com/docs</span> to browse the documentation', |
70 | 76 | ]; |
71 | 77 | } |
| 78 | + |
| 79 | + #[WithMigration] |
| 80 | + #[DataProvider('markdownEncodedTemplateDataProvider')] |
| 81 | + public function testItCanAssertMarkdownEncodedStringUsingTemplate($given, $expected) |
| 82 | + { |
| 83 | + $user = UserFactory::new()->create([ |
| 84 | + 'name' => $given, |
| 85 | + ]); |
| 86 | + |
| 87 | + $mailable = new class($user) extends Mailable |
| 88 | + { |
| 89 | + public $theme = 'taylor'; |
| 90 | + |
| 91 | + public function __construct(public User $user) |
| 92 | + { |
| 93 | + // |
| 94 | + } |
| 95 | + |
| 96 | + public function build() |
| 97 | + { |
| 98 | + return $this->markdown('message-with-template'); |
| 99 | + } |
| 100 | + }; |
| 101 | + |
| 102 | + $mailable->assertSeeInHtml($expected, false); |
| 103 | + } |
| 104 | + |
| 105 | + public static function markdownEncodedTemplateDataProvider() |
| 106 | + { |
| 107 | + yield ['[Laravel](https://laravel.com)', '<em>Hi</em> [Laravel](https://laravel.com)']; |
| 108 | + |
| 109 | + yield [ |
| 110 | + '', |
| 111 | + '<em>Hi</em> ', |
| 112 | + ]; |
| 113 | + |
| 114 | + yield [ |
| 115 | + 'Visit https://laravel.com/docs to browse the documentation', |
| 116 | + '<em>Hi</em> Visit https://laravel.com/docs to browse the documentation', |
| 117 | + ]; |
| 118 | + |
| 119 | + yield [ |
| 120 | + 'Visit <https://laravel.com/docs> to browse the documentation', |
| 121 | + '<em>Hi</em> Visit <https://laravel.com/docs> to browse the documentation', |
| 122 | + ]; |
| 123 | + |
| 124 | + yield [ |
| 125 | + 'Visit <span>https://laravel.com/docs</span> to browse the documentation', |
| 126 | + '<em>Hi</em> Visit <span>https://laravel.com/docs</span> to browse the documentation', |
| 127 | + ]; |
| 128 | + } |
72 | 129 | } |
0 commit comments