Skip to content

Commit 0ee9a4b

Browse files
committed
Expect custom themes to be in mail subdirectory
1 parent 72ea328 commit 0ee9a4b

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/Illuminate/Mail/Markdown.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public function render($view, array $data = [], $inliner = null)
6363
'mail', $this->htmlComponentPaths()
6464
)->make($view, $data)->render();
6565

66-
if ($this->view->exists($this->theme)) {
67-
$theme = $this->theme;
66+
if ($this->view->exists($custom = Str::start($this->theme, 'mail.'))) {
67+
$theme = $custom;
6868
} else {
6969
$theme = Str::contains($this->theme, '::')
7070
? $this->theme

tests/Mail/MailMarkdownTest.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function testRenderFunctionReturnsHtml()
2020
$markdown = new Markdown($viewFactory);
2121
$viewFactory->shouldReceive('flushFinderCache')->once();
2222
$viewFactory->shouldReceive('replaceNamespace')->once()->with('mail', $markdown->htmlComponentPaths())->andReturnSelf();
23-
$viewFactory->shouldReceive('exists')->with('default')->andReturn(false);
23+
$viewFactory->shouldReceive('exists')->with('mail.default')->andReturn(false);
2424
$viewFactory->shouldReceive('make')->with('view', [])->andReturnSelf();
2525
$viewFactory->shouldReceive('make')->with('mail::themes.default', [])->andReturnSelf();
2626
$viewFactory->shouldReceive('render')->twice()->andReturn('<html></html>', 'body {}');
@@ -37,9 +37,26 @@ public function testRenderFunctionReturnsHtmlWithCustomTheme()
3737
$markdown->theme('yaz');
3838
$viewFactory->shouldReceive('flushFinderCache')->once();
3939
$viewFactory->shouldReceive('replaceNamespace')->once()->with('mail', $markdown->htmlComponentPaths())->andReturnSelf();
40-
$viewFactory->shouldReceive('exists')->with('yaz')->andReturn(true);
40+
$viewFactory->shouldReceive('exists')->with('mail.yaz')->andReturn(true);
4141
$viewFactory->shouldReceive('make')->with('view', [])->andReturnSelf();
42-
$viewFactory->shouldReceive('make')->with('yaz', [])->andReturnSelf();
42+
$viewFactory->shouldReceive('make')->with('mail.yaz', [])->andReturnSelf();
43+
$viewFactory->shouldReceive('render')->twice()->andReturn('<html></html>', 'body {}');
44+
45+
$result = $markdown->render('view', []);
46+
47+
$this->assertNotFalse(strpos($result, '<html></html>'));
48+
}
49+
50+
public function testRenderFunctionReturnsHtmlWithCustomThemeWithMailPrefix()
51+
{
52+
$viewFactory = m::mock(Factory::class);
53+
$markdown = new Markdown($viewFactory);
54+
$markdown->theme('mail.yaz');
55+
$viewFactory->shouldReceive('flushFinderCache')->once();
56+
$viewFactory->shouldReceive('replaceNamespace')->once()->with('mail', $markdown->htmlComponentPaths())->andReturnSelf();
57+
$viewFactory->shouldReceive('exists')->with('mail.yaz')->andReturn(true);
58+
$viewFactory->shouldReceive('make')->with('view', [])->andReturnSelf();
59+
$viewFactory->shouldReceive('make')->with('mail.yaz', [])->andReturnSelf();
4360
$viewFactory->shouldReceive('render')->twice()->andReturn('<html></html>', 'body {}');
4461

4562
$result = $markdown->render('view', []);

0 commit comments

Comments
 (0)