<?php
/**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
namespace Friendica\Test\src\App;
use Friendica\App;
-use Friendica\Core\Config\IConfig;
+use Friendica\Core\Cache\Capability\ICanCache;
+use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
+use Friendica\Core\Lock\Capability\ICanLock;
use Friendica\LegacyModule;
use Friendica\Module\HTTPException\PageNotFound;
use Friendica\Module\WellKnown\HostMeta;
use Friendica\Test\DatabaseTest;
+use Mockery;
class ModuleTest extends DatabaseTest
{
private function assertModule(array $assert, App\Module $module)
{
- $this->assertEquals($assert['isBackend'], $module->isBackend());
- $this->assertEquals($assert['name'], $module->getName());
- $this->assertEquals($assert['class'], $module->getClassName());
+ self::assertEquals($assert['isBackend'], $module->isBackend());
+ self::assertEquals($assert['name'], $module->getName());
+ self::assertEquals($assert['class'], $module->getClassName());
}
/**
{
$module = new App\Module();
- $this->assertModule([
+ self::assertModule([
'isBackend' => false,
'name' => App\Module::DEFAULT,
'class' => App\Module::DEFAULT_CLASS,
{
$module = (new App\Module())->determineModule($args);
- $this->assertModule($assert, $module);
+ self::assertModule($assert, $module);
}
public function dataModuleClass()
],
'legacy' => [
'assert' => LegacyModule::class,
- // API is one of the last modules to switch from legacy to new BaseModule
- // so this should be a stable test case until we completely switch ;-)
- 'name' => 'api',
- 'command' => 'api/test/it',
+ 'name' => 'display',
+ 'command' => 'display/test/it',
'privAdd' => false,
],
'new' => [
*/
public function testModuleClass($assert, string $name, string $command, bool $privAdd)
{
- $config = \Mockery::mock(IConfig::class);
+ $config = Mockery::mock(IManageConfigValues::class);
$config->shouldReceive('get')->with('config', 'private_addons', false)->andReturn($privAdd)->atMost()->once();
- $l10n = \Mockery::mock(L10n::class);
+ $l10n = Mockery::mock(L10n::class);
$l10n->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
- $router = (new App\Router([], $l10n))->loadRoutes(include __DIR__ . '/../../../static/routes.config.php');
+ $cache = Mockery::mock(ICanCache::class);
+ $cache->shouldReceive('get')->with('routerDispatchData')->andReturn('')->atMost()->once();
+ $cache->shouldReceive('get')->with('lastRoutesFileModifiedTime')->andReturn('')->atMost()->once();
+ $cache->shouldReceive('set')->withAnyArgs()->andReturn(false)->atMost()->twice();
+
+ $lock = Mockery::mock(ICanLock::class);
+ $lock->shouldReceive('acquire')->andReturn(true);
+ $lock->shouldReceive('isLocked')->andReturn(false);
+
+ $router = (new App\Router([], __DIR__ . '/../../../static/routes.config.php', $l10n, $cache, $lock));
$module = (new App\Module($name))->determineClass(new App\Arguments('', $command), $router, $config);
- $this->assertEquals($assert, $module->getClassName());
+ self::assertEquals($assert, $module->getClassName());
}
/**
$moduleNew = $module->determineModule(new App\Arguments());
- $this->assertNotSame($moduleNew, $module);
+ self::assertNotSame($moduleNew, $module);
}
}