From bb6962e317a2cb85f198c66930168018651e5e26 Mon Sep 17 00:00:00 2001 From: Martien Dermawan Tanama Date: Tue, 5 Jun 2018 23:07:55 +0700 Subject: [PATCH 1/6] update circle ci setup --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5be1a2a9a..5d2494cf4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -85,6 +85,10 @@ jobs: name: Create SQLite Database command: touch database/database.sqlite + - run: + name: Create SQLite Tenant Database + command: touch database/databaseTenant.sqlite + - run: name: Migrate Laravel Database command: php artisan migrate From 9b9dea6d8ae95dc1f5b154aed46a5324dd041734 Mon Sep 17 00:00:00 2001 From: Martien Dermawan Tanama Date: Tue, 5 Jun 2018 16:08:08 +0000 Subject: [PATCH 2/6] Apply fixes from StyleCI [ci skip] [skip ci] --- app/Console/Commands/SetupTenantDatabase.php | 1 - tests/CreatesApplication.php | 2 +- tests/Feature/Master/UserRESTTest.php | 6 ++---- tests/TestCase.php | 6 +++--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/Console/Commands/SetupTenantDatabase.php b/app/Console/Commands/SetupTenantDatabase.php index 769a65488..f9596083b 100644 --- a/app/Console/Commands/SetupTenantDatabase.php +++ b/app/Console/Commands/SetupTenantDatabase.php @@ -3,7 +3,6 @@ namespace App\Console\Commands; use Illuminate\Console\Command; -use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Artisan; class SetupTenantDatabase extends Command diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index 60a3e8ca2..ff133fb4d 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -2,8 +2,8 @@ namespace Tests; -use Illuminate\Contracts\Console\Kernel; use Illuminate\Support\Facades\Hash; +use Illuminate\Contracts\Console\Kernel; trait CreatesApplication { diff --git a/tests/Feature/Master/UserRESTTest.php b/tests/Feature/Master/UserRESTTest.php index 7e755e34f..17a643620 100644 --- a/tests/Feature/Master/UserRESTTest.php +++ b/tests/Feature/Master/UserRESTTest.php @@ -3,8 +3,6 @@ namespace Tests\Feature\Master; use App\User; -use Illuminate\Database\ConnectionResolver; -use Illuminate\Support\Facades\Artisan; use Tests\TestCase; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -64,7 +62,7 @@ public function an_user_can_read_all_user() $response->assertStatus(200); } - /** @test */ + /* @test */ // public function an_user_can_update_user() // { // $data = [ @@ -82,7 +80,7 @@ public function an_user_can_read_all_user() // $response->assertStatus(200); // } - /** @test */ + /* @test */ // public function an_user_can_delete_user() // { // $response = $this->json('DELETE', 'api/v1/master/users/'.$this->user->id, [], [$this->headers]); diff --git a/tests/TestCase.php b/tests/TestCase.php index ced634606..f2fdbeaf7 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -3,8 +3,8 @@ namespace Tests; use App\User; -use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Artisan; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase @@ -26,12 +26,12 @@ public function setUp() $this->getConnection(DB::getDefaultConnection())->disconnect(); $this->artisan('tenant:setup-database', [ - 'tenant_subdomain' => 'database/databaseTenant.sqlite' + 'tenant_subdomain' => 'database/databaseTenant.sqlite', ]); $this->headers = [ 'Accept' => 'application/json', - 'Content-Type' => 'application/json' + 'Content-Type' => 'application/json', ]; } From 071e7407c5c6a623fa5c864e10e88b970d106fa7 Mon Sep 17 00:00:00 2001 From: Martien Dermawan Tanama Date: Tue, 5 Jun 2018 23:17:33 +0700 Subject: [PATCH 3/6] update coveralls path --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5d2494cf4..e90be623b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -117,4 +117,4 @@ jobs: - run: name: Sending code coverage - command: php vendor/bin/coveralls + command: php vendor/bin/php-coveralls From 30e8682c54190c79c5dc7511e4393aa0d252b0a8 Mon Sep 17 00:00:00 2001 From: Martien Dermawan Tanama Date: Tue, 5 Jun 2018 23:27:28 +0700 Subject: [PATCH 4/6] laravel 5.6 min required php 7.1.3 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1fae686bf..0b650a892 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: php php: - - 7.1 + - 7.1.3 before_script: - cp .env.example .env From d4745250f3083e40e8b32df58b01cef9e04b1e0a Mon Sep 17 00:00:00 2001 From: Martien Dermawan Tanama Date: Tue, 5 Jun 2018 23:39:26 +0700 Subject: [PATCH 5/6] update travis setup for support multi tenant multi database --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0b650a892..99389b0cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,8 @@ before_script: - composer self-update - composer install --no-interaction - mysql -e 'create database testing;' + - mysql -e 'create database testing_tenant;' - php artisan key:generate - - php artisan migrate - - php artisan db:seed --class="DatabaseSeeder" script: - vendor/bin/phpunit From 7d214f7a783d6554e36d247d8e9be2c1a9b9816c Mon Sep 17 00:00:00 2001 From: Martien Dermawan Tanama Date: Tue, 5 Jun 2018 23:46:33 +0700 Subject: [PATCH 6/6] update test case get db from environment --- tests/TestCase.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index f2fdbeaf7..6cb8662dd 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -20,13 +20,13 @@ public function setUp() Artisan::call('config:clear'); - config()->set('database.connections.tenant.driver', 'sqlite'); - config()->set('database.connections.tenant.database', 'database/databaseTenant.sqlite'); + config()->set('database.connections.tenant.driver', env('DB_TENANT_DRIVER')); + config()->set('database.connections.tenant.database', env('DB_TENANT_DATABASE')); $this->getConnection(DB::getDefaultConnection())->disconnect(); $this->artisan('tenant:setup-database', [ - 'tenant_subdomain' => 'database/databaseTenant.sqlite', + 'tenant_subdomain' => env('DB_TENANT_DATABASE'), ]); $this->headers = [