1
0
Fork 0

Fix tests (remove superfluous second parameter)

This commit is contained in:
Philipp Holzer 2020-01-18 13:48:29 +01:00
parent 921845c3bd
commit 1c49f1169f
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
6 changed files with 12 additions and 27 deletions

View file

@ -54,11 +54,11 @@ trait AppMockTrait
$this->configMock = \Mockery::mock(Config\Cache\ConfigCache::class); $this->configMock = \Mockery::mock(Config\Cache\ConfigCache::class);
$this->dice->shouldReceive('create') $this->dice->shouldReceive('create')
->with(Config\Cache\ConfigCache::class, []) ->with(Config\Cache\ConfigCache::class)
->andReturn($this->configMock); ->andReturn($this->configMock);
$this->mode = \Mockery::mock(App\Mode::class); $this->mode = \Mockery::mock(App\Mode::class);
$this->dice->shouldReceive('create') $this->dice->shouldReceive('create')
->with(App\Mode::class, []) ->with(App\Mode::class)
->andReturn($this->mode); ->andReturn($this->mode);
$configModel= \Mockery::mock(\Friendica\Model\Config\Config::class); $configModel= \Mockery::mock(\Friendica\Model\Config\Config::class);
// Disable the adapter // Disable the adapter
@ -66,48 +66,33 @@ trait AppMockTrait
$config = new Config\JitConfiguration($this->configMock, $configModel); $config = new Config\JitConfiguration($this->configMock, $configModel);
$this->dice->shouldReceive('create') $this->dice->shouldReceive('create')
->with(Config\IConfiguration::class, []) ->with(Config\IConfiguration::class)
->andReturn($config); ->andReturn($config);
// Mocking App and most used functions // Mocking App and most used functions
$this->app = \Mockery::mock(App::class); $this->app = \Mockery::mock(App::class);
$this->dice->shouldReceive('create') $this->dice->shouldReceive('create')
->with(App::class, []) ->with(App::class)
->andReturn($this->app); ->andReturn($this->app);
$this->app $this->app
->shouldReceive('getBasePath') ->shouldReceive('getBasePath')
->andReturn($root->url()); ->andReturn($root->url());
$this->app
->shouldReceive('getMode')
->andReturn($this->mode);
$this->profilerMock = \Mockery::mock(Profiler::class); $this->profilerMock = \Mockery::mock(Profiler::class);
$this->profilerMock->shouldReceive('saveTimestamp'); $this->profilerMock->shouldReceive('saveTimestamp');
$this->dice->shouldReceive('create') $this->dice->shouldReceive('create')
->with(Profiler::class, []) ->with(Profiler::class)
->andReturn($this->profilerMock); ->andReturn($this->profilerMock);
$this->app $this->app
->shouldReceive('getConfigCache') ->shouldReceive('getConfigCache')
->andReturn($this->configMock); ->andReturn($this->configMock);
$this->app
->shouldReceive('getConfig')
->andReturn($config);
$this->app $this->app
->shouldReceive('getTemplateEngine') ->shouldReceive('getTemplateEngine')
->andReturn(new FriendicaSmartyEngine()); ->andReturn(new FriendicaSmartyEngine());
$this->app $this->app
->shouldReceive('getCurrentTheme') ->shouldReceive('getCurrentTheme')
->andReturn('Smarty3'); ->andReturn('Smarty3');
$this->app
->shouldReceive('getProfiler')
->andReturn($this->profilerMock);
$this->app
->shouldReceive('getBaseUrl')
->andReturnUsing(function () {
return $this->configMock->get('system', 'url');
});
DI::init($this->dice); DI::init($this->dice);

View file

@ -43,13 +43,13 @@ class BBCodeTest extends MockedTest
$l10nMock = \Mockery::mock(L10n::class); $l10nMock = \Mockery::mock(L10n::class);
$l10nMock->shouldReceive('t')->withAnyArgs()->andReturnUsing(function ($args) { return $args; }); $l10nMock->shouldReceive('t')->withAnyArgs()->andReturnUsing(function ($args) { return $args; });
$this->dice->shouldReceive('create') $this->dice->shouldReceive('create')
->with(L10n::class, []) ->with(L10n::class)
->andReturn($l10nMock); ->andReturn($l10nMock);
$baseUrlMock = \Mockery::mock(BaseURL::class); $baseUrlMock = \Mockery::mock(BaseURL::class);
$baseUrlMock->shouldReceive('get')->withAnyArgs()->andReturn('friendica.local'); $baseUrlMock->shouldReceive('get')->withAnyArgs()->andReturn('friendica.local');
$this->dice->shouldReceive('create') $this->dice->shouldReceive('create')
->with(BaseURL::class, []) ->with(BaseURL::class)
->andReturn($baseUrlMock); ->andReturn($baseUrlMock);
} }

View file

@ -34,7 +34,7 @@ class InstallerTest extends MockedTest
$dice = $dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php'); $dice = $dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
$dice->shouldReceive('create') $dice->shouldReceive('create')
->with(\Friendica\Core\L10n\L10n::class, []) ->with(\Friendica\Core\L10n\L10n::class)
->andReturn($this->l10nMock); ->andReturn($this->l10nMock);
DI::init($dice); DI::init($dice);

View file

@ -19,14 +19,14 @@ class SemaphoreLockTest extends LockTest
$app = \Mockery::mock(App::class); $app = \Mockery::mock(App::class);
$app->shouldReceive('getHostname')->andReturn('friendica.local'); $app->shouldReceive('getHostname')->andReturn('friendica.local');
$dice->shouldReceive('create')->with(App::class, [])->andReturn($app); $dice->shouldReceive('create')->with(App::class)->andReturn($app);
$configMock = \Mockery::mock(JitConfiguration::class); $configMock = \Mockery::mock(JitConfiguration::class);
$configMock $configMock
->shouldReceive('get') ->shouldReceive('get')
->with('system', 'temppath', NULL, false) ->with('system', 'temppath', NULL, false)
->andReturn('/tmp/'); ->andReturn('/tmp/');
$dice->shouldReceive('create')->with(IConfiguration::class, [])->andReturn($configMock); $dice->shouldReceive('create')->with(IConfiguration::class)->andReturn($configMock);
// @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject // @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
DI::init($dice); DI::init($dice);

View file

@ -15,7 +15,7 @@ class SystemTest extends TestCase
$baseUrl = \Mockery::mock(BaseURL::class); $baseUrl = \Mockery::mock(BaseURL::class);
$baseUrl->shouldReceive('getHostname')->andReturn('friendica.local')->once(); $baseUrl->shouldReceive('getHostname')->andReturn('friendica.local')->once();
$dice = \Mockery::mock(Dice::class); $dice = \Mockery::mock(Dice::class);
$dice->shouldReceive('create')->with(BaseURL::class, [])->andReturn($baseUrl); $dice->shouldReceive('create')->with(BaseURL::class)->andReturn($baseUrl);
DI::init($dice); DI::init($dice);
} }

View file

@ -22,7 +22,7 @@ class CurlResultTest extends TestCase
$logger = new NullLogger(); $logger = new NullLogger();
$dice->shouldReceive('create') $dice->shouldReceive('create')
->with(LoggerInterface::class, []) ->with(LoggerInterface::class)
->andReturn($logger); ->andReturn($logger);
DI::init($dice); DI::init($dice);