123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <?php
- require_once api_get_path(SYS_CODE_PATH).'permissions/permissions_functions.inc.php';
- class TestPermissions extends UnitTestCase {
- public function __construct() {
- $this->UnitTestCase('Permissions library - main/permissions/permissions_functions.inc.test.php');
- }
-
- function testAssignRole(){
- $content='';
- $action='';
- $id=1;
- $role_id=1;
- $scope='course';
- $res = assign_role($content, $action, $id, $role_id, $scope);
- $this->assertTrue(is_string($res));
-
- }
-
- function testDisplayCheckboxMatrix(){
- ob_start();
- $permission_array=array();
- $tool='';
- $permission=1;
- $inherited_permissions=array();
- $res = display_checkbox_matrix($permission_array, $tool, $permission, $inherited_permissions);
- $this->assertTrue(is_null($res));
- ob_end_clean();
-
- }
-
- function testDisplayImageMatrix(){
-
- $permission_array=array();
- $tool=1;
- $permission=1;
- $inherited_permissions=array($tool => array());
- $course_admin=false;
- $editable=true;
- $res = display_image_matrix($permission_array, $tool, $permission,$inherited_permissions, $course_admin, $editable);
- $this->assertTrue(is_null($res));
-
-
- }
-
- function testDisplayImageMatrixForBlogs(){
- $permission_array=array();
- $user_id=1;
- $tool=1;
- $permission=1;
- $inherited_permissions=array();
- $course_admin=false;
- $editable=true;
- $res = display_image_matrix_for_blogs($permission_array, $user_id, $tool, $permission,$inherited_permissions, $course_admin, $editable);
- $this->assertTrue(is_null($res));
-
- }
-
- function testDisplayRoleList(){
- $current_course_roles='';
- $current_platform_roles='';
- $res = display_role_list($current_course_roles, $current_platform_roles);
- $this->assertTrue(is_null($res));
-
- }
-
- function testGetAllRoles(){
- $content='course';
- $res = get_all_roles($content);
- if (!is_null($res)){
- $this->assertTrue(is_array($res));
- }
-
- }
-
- function testGetPermissions(){
- $content='user';
- $id=1;
- $res = get_permissions($content, $id);
- $this->assertTrue(is_array($res));
-
- }
-
- function testGetRoles(){
- $content='user';
- $id=1;
- $scope='course';
- $res = get_roles($content, $id, $scope);
- $this->assertTrue(is_array($res));
-
- }
-
- function testGetRolesPermissions(){
- $content='user';
- $id=1;
- $scope='course';
- $res = get_roles_permissions($content, $id, $scope);
- if (!is_null($res)){
- $this->assertTrue(is_array($res));
- }
-
- }
-
- function testLimitedOrFull(){
- $current_permissions=array();
- $res = limited_or_full($current_permissions);
- if (!is_null($res)){
- $this->assertTrue(is_array($res));
- }
-
- }
- function testMyPrintR(){
- ob_start();
- $array='';
- $res = my_print_r($array);
- $this->assertTrue(is_null($res));
- ob_end_clean();
-
- }
-
- function testPermissionArrayMerge(){
- $array1=array();
- $array2=array();
- $res = permission_array_merge($array1, $array2);
- $this->assertTrue(is_array($res));
-
- }
-
- function testStoreOnePermission(){
- $res = store_one_permission('user', 'grant', 2, 'link','');
- if(!$res === NULL){
- $this->assertTrue(is_string($res));
- } else {
- $this->assertNull($res);
- }
-
- }
-
- function testStorePermissions(){
- $content='user';
- $id=1;
- $res = store_permissions($content, $id);
- $this->assertTrue(is_string($res));
-
- }
- }
- ?>
|