From 7558712c7127f854ab531c4fd6a88eee81d34a1d Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 2 Mar 2023 08:22:02 -0600 Subject: [PATCH] Revert "[10.x] Fix custom themes not reseting on Markdown renderer (#46200)" This reverts commit c06dfacc1bf34e485be39a5fe185b0ea5100642e. --- src/Illuminate/Mail/Mailable.php | 4 ++- tests/Mail/MailMailableTest.php | 48 -------------------------------- 2 files changed, 3 insertions(+), 49 deletions(-) diff --git a/src/Illuminate/Mail/Mailable.php b/src/Illuminate/Mail/Mailable.php index 0910d4177a0f..8502f55ac49f 100644 --- a/src/Illuminate/Mail/Mailable.php +++ b/src/Illuminate/Mail/Mailable.php @@ -324,7 +324,9 @@ protected function buildMarkdownView() { $markdown = Container::getInstance()->make(Markdown::class); - $markdown->theme($this->theme ?? 'default'); + if (isset($this->theme)) { + $markdown->theme($this->theme); + } $data = $this->buildViewData(); diff --git a/tests/Mail/MailMailableTest.php b/tests/Mail/MailMailableTest.php index 6e93d0a19240..ea4801a908d2 100644 --- a/tests/Mail/MailMailableTest.php +++ b/tests/Mail/MailMailableTest.php @@ -7,10 +7,8 @@ use Illuminate\Contracts\View\Factory; use Illuminate\Mail\Attachment; use Illuminate\Mail\Mailable; -use Illuminate\Mail\Mailables\Content; use Illuminate\Mail\Mailables\Envelope; use Illuminate\Mail\Mailer; -use Illuminate\Mail\Markdown; use Illuminate\Mail\Transport\ArrayTransport; use Mockery as m; use PHPUnit\Framework\AssertionFailedError; @@ -439,52 +437,6 @@ public function testMailableSetsFromCorrectly() } } - public function testMailableSetsMarkdownThemeCorrectly() - { - $viewFactory = m::mock(Factory::class); - $viewFactory->shouldReceive('flushFinderCache'); - $viewFactory->shouldReceive('replaceNamespace')->andReturnSelf(); - $viewFactory->shouldReceive('make')->andReturnSelf(); - $viewFactory->shouldReceive('render')->andReturn('', 'body {}'); - $viewFactory->shouldReceive('exists')->andReturn(true); - - Container::getInstance()->instance(Factory::class, $viewFactory); - Container::getInstance()->singleton(Markdown::class); - Container::getInstance()->instance('mailer', new class - { - public function render() - { - // - } - }); - - (new class() extends Mailable - { - public $theme = 'custom-theme'; - - public function content() - { - return new Content( - markdown: 'mail.markdown', - ); - } - })->render(); - - $this->assertEquals('custom-theme', Container::getInstance()->make(Markdown::class)->getTheme()); - - (new class() extends Mailable - { - public function content() - { - return new Content( - markdown: 'mail.markdown', - ); - } - })->render(); - - $this->assertEquals('default', Container::getInstance()->make(Markdown::class)->getTheme()); - } - public function testMailableSetsSubjectCorrectly() { $mailable = new WelcomeMailableStub;