Skip to content

Commit

Permalink
Simplify sqlite to use predefined connection "testing". (#22855)
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone authored and taylorotwell committed Jan 19, 2018
1 parent 0ce094a commit 2ae6350
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 70 deletions.
9 changes: 5 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
</whitelist>
</filter>
<php>
<!--
<env name="REDIS_HOST" value="127.0.0.1" />
<env name="REDIS_PORT" value="6379" />
-->
<env name="DB_CONNECTION" value="testing" />
<!--
<env name="REDIS_HOST" value="127.0.0.1" />
<env name="REDIS_PORT" value="6379" />
-->
</php>
</phpunit>
7 changes: 0 additions & 7 deletions tests/Integration/Auth/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ 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']);
}

Expand Down
8 changes: 0 additions & 8 deletions tests/Integration/Database/DatabaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,5 @@ 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' => '',
]);
}
}
8 changes: 0 additions & 8 deletions tests/Integration/Database/EloquentDeleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ 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()
Expand Down
6 changes: 0 additions & 6 deletions tests/Integration/Database/EloquentFactoryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ 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:',
Expand Down
8 changes: 0 additions & 8 deletions tests/Integration/Database/EloquentUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ 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);

Expand Down
2 changes: 0 additions & 2 deletions tests/Integration/Queue/JobChainingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ protected function getEnvironmentSetUp($app)
{
$app['config']->set('app.debug', 'true');

$app['config']->set('database.default', 'testbench');

$app['config']->set('queue.connections.sync1', [
'driver' => 'sync',
]);
Expand Down
16 changes: 4 additions & 12 deletions tests/Integration/Queue/ModelSerializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ 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:',
Expand Down Expand Up @@ -76,16 +68,16 @@ public function it_serialize_user_on_default_connection()

$unSerialized = unserialize($serialized);

$this->assertEquals('testbench', $unSerialized->user->getConnectionName());
$this->assertEquals('testing', $unSerialized->user->getConnectionName());
$this->assertEquals('mohamed@laravel.com', $unSerialized->user->email);

$serialized = serialize(new ModelSerializationTestClass(ModelSerializationTestUser::on('testbench')->get()));
$serialized = serialize(new ModelSerializationTestClass(ModelSerializationTestUser::on('testing')->get()));

$unSerialized = unserialize($serialized);

$this->assertEquals('testbench', $unSerialized->user[0]->getConnectionName());
$this->assertEquals('testing', $unSerialized->user[0]->getConnectionName());
$this->assertEquals('mohamed@laravel.com', $unSerialized->user[0]->email);
$this->assertEquals('testbench', $unSerialized->user[1]->getConnectionName());
$this->assertEquals('testing', $unSerialized->user[1]->getConnectionName());
$this->assertEquals('taylor@laravel.com', $unSerialized->user[1]->email);
}

Expand Down

0 comments on commit 2ae6350

Please sign in to comment.