diff --git a/tests/Databases/MigrateDatabaseTest.php b/tests/Databases/MigrateDatabaseTest.php index d602987..f4018ea 100644 --- a/tests/Databases/MigrateDatabaseTest.php +++ b/tests/Databases/MigrateDatabaseTest.php @@ -72,7 +72,7 @@ protected function getPackageAliases($app) */ public function testRunningMigration() { - $users = \DB::table('users')->where('id', '=', 1)->first(); + $users = \DB::table('testbench_users')->where('id', '=', 1)->first(); $this->assertEquals('hello@orchestraplatform.com', $users->email); $this->assertTrue(\Hash::check('123', $users->password)); diff --git a/tests/Databases/MigrateWithRealpathAndLaravelTest.php b/tests/Databases/MigrateWithRealpathAndLaravelTest.php new file mode 100644 index 0000000..2f1117c --- /dev/null +++ b/tests/Databases/MigrateWithRealpathAndLaravelTest.php @@ -0,0 +1,96 @@ +loadMigrationsFrom([ + '--database' => 'testbench', + '--path' => '../vendor/cartalyst/sentry/src/migrations', + ]); + */ + + // 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->loadMigrationsFrom([ + '--database' => 'testing', + '--realpath' => realpath(__DIR__.'/../migrations'), + ]); + } + + /** + * Define environment setup. + * + * @param \Illuminate\Foundation\Application $app + * + * @return void + */ + protected function getEnvironmentSetUp($app) + { + $app['config']->set('database.default', 'testing'); + } + + /** + * 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. + * + * @param \Illuminate\Foundation\Application $app + * + * @return array + */ + protected function getPackageProviders($app) + { + return [ + \Orchestra\Database\ConsoleServiceProvider::class, + //'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. + * + * @param \Illuminate\Foundation\Application $app + * + * @return array + */ + protected function getPackageAliases($app) + { + return [ + //'Sentry' => 'Cartalyst\Sentry\Facades\Laravel\Sentry', + //'YourPackage' => 'YourProject\YourPackage\Facades\YourPackage', + ]; + } + + /** + * Test running migration. + * + * @test + */ + public function testRunningMigration() + { + $users = \DB::table('testbench_users')->where('id', '=', 1)->first(); + + $this->assertEquals('hello@orchestraplatform.com', $users->email); + $this->assertTrue(\Hash::check('123', $users->password)); + } +} diff --git a/tests/Databases/MigrateWithRealpathTest.php b/tests/Databases/MigrateWithRealpathTest.php index 8eb20de..a644ffa 100644 --- a/tests/Databases/MigrateWithRealpathTest.php +++ b/tests/Databases/MigrateWithRealpathTest.php @@ -88,7 +88,7 @@ protected function getPackageAliases($app) */ public function testRunningMigration() { - $users = \DB::table('users')->where('id', '=', 1)->first(); + $users = \DB::table('testbench_users')->where('id', '=', 1)->first(); $this->assertEquals('hello@orchestraplatform.com', $users->email); $this->assertTrue(\Hash::check('123', $users->password)); diff --git a/tests/migrations/2013_07_26_182750_create_testbench_users_table.php b/tests/migrations/2013_07_26_182750_create_testbench_users_table.php index fdb22f9..c79ffbf 100644 --- a/tests/migrations/2013_07_26_182750_create_testbench_users_table.php +++ b/tests/migrations/2013_07_26_182750_create_testbench_users_table.php @@ -12,7 +12,7 @@ class CreateTestbenchUsersTable extends Migration */ public function up() { - Schema::create('users', function ($table) { + Schema::create('testbench_users', function ($table) { $table->increments('id'); $table->string('email'); $table->string('password'); @@ -22,7 +22,7 @@ public function up() $now = Carbon::now(); - DB::table('users')->insert([ + DB::table('testbench_users')->insert([ 'email' => 'hello@orchestraplatform.com', 'password' => Hash::make('123'), 'created_at' => $now, @@ -37,6 +37,6 @@ public function up() */ public function down() { - Schema::drop('users'); + Schema::drop('testbench_users'); } }