diff --git a/class2.php b/class2.php index 083c23421..9fb248221 100755 --- a/class2.php +++ b/class2.php @@ -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(); diff --git a/e107_tests/tests/unit/class2Test.php b/e107_tests/tests/unit/class2Test.php index e8b91dc7a..f16a266d9 100644 --- a/e107_tests/tests/unit/class2Test.php +++ b/e107_tests/tests/unit/class2Test.php @@ -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); -*/ + } diff --git a/e107_tests/tests/unit/e107_user_extendedTest.php b/e107_tests/tests/unit/e107_user_extendedTest.php index fdccd5c0f..7e37b1667 100644 --- a/e107_tests/tests/unit/e107_user_extendedTest.php +++ b/e107_tests/tests/unit/e107_user_extendedTest.php @@ -461,9 +461,10 @@ { // $this->fixRegistry('before'); - + e107::getUserExt()->init(); $sc = e107::getScBatch('signup'); + $template = array( 'extended-category' => "-- {EXTENDED_CAT_TEXT} --", 'extended-user-fields' => "" // {EXTENDED_USER_FIELD_EDIT}