From 411ea5bb6d0ecf32e6c989a99fac120502db9fe9 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Tue, 31 Oct 2017 14:15:19 +0100 Subject: Refactored service provider tests --- tests/Unit/Config/ConfigServiceProviderTest.php | 35 ++++++------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'tests/Unit/Config/ConfigServiceProviderTest.php') diff --git a/tests/Unit/Config/ConfigServiceProviderTest.php b/tests/Unit/Config/ConfigServiceProviderTest.php index 26128e79..96ac8704 100644 --- a/tests/Unit/Config/ConfigServiceProviderTest.php +++ b/tests/Unit/Config/ConfigServiceProviderTest.php @@ -5,10 +5,10 @@ namespace Engelsystem\Test\Config; use Engelsystem\Application; use Engelsystem\Config\Config; use Engelsystem\Config\ConfigServiceProvider; -use PHPUnit\Framework\TestCase; +use Engelsystem\Test\Unit\ServiceProviderTest; use PHPUnit_Framework_MockObject_MockObject; -class ConfigServiceProviderTest extends TestCase +class ConfigServiceProviderTest extends ServiceProviderTest { /** * @covers \Engelsystem\Config\ConfigServiceProvider::register() @@ -19,34 +19,15 @@ class ConfigServiceProviderTest extends TestCase $config = $this->getMockBuilder(Config::class) ->getMock(); - /** @var PHPUnit_Framework_MockObject_MockObject|Application $app */ - $app = $this->getMockBuilder(Application::class) - ->setMethods(['make', 'instance', 'get']) - ->getMock(); + $app = $this->getApp(['make', 'instance', 'get']); Application::setInstance($app); - $app->expects($this->once()) - ->method('make') - ->with(Config::class) - ->willReturn($config); - - $app->expects($this->once()) - ->method('instance') - ->with('config', $config); - - $app->expects($this->atLeastOnce()) - ->method('get') - ->with('path.config') - ->willReturn(__DIR__ . '/../../../config'); - - $config->expects($this->exactly(2)) - ->method('set') - ->withAnyParameters(); + $this->setExpects($app, 'make', [Config::class], $config); + $this->setExpects($app, 'instance', ['config', $config]); + $this->setExpects($app, 'get', ['path.config'], __DIR__ . '/../../../config', $this->atLeastOnce()); - $config->expects($this->once()) - ->method('get') - ->with(null) - ->willReturn([]); + $this->setExpects($config, 'set', null, null, $this->exactly(2)); + $this->setExpects($config, 'get', [null], []); $serviceProvider = new ConfigServiceProvider($app); $serviceProvider->register(); -- cgit v1.2.3-54-g00ecf