Last active
October 13, 2015 12:25
-
-
Save mass6/5f6159c7785172574b84 to your computer and use it in GitHub Desktop.
Laravel 4.2 Trait for working with Behat
This file contains hidden or 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
<?php | |
use Illuminate\Foundation\Testing\ApplicationTrait; | |
use Illuminate\Foundation\Testing\AssertionsTrait; | |
use Illuminate\Support\Facades\Artisan; | |
trait LaravelTrait | |
{ | |
/** | |
* Responsible for providing a Laravel app instance. | |
*/ | |
use ApplicationTrait, AssertionsTrait, CrawlerTrait, PhpUnitAssertionsTrait; | |
/** | |
* The base URL to use while testing the application. | |
* | |
* @var string | |
*/ | |
protected $baseUrl = 'http://localhost'; | |
protected $phpUnit; | |
/** | |
* @BeforeScenario | |
*/ | |
public function setUp() | |
{ | |
if ( ! $this->app) { | |
$this->refreshApplication(); | |
} | |
// set the database connection to use for testing | |
$this->app->config->set('database.default', 'sqlite'); | |
} | |
/** | |
* @BeforeScenario | |
*/ | |
public function setupDatabase() | |
{ | |
$this->artisan('migrate'); | |
} | |
/** | |
* @AfterScenario | |
*/ | |
public function cleanDatabase() | |
{ | |
$this->artisan('migrate:reset'); | |
} | |
/** | |
* Creates the application. | |
* | |
* @return \Illuminate\Foundation\Application | |
*/ | |
public function createApplication() | |
{ | |
$app = require_once __DIR__.'/../bootstrap/start.php'; | |
$app->boot(); | |
return $app; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment