-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace mail driver with listener. (#17)
- Loading branch information
Showing
11 changed files
with
54 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,17 @@ | ||
<?php | ||
|
||
namespace Jstoone\Mailman\Tests\Mailer; | ||
namespace Jstoone\Mailman\Tests; | ||
|
||
use Illuminate\Contracts\Filesystem\Filesystem; | ||
use Illuminate\View\View; | ||
use Jstoone\Mailman\GenerateMailIdentifier; | ||
use Jstoone\Mailman\Mailer\MailmanTransport; | ||
use Jstoone\Mailman\Tests\TestCase; | ||
use Swift_Message; | ||
|
||
class MailmanTransportTest extends TestCase | ||
class DeliverToInboxTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_creates_a_directory_for_storing_emails() | ||
{ | ||
$message = new Swift_Message('Mail Subject', 'Mail Body'); | ||
$message->setTo('[email protected]'); | ||
|
||
$transport = $this->app->make(MailmanTransport::class); | ||
|
||
$transport->send($message); | ||
$this->sendMail('Mail Subject', '[email protected]'); | ||
|
||
$this->assertTrue( | ||
app(Filesystem::class)->exists('mailman') | ||
|
@@ -33,7 +25,7 @@ public function it_stores_emails_as_blade_views() | |
return 'unique-identifier'; | ||
}); | ||
|
||
$message = $this->sendMail('Mail Subject', '[email protected]'); | ||
$this->sendMail('Mail Subject', '[email protected]'); | ||
|
||
$view = view('nova-mailman-mails::unique-identifier'); | ||
$this->assertInstanceOf(View::class, $view); | ||
|
@@ -47,13 +39,13 @@ public function it_stores_email_metadata_in_a_json_file() | |
return 'unique-identifier'; | ||
}); | ||
|
||
$message = $this->sendMail('Mail Subject', '[email protected]'); | ||
$this->sendMail('Mail Subject', '[email protected]'); | ||
$file = app(Filesystem::class)->get('mailman/unique-identifier.json'); | ||
|
||
$this->assertEquals( | ||
[ | ||
'id' => 'unique-identifier', | ||
'subject' => $message->getSubject(), | ||
'subject' => 'Mail Subject', | ||
'recipient' => '[email protected]', | ||
'sent_at' => time(), | ||
'link' => route('nova-mailman.show', 'unique-identifier'), | ||
|
7 changes: 3 additions & 4 deletions
7
tests/Mailer/MailIdentifierTest.php → tests/MailIdentifierTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,26 +3,12 @@ | |
namespace Jstoone\Mailman\Tests; | ||
|
||
use Illuminate\Contracts\Filesystem\Filesystem; | ||
use Jstoone\Mailman\Mailer\MailmanTransport; | ||
use Illuminate\Support\Facades\Mail; | ||
use Jstoone\Mailman\MailmanServiceProvider; | ||
use Orchestra\Testbench\TestCase as Orchestra; | ||
use Swift_Message; | ||
|
||
abstract class TestCase extends Orchestra | ||
{ | ||
/** @var string */ | ||
public static $mailDriver = 'mailman'; | ||
|
||
/** @var MailmanTransport */ | ||
private $transport; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->transport = $this->app->make(MailmanTransport::class); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
app(Filesystem::class)->deleteDirectory('mailman'); | ||
|
@@ -33,28 +19,28 @@ public function tearDown() | |
protected function getEnvironmentSetUp($app) | ||
{ | ||
$app['router']->middlewareGroup('nova', []); | ||
} | ||
|
||
protected function getPackageProviders($app) | ||
{ | ||
$app['config']->set('mail.driver', self::$mailDriver); | ||
$app['config']->set('mail.driver', 'array'); | ||
|
||
$app['config']->set('filesystems.disks.local', [ | ||
'driver' => 'local', | ||
'root' => __DIR__ . '/temp', | ||
]); | ||
} | ||
|
||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
MailmanServiceProvider::class, | ||
]; | ||
} | ||
|
||
protected function sendMail(string $subject, string $recipient): Swift_Message | ||
protected function sendMail(string $subject, string $recipient): void | ||
{ | ||
$message = new Swift_Message($subject, 'Mail Body'); | ||
$message->setTo($recipient); | ||
|
||
$this->transport->send($message); | ||
|
||
return $message; | ||
Mail::raw('Mail Body', function ($message) use ($subject, $recipient) { | ||
$message->from('[email protected]') | ||
->to($recipient) | ||
->subject($subject); | ||
}); | ||
} | ||
} |