From 7f0b2e1cd1863cfb8b9d1e1014d81970bba2f704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Thu, 7 Feb 2019 17:53:21 +0100 Subject: [PATCH] Minor tweaks --- .env.example | 1 + .travis.yml | 10 ++++++---- composer.json | 5 ----- phpunit.xml | 1 - tests/DatabaseCreationTest.php | 5 +---- tests/TestCase.php | 5 ++++- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.env.example b/.env.example index f032cc7f..55e2e43d 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ +# DB_DATABASE=travis_tenancy # DB_USERNAME=foo # DB_PASSWORD=bar \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 6771e6a8..ac3172f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,9 @@ +env: + - DB_USERNAME=root + - DB_PASSWORD=root + - DB_DATABASE=travis_tenancy + - CODECOV_TOKEN="24382d15-84e7-4a55-bea4-c4df96a24a9b" + language: php php: - '7.2' @@ -18,13 +24,9 @@ install: - travis_retry composer install --no-interaction before_script: - - export DB_USERNAME=root - - export DB_PASSWORD=root - mysql -e 'CREATE DATABASE travis_tenancy;' - - export DB_DATABASE=travis_tenancy script: vendor/bin/phpunit -v --coverage-clover=coverage.xml after_success: - - export CODECOV_TOKEN="24382d15-84e7-4a55-bea4-c4df96a24a9b" - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/composer.json b/composer.json index b045ba4d..ca99db8e 100644 --- a/composer.json +++ b/composer.json @@ -37,10 +37,5 @@ "Stancl\\Tenancy\\TenancyServiceProvider" ] } - }, - "scripts": { - "post-root-package-install": [ - "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" - ] } } diff --git a/phpunit.xml b/phpunit.xml index da25c19f..75cb7545 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -29,6 +29,5 @@ - \ No newline at end of file diff --git a/tests/DatabaseCreationTest.php b/tests/DatabaseCreationTest.php index 5f3e47f3..9b1428d0 100644 --- a/tests/DatabaseCreationTest.php +++ b/tests/DatabaseCreationTest.php @@ -24,10 +24,7 @@ class DatabaseCreationTest extends TestCase $this->markTestSkipped('As to not bloat your MySQL instance with test databases, this test is not run by default.'); } - config()->set([ - 'database.default' => 'mysql', - 'database.connections.mysql.database' => 'travis_tenancy', - ]); + config()->set('database.default', 'mysql'); $db_name = 'testdatabase' . $this->randomString(10); app(DatabaseManager::class)->create($db_name, 'mysql'); diff --git a/tests/TestCase.php b/tests/TestCase.php index ad613118..2ec26ba1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -30,7 +30,9 @@ class TestCase extends \Orchestra\Testbench\TestCase */ protected function getEnvironmentSetUp($app) { - (new \Dotenv\Dotenv(__DIR__ . '/..'))->load(); + if (file_exists(__DIR__ . '/../.env')) { + (new \Dotenv\Dotenv(__DIR__ . '/..'))->load(); + } $app['config']->set([ 'database.redis.client' => 'phpredis', @@ -47,6 +49,7 @@ class TestCase extends \Orchestra\Testbench\TestCase 'prefix' => 'tenant', 'suffix' => '.sqlite', ], + 'database.connections.sqlite.database' => ':memory:', ]); }