Skip to content

Commit

Permalink
Merge branch 'fix/markdown-mailable' into 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 21, 2021
2 parents 2121759 + 461c448 commit 96effe8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Mail/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -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($customTheme = Str::start($this->theme, 'mail.'))) {
$theme = $customTheme;
} else {
$theme = Str::contains($this->theme, '::')
? $this->theme
Expand Down
23 changes: 20 additions & 3 deletions tests/Mail/MailMarkdownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<html></html>', 'body {}');
Expand All @@ -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('<html></html>', 'body {}');

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

$this->assertNotFalse(strpos($result, '<html></html>'));
}

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('<html></html>', 'body {}');

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

0 comments on commit 96effe8

Please sign in to comment.