summaryrefslogtreecommitdiff
path: root/tests/Unit/Database/DatabaseServiceProviderTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Unit/Database/DatabaseServiceProviderTest.php')
-rw-r--r--tests/Unit/Database/DatabaseServiceProviderTest.php48
1 files changed, 44 insertions, 4 deletions
diff --git a/tests/Unit/Database/DatabaseServiceProviderTest.php b/tests/Unit/Database/DatabaseServiceProviderTest.php
index 8f7898cd..0f259036 100644
--- a/tests/Unit/Database/DatabaseServiceProviderTest.php
+++ b/tests/Unit/Database/DatabaseServiceProviderTest.php
@@ -3,7 +3,9 @@
namespace Engelsystem\Test\Unit\Database;
use Engelsystem\Config\Config;
+use Engelsystem\Database\Database;
use Engelsystem\Database\DatabaseServiceProvider;
+use Engelsystem\Database\Db;
use Engelsystem\Test\Unit\ServiceProviderTest;
use Exception;
use Illuminate\Database\Capsule\Manager as CapsuleManager;
@@ -18,9 +20,29 @@ class DatabaseServiceProviderTest extends ServiceProviderTest
*/
public function testRegister()
{
- list($app, $dbManager) = $this->prepare(['driver' => 'sqlite', 'database' => ':memory:']);
+ /** @var Application|MockObject $app */
+ /** @var CapsuleManager|MockObject $dbManager */
+ /** @var PDO|MockObject $pdo */
+ /** @var Database|MockObject $database */
+ /** @var Connection|MockObject $connection */
+ list($app, $dbManager, $pdo, $database, $connection) = $this->prepare(
+ [
+ 'driver' => 'sqlite',
+ 'database' => ':memory:'
+ ]
+ );
- $this->setExpects($app, 'instance', ['db', $dbManager]);
+ $app->expects($this->exactly(7))
+ ->method('instance')
+ ->withConsecutive(
+ [CapsuleManager::class, $dbManager],
+ [Db::class, $dbManager],
+ [Connection::class, $connection],
+ [Database::class, $database],
+ ['db', $database],
+ ['db.pdo', $pdo],
+ ['db.connection', $connection]
+ );
$serviceProvider = new DatabaseServiceProvider($app);
$serviceProvider->register();
@@ -64,13 +86,31 @@ class DatabaseServiceProviderTest extends ServiceProviderTest
$connection = $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()
->getMock();
+ /** @var PDO|MockObject $pdo */
+ $pdo = $this->getMockBuilder(PDO::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ /** @var Database|MockObject $database */
+ $database = $this->getMockBuilder(Database::class)
+ ->disableOriginalConstructor()
+ ->getMock();
$app = $this->getApp(['get', 'make', 'instance']);
$this->setExpects($app, 'get', ['config'], $config);
- $this->setExpects($app, 'make', [CapsuleManager::class], $dbManager);
$this->setExpects($config, 'get', ['database'], $dbConfigData, $this->atLeastOnce());
+ $app->expects($this->atLeastOnce())
+ ->method('make')
+ ->withConsecutive(
+ [CapsuleManager::class],
+ [Database::class]
+ )
+ ->willReturn(
+ $dbManager,
+ $database
+ );
+
$this->setExpects($dbManager, 'setAsGlobal');
$this->setExpects($dbManager, 'bootEloquent');
@@ -86,6 +126,6 @@ class DatabaseServiceProviderTest extends ServiceProviderTest
});
$this->setExpects($dbManager, 'getConnection', [], $connection, $this->atLeastOnce());
- return [$app, $dbManager];
+ return [$app, $dbManager, $pdo, $database, $connection];
}
}