travis - cleanup database creation/migration for tests
This commit is contained in:
parent
de91b133e7
commit
c40cd3da53
4
Makefile
4
Makefile
@ -47,8 +47,8 @@ tests: test
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
php artisan database:create --reset
|
||||
vendor/bin/phpunit --debug --verbose --testdox tests
|
||||
#php artisan database:create --reset
|
||||
vendor/bin/phpunit --debug --verbose
|
||||
|
||||
.PHONY: schema
|
||||
schema:
|
||||
|
@ -3,20 +3,16 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
|
||||
|
||||
class CreateDatabase extends Command
|
||||
{
|
||||
protected $signature = 'database:create {--reset}';
|
||||
protected $signature = 'database:create {--reset} {--conn=?}';
|
||||
protected $description = 'Create a database';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@ -94,7 +90,8 @@ class CreateDatabase extends Command
|
||||
{
|
||||
$this->info('Using connection "'.config('database.default').'"');
|
||||
|
||||
$dbkey = 'database.connections.' . config('database.default').'.';
|
||||
$conn = config('database.default');
|
||||
$dbkey = 'database.connections.'.$conn.'.';
|
||||
|
||||
if(config($dbkey.'driver') === 'mysql') {
|
||||
$this->create_mysql($dbkey);
|
||||
|
@ -3,6 +3,9 @@
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
|
||||
|
||||
abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
{
|
||||
@ -20,7 +23,8 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
}
|
||||
|
||||
protected function reset_db() {
|
||||
exec('make -f '.__DIR__.'/../Makefile unittest-db');
|
||||
Artisan::call('database:create', ['--reset' => true]);
|
||||
Artisan::call('migrate:refresh', ['--env' => 'unittest']);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
|
Loading…
Reference in New Issue
Block a user