1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-16 19:44:09 +02:00

Simplified inAdminDir().

This commit is contained in:
Cameron
2020-12-27 12:13:51 -08:00
parent f93ce247fd
commit 6ed9ad3e0d
2 changed files with 30 additions and 18 deletions

View File

@@ -960,21 +960,24 @@ class e107Test extends \Codeception\Test\Unit
4 => array('path' => 'e107_plugins/forum/forum.php', 'plugdir' => true, 'expected' => false),
5 => array('path' => 'e107_plugins/vstore/admin_config.php', 'plugdir' => true, 'expected' => true),
6 => array('path' => 'e107_plugins/login_menu/config.php', 'plugdir' => true, 'expected' => true),
7 => array('path' => 'e107_plugins/aplugin/prefs.php', 'plugdir' => true, 'expected' => true),
7 => array('path' => 'e107_plugins/myplugin/prefs.php', 'plugdir' => true, 'expected' => true),
8 => array('path' => 'e107_plugins/dtree_menu/dtree_config.php', 'plugdir' => true, 'expected' => true),
9 => array('path' => 'e107_plugins/myplugin/admin/something.php', 'plugdir' => true, 'expected' => true),
10 => array('path' => 'e107_plugins/myplugin/bla_admin.php', 'plugdir' => true, 'expected' => true),
11 => array('path' => 'e107_plugins/myplugin/admin_xxx.php', 'plugdir' => true, 'expected' => true),
);
foreach($tests as $var)
foreach($tests as $index=>$var)
{
$curPage = basename($var['path']);
$result = $this->e107->inAdminDir($var['path'], $curPage, $var['plugdir']);
$this->assertSame($var['expected'], $result);
$this->assertSame($var['expected'], $result, "Failed on index #".$index);
}
// Test legacy override.
$GLOBALS['eplug_admin'] = true;
$result = $this->e107->inAdminDir('myplugin.php','myplugin.php', true);
$this->assertTrue($result);
$this->assertTrue($result, "Legacy Override Failed");
// Test legacy off.
$GLOBALS['eplug_admin'] = false;