diff --git a/tests/TestCase.php b/tests/TestCase.php index 0efd94e..acb3d31 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,13 +2,26 @@ namespace IWasHereFirst2\LaravelMultiMail\Tests; +use IWasHereFirst2\LaravelMultiMail\Facades\MultiMail; + use IWasHereFirst2\LaravelMultiMail\MultiMailServiceProvider; +use Swift_Events_EventListener; +use Swift_Message; class TestCase extends \Orchestra\Testbench\TestCase { + protected $emails; + public function setUp(): void { parent::setUp(); + + MultiMail::registerPlugin(new TestingMailEventListener($this)); + } + + public function addEmail(Swift_Message $email) + { + $this->emails[] = $email; } /** @@ -40,3 +53,18 @@ protected function getEnvironmentSetUp($app) ]); } } + +class TestingMailEventListener implements Swift_Events_EventListener +{ + protected $test; + + public function __construct($test) + { + $this->test = $test; + } + + public function beforeSendPerformed($event) + { + $this->test->addEmail($event->getMessage()); + } +} diff --git a/tests/Unit/MultiMailTest.php b/tests/Unit/MultiMailTest.php index 41784ec..34d13ff 100644 --- a/tests/Unit/MultiMailTest.php +++ b/tests/Unit/MultiMailTest.php @@ -6,22 +6,11 @@ use Illuminate\Support\Facades\View; use IWasHereFirst2\LaravelMultiMail\Facades\MultiMail; use IWasHereFirst2\LaravelMultiMail\Tests\TestCase; -use Swift_Events_EventListener; -use Swift_Message; class MultiMailTest extends TestCase { const FROM = 'test@fake.de'; - protected $emails; - - public function setUp(): void - { - parent::setUp(); - - MultiMail::registerPlugin(new TestingMailEventListener($this)); - } - /** @test */ public function check_if_mail_is_sendable() { @@ -62,11 +51,6 @@ protected function getEnvironmentSetUp($app) View::addLocation(__DIR__ . '/Fixtures'); } - - public function addEmail(Swift_Message $email) - { - $this->emails[] = $email; - } } class TestMail extends Mailable @@ -81,18 +65,3 @@ public function build() return $this->view('view'); } } - -class TestingMailEventListener implements Swift_Events_EventListener -{ - protected $test; - - public function __construct($test) - { - $this->test = $test; - } - - public function beforeSendPerformed($event) - { - $this->test->addEmail($event->getMessage()); - } -}