Skip to content

Commit

Permalink
Update setup for migration.
Browse files Browse the repository at this point in the history
Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed Aug 17, 2016
1 parent ca41540 commit a9c6192
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 101 deletions.
13 changes: 7 additions & 6 deletions src/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,19 @@ public function tearDown()
/**
* Define hooks to migrate the database before and after each test.
*
* @param string $realpah
* @param string|array $realpah
*
* @return void
*/
protected function loadMigrationsFrom($realpath)
{
$this->artisan('migrate', [
'--realpath' => $realpath,
]);
$options = is_array($realpath) ? $realpath : ['--realpath' => $realpath];
$database = isset($options['--database']) ? $options['--database'] : null;

$this->beforeApplicationDestroyed(function () {
$this->artisan('migrate:rollback');
$this->artisan('migrate', $options);

$this->beforeApplicationDestroyed(function () use ($database) {
$this->artisan('migrate:rollback', ['--database' => $database]);
});
}

Expand Down
4 changes: 2 additions & 2 deletions tests/DatabaseFixtureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function setUp()
// not necessary if your package doesn't depend on another package that requires
// running migrations for proper installation
/* uncomment as necessary
$this->artisan('migrate', [
$this->loadMigrationsFrom([
'--database' => 'testbench',
'--path' => '../vendor/cartalyst/sentry/src/migrations',
]);
Expand All @@ -25,7 +25,7 @@ public function setUp()
// call migrations specific to our tests, e.g. to seed the db
// the path option should be relative to the 'path.database'
// path unless `--path` option is available.
$this->artisan('migrate', [
$this->loadMigrationsFrom([
'--database' => 'testing',
'--realpath' => realpath(__DIR__.'/migrations'),
]);
Expand Down
93 changes: 0 additions & 93 deletions tests/DatabaseLoadMigrationTest.php

This file was deleted.

0 comments on commit a9c6192

Please sign in to comment.