X-Git-Url: https://reisub.nsupdate.info/git/?a=blobdiff_plain;f=tests%2FUtil%2FAppMockTrait.php;h=23920ff6f434d30f666472f8011184ed3aebe951;hb=740cbc97693c6b4ee467c36bef3930ec69ef7f72;hp=817570dd58c948cd4418e3217e4a660f3d6d1ac2;hpb=d6944eb894df3f245e2a5bb691da2f9b306e253a;p=friendica.git%2F.git diff --git a/tests/Util/AppMockTrait.php b/tests/Util/AppMockTrait.php index 817570dd58..23920ff6f4 100644 --- a/tests/Util/AppMockTrait.php +++ b/tests/Util/AppMockTrait.php @@ -30,19 +30,27 @@ trait AppMockTrait */ protected $profilerMock; + /** + * @var MockInterface|App\Mode The mocked App mode + */ + protected $mode; + /** * Mock the App * * @param vfsStreamDirectory $root The root directory + * @param Config\Cache\ConfigCache $configCache + * @param bool $raw If true, no config mocking will be done */ - public function mockApp($root) + public function mockApp(vfsStreamDirectory $root, $configCache = null, $raw = false) { $this->configMock = \Mockery::mock(Config\Cache\IConfigCache::class); + $this->mode = \Mockery::mock(App\Mode::class); $configAdapterMock = \Mockery::mock(Config\Adapter\IConfigAdapter::class); // Disable the adapter $configAdapterMock->shouldReceive('isConnected')->andReturn(false); - $config = new Config\Configuration($this->configMock, $configAdapterMock); + $config = new Config\Configuration((isset($configCache) ? $configCache : $this->configMock), $configAdapterMock); // Initialize empty Config Config::init($config); @@ -52,6 +60,37 @@ trait AppMockTrait ->shouldReceive('getBasePath') ->andReturn($root->url()); + $this->app + ->shouldReceive('getMode') + ->andReturn($this->mode); + + $this->profilerMock = \Mockery::mock(Profiler::class); + $this->profilerMock->shouldReceive('saveTimestamp'); + + $this->app + ->shouldReceive('getConfigCache') + ->andReturn((isset($configCache) ? $configCache : $this->configMock)); + $this->app + ->shouldReceive('getTemplateEngine') + ->andReturn(new FriendicaSmartyEngine()); + $this->app + ->shouldReceive('getCurrentTheme') + ->andReturn('Smarty3'); + $this->app + ->shouldReceive('getProfiler') + ->andReturn($this->profilerMock); + $this->app + ->shouldReceive('getBaseUrl') + ->andReturnUsing(function () { + return $this->app->getConfigCache()->get('system', 'url'); + }); + + BaseObject::setApp($this->app); + + if ($raw) { + return; + } + $this->configMock ->shouldReceive('has') ->andReturn(true); @@ -79,26 +118,5 @@ trait AppMockTrait ->shouldReceive('get') ->with('system', 'theme') ->andReturn('system_theme'); - - $this->profilerMock = \Mockery::mock(Profiler::class); - $this->profilerMock->shouldReceive('saveTimestamp'); - - $this->app - ->shouldReceive('getConfigCache') - ->andReturn($this->configMock); - $this->app - ->shouldReceive('getTemplateEngine') - ->andReturn(new FriendicaSmartyEngine()); - $this->app - ->shouldReceive('getCurrentTheme') - ->andReturn('Smarty3'); - $this->app - ->shouldReceive('getBaseUrl') - ->andReturn('http://friendica.local'); - $this->app - ->shouldReceive('getProfiler') - ->andReturn($this->profilerMock); - - BaseObject::setApp($this->app); } }