From 463c566edafe19abb9a985720b8bd6329b2f93ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Fri, 4 Oct 2019 19:54:24 +0200 Subject: [PATCH] Create command test --- .travis.yml | 2 +- fulltest | 7 +++++++ src/TenancyServiceProvider.php | 1 + test | 3 --- tests/CommandsTest.php | 12 ++++++++++++ 5 files changed, 21 insertions(+), 4 deletions(-) create mode 100755 fulltest diff --git a/.travis.yml b/.travis.yml index b55100c8..87f9f300 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ before_script: - export DB_USERNAME=root DB_PASSWORD="" DB_DATABASE=tenancy CODECOV_TOKEN="24382d15-84e7-4a55-bea4-c4df96a24a9b" - cat vendor/laravel/framework/src/Illuminate/Foundation/Application.php| grep 'const VERSION' -script: ./test +script: ./fulltest after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/fulltest b/fulltest new file mode 100755 index 00000000..0c526f4e --- /dev/null +++ b/fulltest @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +# for development +docker-compose up -d +./test "$@" +docker-compose exec test vendor/bin/phpcov merge --clover clover.xml coverage/ diff --git a/src/TenancyServiceProvider.php b/src/TenancyServiceProvider.php index 8329acb0..7f8e86ad 100644 --- a/src/TenancyServiceProvider.php +++ b/src/TenancyServiceProvider.php @@ -65,6 +65,7 @@ class TenancyServiceProvider extends ServiceProvider Commands\Migrate::class, Commands\Rollback::class, Commands\TenantList::class, + Commands\CreateTenant::class, Commands\MigrateFresh::class, ]); diff --git a/test b/test index 780da956..3f8244b3 100755 --- a/test +++ b/test @@ -1,10 +1,7 @@ #!/bin/bash set -e -# for development -docker-compose up -d printf "Variant 1\n\n" docker-compose exec test env TENANCY_TEST_STORAGE_DRIVER=db vendor/bin/phpunit --coverage-php coverage/2.cov "$@" printf "Variant 2\n\n" docker-compose exec test env TENANCY_TEST_STORAGE_DRIVER=redis vendor/bin/phpunit --coverage-php coverage/1.cov "$@" -docker-compose exec test vendor/bin/phpcov merge --clover clover.xml coverage/ diff --git a/tests/CommandsTest.php b/tests/CommandsTest.php index 1fdf9801..4cf8a92c 100644 --- a/tests/CommandsTest.php +++ b/tests/CommandsTest.php @@ -156,4 +156,16 @@ class CommandsTest extends TestCase Artisan::call('tenants:migrate-fresh'); $this->assertFalse(DB::table('users')->exists()); } + + /** @test */ + public function create_command_works() + { + Artisan::call('tenants:create -d aaa.localhost -d bbb.localhost plan=free email=foo@test.local'); + $tenant = tenancy()->all()[1]; // a tenant is autocreated prior to this + $data = $tenant->data; + unset($data['id']); + + $this->assertSame(['plan' => 'free', 'email' => 'foo@test.local'], $data); + $this->assertSame(['aaa.localhost', 'bbb.localhost'], $tenant->domains); + } }