Skip to content

Commit

Permalink
Implements boot handling for traits
Browse files Browse the repository at this point in the history
  • Loading branch information
artstorm committed Jun 22, 2015
1 parent 647a819 commit 07d8ac4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 26 additions & 1 deletion api/tests/TestCase.php
Expand Up @@ -10,6 +10,32 @@ class TestCase extends Laravel\Lumen\Testing\TestCase
{
use AssertionTrait;

/**
* Setup the test environment.
*
* @return void
*/
public function setUp()
{
$this->bootTraits();

parent::setUp();
}

/**
* Allow traits to have custom initialization built in.
*
* @return void
*/
protected function bootTraits()
{
foreach (class_uses($this) as $trait) {
if (method_exists($this, 'boot'.$trait)) {
$this->{'boot'.$trait}();
}
}
}

/**
* Creates the application.
*
Expand All @@ -20,7 +46,6 @@ public function createApplication()
return require __DIR__.'/../bootstrap/app.php';
}


/**
* In Lumen 5.1.0, there is a bug in Laravel\Lumen\Testing\TestCase where
* Mockery::close() is called if Mockery exists, but the class has omitted
Expand Down
2 changes: 1 addition & 1 deletion api/tests/Traits/MailcatcherTrait.php
Expand Up @@ -13,7 +13,7 @@ trait MailcatcherTrait
*/
private $mailcatcher;

public function __construct()
public function bootMailcatcherTrait()
{
$this->mailcatcher = new Client([
'base_url' => 'http://'.getenv('MAIL_HOST').':1080'
Expand Down

0 comments on commit 07d8ac4

Please sign in to comment.