1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 14:46:56 +02:00

Expanded on getperms() test.

This commit is contained in:
Cameron
2021-01-22 17:09:55 -08:00
parent 45b536b50a
commit 93918849f4
3 changed files with 14 additions and 19 deletions

View File

@@ -1275,7 +1275,7 @@ function check_class($var, $userclass = USERCLASS_LIST, $uid = 0)
* @param bool|mixed|string $ap
* @return bool
*/
function getperms($arg, $ap = ADMINPERMS)
function getperms($arg, $ap = ADMINPERMS, $path = e_SELF)
{
// $ap = "4"; // Just for testing.
@@ -1294,11 +1294,12 @@ function getperms($arg, $ap = ADMINPERMS)
return true;
}
if ($arg === 'P' && preg_match('#(.*?)/' .e107::getInstance()->getFolder('plugins'). '(.*?)/(.*?)#', e_SELF, $matches))
if ($arg === 'P' && preg_match('#(.*?)/' .e107::getInstance()->getFolder('plugins'). '(.*?)/(.*?)#', $path, $matches))
{
$sql = e107::getDb('psql');
/* $id = e107::getPlug()->load($matches[2])->getId();
$arg = 'P'.$id;*/
// FIXME - cache it, avoid sql query here
if ($sql->select('plugin', 'plugin_id', "plugin_path = '".$matches[2]."' LIMIT 1 "))
{
$row = $sql->fetch();

View File

@@ -12,19 +12,11 @@
class class2Test extends \Codeception\Test\Unit
{
/** @var ${TESTED_NAME} */
protected $ep;
protected function _before()
function testLoadClass2()
{
/*try
{
$this->ep = $this->make('${TESTED_NAME}');
} catch(Exception $e)
{
$this->assertTrue(false, "Couldn't load ${TESTED_NAME} object");
}*/
require_once(e_BASE."class2.php"); // already loaded but coverage says otherwise.
}
@@ -41,16 +33,17 @@
$result = getperms('U1|U2', '0.');
$this->assertTrue($result);
/*
$pid = e107::getDb()->retrieve('plugin', 'plugin_id', "plugin_path = 'gallery'");
$result = getperms('P', 'P'.$pid);
$this->assertFalse($result);
// define('e_CURRENT_PLUGIN', 'gallery');
$result = getperms('P', 'P'.$pid);
$result = getperms('P', 'P'.$pid, 'http://localhost/e107v2/e107_plugins/gallery/admin_config.php');
$this->assertTrue($result);
*/
}

View File

@@ -461,9 +461,10 @@
{
// $this->fixRegistry('before');
e107::getUserExt()->init();
$sc = e107::getScBatch('signup');
$template = array(
'extended-category' => "-- {EXTENDED_CAT_TEXT} --",
'extended-user-fields' => "<label>{EXTENDED_USER_FIELD_TEXT}{EXTENDED_USER_FIELD_REQUIRED}</label>" // {EXTENDED_USER_FIELD_EDIT}