From 0de40a65a7b4b1f07866e74a7f721cdcee220faf Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 19 Jan 2018 07:45:26 -0600 Subject: [PATCH] Revert "Simplify sqlite to use predefined connection "testing". (#22855)" (#22857) This reverts commit 2ae63504684f259dffe7835370f68a546459a7df. --- phpunit.xml.dist | 9 ++++----- tests/Integration/Auth/AuthenticationTest.php | 7 +++++++ tests/Integration/Database/DatabaseTestCase.php | 8 ++++++++ .../Integration/Database/EloquentDeleteTest.php | 8 ++++++++ .../Database/EloquentFactoryBuilderTest.php | 6 ++++++ .../Integration/Database/EloquentUpdateTest.php | 8 ++++++++ .../Concerns/InteractsWithAuthenticationTest.php | 7 +++++++ .../SendingMailNotificationsTest.php | 8 ++++++++ tests/Integration/Queue/JobChainingTest.php | 2 ++ .../Integration/Queue/ModelSerializationTest.php | 16 ++++++++++++---- 10 files changed, 70 insertions(+), 9 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 63af998f2c2e..d963e75d85d9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -27,10 +27,9 @@ - - + diff --git a/tests/Integration/Auth/AuthenticationTest.php b/tests/Integration/Auth/AuthenticationTest.php index 7dcb28f7dc11..475a8c5bb84e 100644 --- a/tests/Integration/Auth/AuthenticationTest.php +++ b/tests/Integration/Auth/AuthenticationTest.php @@ -18,6 +18,13 @@ protected function getEnvironmentSetUp($app) $app['config']->set('app.debug', 'true'); $app['config']->set('auth.providers.users.model', AuthenticationTestUser::class); + $app['config']->set('database.default', 'testbench'); + $app['config']->set('database.connections.testbench', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); + $app['config']->set('hashing', ['driver' => 'bcrypt']); } diff --git a/tests/Integration/Database/DatabaseTestCase.php b/tests/Integration/Database/DatabaseTestCase.php index 26fcfade5f0e..af8c9ff1ea7e 100644 --- a/tests/Integration/Database/DatabaseTestCase.php +++ b/tests/Integration/Database/DatabaseTestCase.php @@ -9,5 +9,13 @@ class DatabaseTestCase extends TestCase protected function getEnvironmentSetUp($app) { $app['config']->set('app.debug', 'true'); + + $app['config']->set('database.default', 'testbench'); + + $app['config']->set('database.connections.testbench', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); } } diff --git a/tests/Integration/Database/EloquentDeleteTest.php b/tests/Integration/Database/EloquentDeleteTest.php index d164aab09d64..1c21e082c582 100644 --- a/tests/Integration/Database/EloquentDeleteTest.php +++ b/tests/Integration/Database/EloquentDeleteTest.php @@ -14,6 +14,14 @@ class EloquentDeleteTest extends TestCase protected function getEnvironmentSetUp($app) { $app['config']->set('app.debug', 'true'); + + $app['config']->set('database.default', 'testbench'); + + $app['config']->set('database.connections.testbench', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); } public function setUp() diff --git a/tests/Integration/Database/EloquentFactoryBuilderTest.php b/tests/Integration/Database/EloquentFactoryBuilderTest.php index 2035add83c4a..3553b02d9436 100644 --- a/tests/Integration/Database/EloquentFactoryBuilderTest.php +++ b/tests/Integration/Database/EloquentFactoryBuilderTest.php @@ -17,6 +17,12 @@ protected function getEnvironmentSetUp($app) { $app['config']->set('app.debug', 'true'); + $app['config']->set('database.default', 'testbench'); + $app['config']->set('database.connections.testbench', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); $app['config']->set('database.connections.alternative-connection', [ 'driver' => 'sqlite', 'database' => ':memory:', diff --git a/tests/Integration/Database/EloquentUpdateTest.php b/tests/Integration/Database/EloquentUpdateTest.php index dc7d95a31a2e..dcb0c56c7c60 100644 --- a/tests/Integration/Database/EloquentUpdateTest.php +++ b/tests/Integration/Database/EloquentUpdateTest.php @@ -15,6 +15,14 @@ class EloquentUpdateTest extends TestCase protected function getEnvironmentSetUp($app) { $app['config']->set('app.debug', 'true'); + + $app['config']->set('database.default', 'testbench'); + + $app['config']->set('database.connections.testbench', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); } public function setUp() diff --git a/tests/Integration/Foundation/Testing/Concerns/InteractsWithAuthenticationTest.php b/tests/Integration/Foundation/Testing/Concerns/InteractsWithAuthenticationTest.php index 9e78594bdf54..9bcb15897a4b 100644 --- a/tests/Integration/Foundation/Testing/Concerns/InteractsWithAuthenticationTest.php +++ b/tests/Integration/Foundation/Testing/Concerns/InteractsWithAuthenticationTest.php @@ -14,6 +14,13 @@ class InteractsWithAuthenticationTest extends TestCase protected function getEnvironmentSetUp($app) { $app['config']->set('auth.providers.users.model', AuthenticationTestUser::class); + + $app['config']->set('database.default', 'testbench'); + $app['config']->set('database.connections.testbench', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); } public function setUp() diff --git a/tests/Integration/Notifications/SendingMailNotificationsTest.php b/tests/Integration/Notifications/SendingMailNotificationsTest.php index 1edfaf1a3108..5f1285401457 100644 --- a/tests/Integration/Notifications/SendingMailNotificationsTest.php +++ b/tests/Integration/Notifications/SendingMailNotificationsTest.php @@ -32,6 +32,14 @@ protected function getEnvironmentSetUp($app) { $app['config']->set('app.debug', 'true'); + $app['config']->set('database.default', 'testbench'); + + $app['config']->set('database.connections.testbench', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); + $this->mailer = Mockery::mock(Mailer::class); $this->markdown = Mockery::mock(Markdown::class); diff --git a/tests/Integration/Queue/JobChainingTest.php b/tests/Integration/Queue/JobChainingTest.php index d30f4ceb6ee1..4d2c369e061d 100644 --- a/tests/Integration/Queue/JobChainingTest.php +++ b/tests/Integration/Queue/JobChainingTest.php @@ -18,6 +18,8 @@ protected function getEnvironmentSetUp($app) { $app['config']->set('app.debug', 'true'); + $app['config']->set('database.default', 'testbench'); + $app['config']->set('queue.connections.sync1', [ 'driver' => 'sync', ]); diff --git a/tests/Integration/Queue/ModelSerializationTest.php b/tests/Integration/Queue/ModelSerializationTest.php index c2f087e29c20..4d6adfe1d03d 100644 --- a/tests/Integration/Queue/ModelSerializationTest.php +++ b/tests/Integration/Queue/ModelSerializationTest.php @@ -15,6 +15,14 @@ protected function getEnvironmentSetUp($app) { $app['config']->set('app.debug', 'true'); + $app['config']->set('database.default', 'testbench'); + + $app['config']->set('database.connections.testbench', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); + $app['config']->set('database.connections.custom', [ 'driver' => 'sqlite', 'database' => ':memory:', @@ -68,16 +76,16 @@ public function it_serialize_user_on_default_connection() $unSerialized = unserialize($serialized); - $this->assertEquals('testing', $unSerialized->user->getConnectionName()); + $this->assertEquals('testbench', $unSerialized->user->getConnectionName()); $this->assertEquals('mohamed@laravel.com', $unSerialized->user->email); - $serialized = serialize(new ModelSerializationTestClass(ModelSerializationTestUser::on('testing')->get())); + $serialized = serialize(new ModelSerializationTestClass(ModelSerializationTestUser::on('testbench')->get())); $unSerialized = unserialize($serialized); - $this->assertEquals('testing', $unSerialized->user[0]->getConnectionName()); + $this->assertEquals('testbench', $unSerialized->user[0]->getConnectionName()); $this->assertEquals('mohamed@laravel.com', $unSerialized->user[0]->email); - $this->assertEquals('testing', $unSerialized->user[1]->getConnectionName()); + $this->assertEquals('testbench', $unSerialized->user[1]->getConnectionName()); $this->assertEquals('taylor@laravel.com', $unSerialized->user[1]->email); }