Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[10.x] Fix custom themes not reseting on Markdown renderer" #46328

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Illuminate/Mail/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
48 changes: 0 additions & 48 deletions tests/Mail/MailMailableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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('<html></html>', '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;
Expand Down