Skip to content
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
3 changes: 3 additions & 0 deletions src/Illuminate/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Support\Arr;
use InvalidArgumentException;
use Illuminate\Contracts\View\Factory;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Queue\ShouldQueue;
Expand All @@ -16,6 +17,8 @@

class Mailer implements MailerContract, MailQueueContract
{
use Macroable;

/**
* The view factory instance.
*
Expand Down
16 changes: 15 additions & 1 deletion tests/Mail/MailMailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Tests\Mail;

use Mockery as m;
use Illuminate\Mail\Mailer;
use PHPUnit\Framework\TestCase;
use Illuminate\Support\HtmlString;

Expand Down Expand Up @@ -148,9 +149,22 @@ public function testEventsAreDispatched()
});
}

public function testMacroable()
{
Mailer::macro('foo', function () {
return 'bar';
});

$mailer = $this->getMailer();

$this->assertEquals(
'bar', $mailer->foo()
);
}

protected function getMailer($events = null)
{
return new \Illuminate\Mail\Mailer(m::mock('Illuminate\Contracts\View\Factory'), m::mock('Swift_Mailer'), $events);
return new Mailer(m::mock('Illuminate\Contracts\View\Factory'), m::mock('Swift_Mailer'), $events);
}

public function setSwiftMailer($mailer)
Expand Down