diff --git a/tests/DatabaseFixtureTest.php b/tests/DatabaseFixtureTest.php index 4c7f70b..4fa6289 100644 --- a/tests/DatabaseFixtureTest.php +++ b/tests/DatabaseFixtureTest.php @@ -8,11 +8,38 @@ class DatabaseFixtureTest extends \Orchestra\Testbench\TestCase { public function setUp() { parent::setUp(); + + // uncomment to enable route filters if your package defines routes with filters + // $this->app['router']->enableFilters(); - $this->app['artisan']->call('migrate', array( - '--path' => '../../tests/migrations', + // create an artisan object for calling migrations + $artisan = $this->app->make('artisan'); + + // call migrations for packages upon which our package depends, e.g. Cartalyst/Sentry + // not necessary if your package doesn't depend on another package that requires + // running migrations for proper installation + /* uncomment as necessary + $artisan->call('migrate', [ '--database' => 'testbench', - )); + '--path' => '../vendor/cartalyst/sentry/src/migrations', + ]); + */ + + // call migrations that will be part of your package, assumes your migrations are in src/migrations + // not neccessary if your package doesn't require any migrations to be run for + // proper installation + /* uncomment as neccesary + $artisan->call('migrate', [ + '--database' => 'testbench', + '--path' => 'migrations', + ]); + */ + + // call migrations specific to our tests, e.g. to seed the db + $artisan->call('migrate', [ + '--database' => 'testbench', + '--path' => '../tests/migrations', + ]); } /** @@ -23,6 +50,9 @@ public function setUp() */ protected function getEnvironmentSetUp($app) { + // reset base path to point to our package's src directory + $app[ 'path.base' ] = __DIR__ . '/../src' ; + $app['config']->set('database.default', 'testbench'); $app['config']->set('database.connections.testbench', array( 'driver' => 'sqlite', @@ -31,6 +61,36 @@ protected function getEnvironmentSetUp($app) )); } + /** + * Get package providers. At a minimum this is the package being tested, but also + * would include packages upon which our package depends, e.g. Cartalyst/Sentry + * In a normal app environment these would be added to the 'providers' array in + * the config/app.php file. + * + * @return array + */ + protected function getPackageProviders() { + return [ + //'Cartalyst\Sentry\SentryServiceProvider', + //'YourProject\YourPackage\YourPackageServiceProvider', + ]; + } + + /** + * Get package aliases. In a normal app environment these would be added to + * the 'aliases' array in the config/app.php file. If your package exposes an + * aliased facade, you should add the alias here, along with aliases for + * facades upon which your package depends, e.g. Cartalyst/Sentry + * + * @return array + */ + protected function getPackageAliases() { + return [ + //'Sentry' => 'Cartalyst\Sentry\Facades\Laravel\Sentry', + //'YourPackage' => 'YourProject\YourPackage\Facades\YourPackage', + ]; + } + /** * Test running migration. *