Skip to content

Commit

Permalink
Added trait constructor to mailcatchertrait to handle booting the tra…
Browse files Browse the repository at this point in the history
…it. Added more comments
  • Loading branch information
zakhenry committed Jun 22, 2015
1 parent 8b782cc commit 622e858
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 0 additions & 3 deletions api/tests/EmailTest.php
Expand Up @@ -10,8 +10,6 @@ class EmailTest extends TestCase
public function setUp()
{
parent::setUp();

$this->setUpMailcatcherTrait(); //@todo find a way to construct mailcatcher trait when used
}

/**
Expand All @@ -20,7 +18,6 @@ public function setUp()
public function testSendEmail()
{


$subject = 'Test Email';

$responseCode = Mail::send('emails.welcome', [], function($message) use ($subject)
Expand Down
14 changes: 12 additions & 2 deletions api/tests/Traits/MailcatcherTrait.php
Expand Up @@ -13,7 +13,7 @@ trait MailcatcherTrait
*/
private $mailcatcher;

public function setUpMailcatcherTrait()
public function __construct()
{
$this->mailcatcher = new Client([
'base_url' => 'http://'.getenv('MAIL_HOST').':1080'
Expand All @@ -22,12 +22,18 @@ public function setUpMailcatcherTrait()
$this->clearMessages();
}

// api calls
/**
* Empty the inbox
*/
public function clearMessages()
{
$this->mailcatcher->delete('/messages');
}

/**
* Get the latest email
* @return mixed
*/
public function getLastMessage()
{
$messages = $this->getMessages();
Expand All @@ -38,6 +44,10 @@ public function getLastMessage()
return reset($messages);
}

/**
* Get all emails
* @return mixed
*/
public function getMessages()
{
$jsonResponse = $this->mailcatcher->get('/messages');
Expand Down

0 comments on commit 622e858

Please sign in to comment.