Last active
April 8, 2018 01:51
-
-
Save bgallagh3r/dc39f8bb18c380214919 to your computer and use it in GitHub Desktop.
Behat FeatureContext Bootstrap for use in Laravel.
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
<?php | |
// Put this inside of your featurecontext class | |
// This assumes the FeatureContext.php class is within app/tests/behat/features/bootstrap | |
// Another thing to note... I'm using sqlite in memory for these tests, | |
// so I'm not worried about the db at the end of the run, just the install and start. | |
class FeatureContext extends BehatContext //or MinkContext if using Mink | |
{ | |
/** | |
* Laravel app instance | |
* | |
* @var \Illuminate\Foundation\Application | |
*/ | |
protected static $laravel; | |
/** | |
* @static | |
* @beforeSuite | |
*/ | |
public static function bootstrapLaravel() | |
{ | |
// Bootstrap Laravel | |
self::$laravel = require __DIR__ . '/../../../../bootstrap/start.php'; | |
self::$laravel['mail']->pretend(true); | |
} | |
/** | |
* @static | |
* @beforeSuite | |
*/ | |
public static function setUpDb() | |
{ | |
self::$laravel['artisan']->call('migrate:install'); | |
} | |
/** | |
* @static | |
* @beforeFeature | |
*/ | |
public static function prepDb() | |
{ | |
self::$laravel['artisan']->call('migrate:refresh'); | |
self::$laravel['artisan']->call('db:seed'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment