diff --git a/Makefile b/Makefile index 8bcc4d7e..5cb5f42d 100644 --- a/Makefile +++ b/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: diff --git a/app/Console/Commands/CreateDatabase.php b/app/Console/Commands/CreateDatabase.php index ae3bfe0a..6046c286 100644 --- a/app/Console/Commands/CreateDatabase.php +++ b/app/Console/Commands/CreateDatabase.php @@ -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); diff --git a/tests/TestCase.php b/tests/TestCase.php index ab9125d4..fadbef34 100755 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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() {