diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2019-11-06 13:16:00 +0100 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2019-11-06 13:16:00 +0100 |
commit | 2cce967eb09edd6ef35238c68f8ff5ed2348f5fd (patch) | |
tree | 8848ca509d5a37cf699120e57abdd80e53443c0b /tests/Unit/Config | |
parent | 867d720f150dc5a728a092f8d66d8b1c1a5efc5a (diff) |
Tests: Replaced duplicates and formatting/cleanup
Diffstat (limited to 'tests/Unit/Config')
-rw-r--r-- | tests/Unit/Config/ConfigServiceProviderTest.php | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/tests/Unit/Config/ConfigServiceProviderTest.php b/tests/Unit/Config/ConfigServiceProviderTest.php index 62a662f8..8895f66d 100644 --- a/tests/Unit/Config/ConfigServiceProviderTest.php +++ b/tests/Unit/Config/ConfigServiceProviderTest.php @@ -23,21 +23,9 @@ class ConfigServiceProviderTest extends ServiceProviderTest */ public function testRegister() { + /** @var Application|MockObject $app */ /** @var Config|MockObject $config */ - $config = $this->getMockBuilder(Config::class) - ->getMock(); - - $app = $this->getApp(['make', 'instance', 'get']); - Application::setInstance($app); - - $this->setExpects($app, 'make', [Config::class], $config); - $this->setExpects($app, 'get', ['path.config'], __DIR__ . '/../../../config', $this->atLeastOnce()); - $app->expects($this->exactly(2)) - ->method('instance') - ->withConsecutive( - [Config::class, $config], - ['config', $config] - ); + list($app, $config) = $this->getConfiguredApp(__DIR__ . '/../../../config'); $this->setExpects($config, 'set', null, null, $this->exactly(2)); $config->expects($this->exactly(3)) @@ -64,21 +52,9 @@ class ConfigServiceProviderTest extends ServiceProviderTest */ public function testRegisterException() { + /** @var Application|MockObject $app */ /** @var Config|MockObject $config */ - $config = $this->getMockBuilder(Config::class) - ->getMock(); - - $app = $this->getApp(['make', 'instance', 'get']); - Application::setInstance($app); - - $this->setExpects($app, 'make', [Config::class], $config); - $app->expects($this->exactly(2)) - ->method('instance') - ->withConsecutive( - [Config::class, $config], - ['config', $config] - ); - $this->setExpects($app, 'get', ['path.config'], __DIR__ . '/not_existing', $this->atLeastOnce()); + list($app, $config) = $this->getConfiguredApp(__DIR__ . '/not_existing'); $this->setExpects($config, 'set', null, null, $this->never()); $this->setExpects($config, 'get', [null], []); @@ -151,4 +127,29 @@ class ConfigServiceProviderTest extends ServiceProviderTest $config->get(null) ); } + + /** + * @param string $configPath + * @return Application[]|Config[] + */ + protected function getConfiguredApp(string $configPath) + { + /** @var Config|MockObject $config */ + $config = $this->getMockBuilder(Config::class) + ->getMock(); + + $app = $this->getApp(['make', 'instance', 'get']); + Application::setInstance($app); + + $this->setExpects($app, 'make', [Config::class], $config); + $this->setExpects($app, 'get', ['path.config'], $configPath, $this->atLeastOnce()); + $app->expects($this->exactly(2)) + ->method('instance') + ->withConsecutive( + [Config::class, $config], + ['config', $config] + ); + + return [$app, $config]; + } } |