Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add using mix of Laravel and custom realpath migration test to show t…
…hat it's can rollback perfectly. #176 Signed-off-by: crynobone <crynobone@gmail.com>
- Loading branch information
Showing
4 changed files
with
101 additions
and
5 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
namespace Orchestra\Testbench\Tests\Databases; | ||
|
||
use Orchestra\Testbench\TestCase; | ||
|
||
class MigrateWithRealpathAndLaravelTest extends TestCase | ||
{ | ||
/** | ||
* Setup the test environment. | ||
*/ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
// 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 | ||
$this->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)); | ||
} | ||
} |
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
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