From edeab5e75ffa02b075c151ca03ea1038f61e4396 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 16 Sep 2018 00:58:25 +0200 Subject: Added Database class as a replacement for Db, fixed naming --- tests/Unit/Database/Migration/MigrateTest.php | 14 +++++++------- .../Database/Migration/MigrationServiceProviderTest.php | 17 ++++++++--------- 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'tests/Unit/Database/Migration') diff --git a/tests/Unit/Database/Migration/MigrateTest.php b/tests/Unit/Database/Migration/MigrateTest.php index c88ad777..2adbed41 100644 --- a/tests/Unit/Database/Migration/MigrateTest.php +++ b/tests/Unit/Database/Migration/MigrateTest.php @@ -120,12 +120,12 @@ class MigrateTest extends TestCase $dbManager->bootEloquent(); $db = $dbManager->getConnection(); $db->useDefaultSchemaGrammar(); - $scheme = $db->getSchemaBuilder(); + $schema = $db->getSchemaBuilder(); - $app->instance('scheme', $scheme); - $app->bind(SchemaBuilder::class, 'scheme'); + $app->instance('schema', $schema); + $app->bind(SchemaBuilder::class, 'schema'); - $migration = new Migrate($scheme, $app); + $migration = new Migrate($schema, $app); $messages = []; $migration->setOutput(function ($msg) use (&$messages) { @@ -134,7 +134,7 @@ class MigrateTest extends TestCase $migration->run(__DIR__ . '/Stub', Migrate::UP); - $this->assertTrue($scheme->hasTable('migrations')); + $this->assertTrue($schema->hasTable('migrations')); $migrations = $db->table('migrations')->get(); $this->assertCount(3, $migrations); @@ -143,7 +143,7 @@ class MigrateTest extends TestCase $this->assertTrue($migrations->contains('migration', '2017_12_24_053300_another_stuff')); $this->assertTrue($migrations->contains('migration', '2022_12_22_221222_add_some_feature')); - $this->assertTrue($scheme->hasTable('lorem_ipsum')); + $this->assertTrue($schema->hasTable('lorem_ipsum')); $migration->run(__DIR__ . '/Stub', Migrate::DOWN, true); @@ -155,6 +155,6 @@ class MigrateTest extends TestCase $migrations = $db->table('migrations')->get(); $this->assertCount(0, $migrations); - $this->assertFalse($scheme->hasTable('lorem_ipsum')); + $this->assertFalse($schema->hasTable('lorem_ipsum')); } } diff --git a/tests/Unit/Database/Migration/MigrationServiceProviderTest.php b/tests/Unit/Database/Migration/MigrationServiceProviderTest.php index a99cdebe..593da5c5 100644 --- a/tests/Unit/Database/Migration/MigrationServiceProviderTest.php +++ b/tests/Unit/Database/Migration/MigrationServiceProviderTest.php @@ -2,11 +2,10 @@ namespace Engelsystem\Test\Unit\Database\Migration; -use Engelsystem\Database\Db; +use Engelsystem\Database\Database; use Engelsystem\Database\Migration\Migrate; use Engelsystem\Database\Migration\MigrationServiceProvider; use Engelsystem\Test\Unit\ServiceProviderTest; -use Illuminate\Database\Capsule\Manager as CapsuleManager; use Illuminate\Database\Connection; use Illuminate\Database\Schema\Builder as SchemaBuilder; use PHPUnit_Framework_MockObject_MockObject as MockObject; @@ -22,8 +21,8 @@ class MigrationServiceProviderTest extends ServiceProviderTest $migration = $this->getMockBuilder(Migrate::class) ->disableOriginalConstructor() ->getMock(); - /** @var MockObject|CapsuleManager $dbManager */ - $dbManager = $this->getMockBuilder(CapsuleManager::class) + /** @var Database|MockObject $database */ + $database = $this->getMockBuilder(Database::class) ->disableOriginalConstructor() ->getMock(); /** @var MockObject|Connection $dbConnection */ @@ -35,19 +34,19 @@ class MigrationServiceProviderTest extends ServiceProviderTest ->disableOriginalConstructor() ->getMock(); - $app = $this->getApp(['make', 'instance', 'bind']); + $app = $this->getApp(['make', 'instance', 'bind', 'get']); $app->expects($this->atLeastOnce()) ->method('instance') - ->withConsecutive(['db.scheme'], ['db.migration']) + ->withConsecutive(['db.schema'], ['db.migration']) ->willReturnOnConsecutiveCalls($schemaBuilder, $migration); - $this->setExpects($app, 'bind', [SchemaBuilder::class, 'db.scheme']); + $this->setExpects($app, 'bind', [SchemaBuilder::class, 'db.schema']); $this->setExpects($app, 'make', [Migrate::class], $migration); + $this->setExpects($app, 'get', [Database::class], $database); $this->setExpects($dbConnection, 'getSchemaBuilder', null, $schemaBuilder); - $this->setExpects($dbManager, 'getConnection', null, $dbConnection); - Db::setDbManager($dbManager); + $this->setExpects($database, 'getConnection', null, $dbConnection); $serviceProvider = new MigrationServiceProvider($app); $serviceProvider->register(); -- cgit v1.2.3-54-g00ecf