|
|
|
@ -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();
|
|
|
|
|