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
|
<?php
namespace Illuminate\Tests\Integration\Mail;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
abstract class MailableTestCase extends TestCase
{
/** {@inheritdoc} */
#[\Override]
protected function defineEnvironment($app)
{
$app['view']->addLocation(__DIR__.'/Fixtures');
}
#[DataProvider('markdownEncodedDataProvider')]
public function testItCanAssertMarkdownEncodedString($given, $expected)
{
$mailable = new class($given) extends Mailable
{
public function __construct(public string $message)
{
//
}
public function envelope()
{
return new Envelope(
subject: 'My basic title',
);
}
public function content()
{
return new Content(
markdown: 'message',
);
}
};
$mailable->assertSeeInHtml($expected, false);
}
public static function markdownEncodedDataProvider()
{
yield ['[Laravel](https://laravel.com)', 'My message is: [Laravel](https://laravel.com)'];
yield [
'',
'My message is: ',
];
yield [
'Visit https://laravel.com/docs to browse the documentation',
'My message is: Visit https://laravel.com/docs to browse the documentation',
];
yield [
'Visit <https://laravel.com/docs> to browse the documentation',
'My message is: Visit <https://laravel.com/docs> to browse the documentation',
];
yield [
'Visit <span>https://laravel.com/docs</span> to browse the documentation',
'My message is: Visit <span>https://laravel.com/docs</span> to browse the documentation',
];
}
}
|