fix tests & remove superfluous parameter

This commit is contained in:
Philipp Holzer 2019-08-12 21:51:51 +02:00
parent 4089e17f85
commit b1ae58cdc5
No known key found for this signature in database
GPG Key ID: D8365C3D36B77D90
3 changed files with 5 additions and 24 deletions

View File

@ -107,11 +107,10 @@ class Module
* Determines the current module based on the App arguments and the server variable * Determines the current module based on the App arguments and the server variable
* *
* @param Arguments $args The Friendica arguments * @param Arguments $args The Friendica arguments
* @param array $server The $_SERVER variable
* *
* @return Module The module with the determined module * @return Module The module with the determined module
*/ */
public function determineModule(Arguments $args, array $server) public function determineModule(Arguments $args)
{ {
if ($args->getArgc() > 0) { if ($args->getArgc() > 0) {
$module = str_replace('.', '_', $args->get(0)); $module = str_replace('.', '_', $args->get(0));

View File

@ -145,7 +145,7 @@ return [
App\Module::class => [ App\Module::class => [
'instanceOf' => App\Module::class, 'instanceOf' => App\Module::class,
'call' => [ 'call' => [
['determineModule', [$_SERVER], Dice::CHAIN_CALL], ['determineModule', [], Dice::CHAIN_CALL],
], ],
], ],
]; ];

View File

@ -45,7 +45,6 @@ class ModuleTest extends DatabaseTest
'network/data/in', 'network/data/in',
['network', 'data', 'in'], ['network', 'data', 'in'],
3), 3),
'server' => [],
], ],
'withStrikeAndPoint' => [ 'withStrikeAndPoint' => [
'assert' => [ 'assert' => [
@ -57,7 +56,6 @@ class ModuleTest extends DatabaseTest
'with-strike.and-point/data/in', 'with-strike.and-point/data/in',
['with-strike.and-point', 'data', 'in'], ['with-strike.and-point', 'data', 'in'],
3), 3),
'server' => [],
], ],
'withNothing' => [ 'withNothing' => [
'assert' => [ 'assert' => [
@ -66,7 +64,6 @@ class ModuleTest extends DatabaseTest
'class' => App\Module::DEFAULT_CLASS, 'class' => App\Module::DEFAULT_CLASS,
], ],
'args' => new App\Arguments(), 'args' => new App\Arguments(),
'server' => []
], ],
'withIndex' => [ 'withIndex' => [
'assert' => [ 'assert' => [
@ -75,21 +72,8 @@ class ModuleTest extends DatabaseTest
'class' => App\Module::DEFAULT_CLASS, 'class' => App\Module::DEFAULT_CLASS,
], ],
'args' => new App\Arguments(), 'args' => new App\Arguments(),
'server' => ['PHP_SELF' => 'index.php']
], ],
'withIndexButBackendMod' => [ 'withBackendMod' => [
'assert' => [
'isBackend' => false,
'name' => App\Module::BACKEND_MODULES[0],
'class' => App\Module::DEFAULT_CLASS,
],
'args' => new App\Arguments(App\Module::BACKEND_MODULES[0] . '/data/in',
App\Module::BACKEND_MODULES[0] . '/data/in',
[App\Module::BACKEND_MODULES[0], 'data', 'in'],
3),
'server' => ['PHP_SELF' => 'index.php']
],
'withNotIndexAndBackendMod' => [
'assert' => [ 'assert' => [
'isBackend' => true, 'isBackend' => true,
'name' => App\Module::BACKEND_MODULES[0], 'name' => App\Module::BACKEND_MODULES[0],
@ -99,7 +83,6 @@ class ModuleTest extends DatabaseTest
App\Module::BACKEND_MODULES[0] . '/data/in', App\Module::BACKEND_MODULES[0] . '/data/in',
[App\Module::BACKEND_MODULES[0], 'data', 'in'], [App\Module::BACKEND_MODULES[0], 'data', 'in'],
3), 3),
'server' => ['PHP_SELF' => 'daemon.php']
], ],
'withFirefoxApp' => [ 'withFirefoxApp' => [
'assert' => [ 'assert' => [
@ -111,7 +94,6 @@ class ModuleTest extends DatabaseTest
'users/sign_in', 'users/sign_in',
['users', 'sign_in'], ['users', 'sign_in'],
3), 3),
'server' => ['PHP_SELF' => 'index.php'],
], ],
]; ];
} }
@ -121,9 +103,9 @@ class ModuleTest extends DatabaseTest
* *
* @dataProvider dataModuleName * @dataProvider dataModuleName
*/ */
public function testModuleName(array $assert, App\Arguments $args, array $server) public function testModuleName(array $assert, App\Arguments $args)
{ {
$module = (new App\Module())->determineModule($args, $server); $module = (new App\Module())->determineModule($args);
$this->assertModule($assert, $module); $this->assertModule($assert, $module);
} }