travis - cleanup database creation/migration for tests

This commit is contained in:
Nabeel Shahzad 2017-07-13 15:43:56 -05:00
parent de91b133e7
commit c40cd3da53
3 changed files with 11 additions and 10 deletions

View File

@ -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:

View File

@ -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);

View File

@ -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() {