From af09865f3da55ae8e50ee0bf9f5ebc7d005dfcf5 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 13 Oct 2019 21:06:24 +0200 Subject: Fix/Cleanup tests for DatabaseServiceProvider --- .../Database/DatabaseServiceProviderTest.php | 29 ++++++---------------- tests/Feature/Database/DatabaseTest.php | 2 +- 2 files changed, 8 insertions(+), 23 deletions(-) (limited to 'tests/Feature') diff --git a/tests/Feature/Database/DatabaseServiceProviderTest.php b/tests/Feature/Database/DatabaseServiceProviderTest.php index d66ed25c..aa4dbc7b 100644 --- a/tests/Feature/Database/DatabaseServiceProviderTest.php +++ b/tests/Feature/Database/DatabaseServiceProviderTest.php @@ -2,10 +2,9 @@ namespace Engelsystem\Test\Feature\Database; -use Engelsystem\Application; use Engelsystem\Config\Config; +use Engelsystem\Database\Database; use Engelsystem\Database\DatabaseServiceProvider; -use PHPUnit\Framework\MockObject\MockObject; class DatabaseServiceProviderTest extends DatabaseTest { @@ -14,27 +13,13 @@ class DatabaseServiceProviderTest extends DatabaseTest */ public function testRegister() { - /** @var Config|MockObject $config */ - $config = $this->getMockBuilder(Config::class) - ->getMock(); + $this->app->instance('config', new Config([ + 'database' => $this->getDbConfig(), + 'timezone' => 'UTC', + ])); - /** @var Application|MockObject $app */ - $app = $this->getMockBuilder(Application::class) - ->setMethods(['get']) - ->getMock(); - Application::setInstance($app); - - $app->expects($this->once()) - ->method('get') - ->with('config') - ->willReturn($config); - - $config->expects($this->atLeastOnce()) - ->method('get') - ->with('database') - ->willReturn($this->getDbConfig()); - - $serviceProvider = new DatabaseServiceProvider($app); + $serviceProvider = new DatabaseServiceProvider($this->app); $serviceProvider->register(); + $this->assertTrue($this->app->has(Database::class)); } } diff --git a/tests/Feature/Database/DatabaseTest.php b/tests/Feature/Database/DatabaseTest.php index 11df6779..0116e526 100644 --- a/tests/Feature/Database/DatabaseTest.php +++ b/tests/Feature/Database/DatabaseTest.php @@ -2,7 +2,7 @@ namespace Engelsystem\Test\Feature\Database; -use PHPUnit\Framework\TestCase; +use Engelsystem\Test\Unit\TestCase; abstract class DatabaseTest extends TestCase { -- cgit v1.2.3-70-g09d2