diff --git a/src/Illuminate/Mail/Markdown.php b/src/Illuminate/Mail/Markdown.php index a506f837f59f..725247e4d00d 100644 --- a/src/Illuminate/Mail/Markdown.php +++ b/src/Illuminate/Mail/Markdown.php @@ -63,8 +63,8 @@ public function render($view, array $data = [], $inliner = null) 'mail', $this->htmlComponentPaths() )->make($view, $data)->render(); - if ($this->view->exists($this->theme)) { - $theme = $this->theme; + if ($this->view->exists($custom = Str::start($this->theme, 'mail.'))) { + $theme = $custom; } else { $theme = Str::contains($this->theme, '::') ? $this->theme diff --git a/tests/Mail/MailMarkdownTest.php b/tests/Mail/MailMarkdownTest.php index 7878174ac43b..19341fde67a0 100644 --- a/tests/Mail/MailMarkdownTest.php +++ b/tests/Mail/MailMarkdownTest.php @@ -20,7 +20,7 @@ public function testRenderFunctionReturnsHtml() $markdown = new Markdown($viewFactory); $viewFactory->shouldReceive('flushFinderCache')->once(); $viewFactory->shouldReceive('replaceNamespace')->once()->with('mail', $markdown->htmlComponentPaths())->andReturnSelf(); - $viewFactory->shouldReceive('exists')->with('default')->andReturn(false); + $viewFactory->shouldReceive('exists')->with('mail.default')->andReturn(false); $viewFactory->shouldReceive('make')->with('view', [])->andReturnSelf(); $viewFactory->shouldReceive('make')->with('mail::themes.default', [])->andReturnSelf(); $viewFactory->shouldReceive('render')->twice()->andReturn('', 'body {}'); @@ -37,9 +37,26 @@ public function testRenderFunctionReturnsHtmlWithCustomTheme() $markdown->theme('yaz'); $viewFactory->shouldReceive('flushFinderCache')->once(); $viewFactory->shouldReceive('replaceNamespace')->once()->with('mail', $markdown->htmlComponentPaths())->andReturnSelf(); - $viewFactory->shouldReceive('exists')->with('yaz')->andReturn(true); + $viewFactory->shouldReceive('exists')->with('mail.yaz')->andReturn(true); $viewFactory->shouldReceive('make')->with('view', [])->andReturnSelf(); - $viewFactory->shouldReceive('make')->with('yaz', [])->andReturnSelf(); + $viewFactory->shouldReceive('make')->with('mail.yaz', [])->andReturnSelf(); + $viewFactory->shouldReceive('render')->twice()->andReturn('', 'body {}'); + + $result = $markdown->render('view', []); + + $this->assertNotFalse(strpos($result, '')); + } + + public function testRenderFunctionReturnsHtmlWithCustomThemeWithMailPrefix() + { + $viewFactory = m::mock(Factory::class); + $markdown = new Markdown($viewFactory); + $markdown->theme('mail.yaz'); + $viewFactory->shouldReceive('flushFinderCache')->once(); + $viewFactory->shouldReceive('replaceNamespace')->once()->with('mail', $markdown->htmlComponentPaths())->andReturnSelf(); + $viewFactory->shouldReceive('exists')->with('mail.yaz')->andReturn(true); + $viewFactory->shouldReceive('make')->with('view', [])->andReturnSelf(); + $viewFactory->shouldReceive('make')->with('mail.yaz', [])->andReturnSelf(); $viewFactory->shouldReceive('render')->twice()->andReturn('', 'body {}'); $result = $markdown->render('view', []);