See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Tests for gradereport_user library functions. 19 * 20 * @package gradereport_user 21 * @copyright 2015 onwards Ankit agarwal <ankit.agrr@gmail.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 global $CFG; 28 require_once($CFG->dirroot . '/grade/report/user/lib.php'); 29 30 /** 31 * Class gradereport_user_lib_testcase. 32 * 33 * @package gradereport_user 34 * @copyright 2015 onwards Ankit agarwal <ankit.agrr@gmail.com> 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. 36 */ 37 class gradereport_user_lib_testcase extends advanced_testcase { 38 39 /** 40 * @var stdClass The user. 41 */ 42 private $user; 43 44 /** 45 * @var stdClass The course. 46 */ 47 private $course; 48 49 /** 50 * @var \core_user\output\myprofile\tree The navigation tree. 51 */ 52 private $tree; 53 54 public function setUp() { 55 $this->user = $this->getDataGenerator()->create_user(); 56 $this->course = $this->getDataGenerator()->create_course(); 57 $this->tree = new \core_user\output\myprofile\tree(); 58 $this->resetAfterTest(); 59 } 60 61 /** 62 * Tests the gradereport_user_myprofile_navigation() function. 63 */ 64 public function test_gradereport_user_myprofile_navigation() { 65 $this->setAdminUser(); 66 $iscurrentuser = false; 67 68 gradereport_user_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course); 69 $reflector = new ReflectionObject($this->tree); 70 $nodes = $reflector->getProperty('nodes'); 71 $nodes->setAccessible(true); 72 $this->assertArrayHasKey('grade', $nodes->getValue($this->tree)); 73 } 74 75 /** 76 * Tests the gradereport_user_myprofile_navigation() function for a user 77 * without permission to view the grade node. 78 */ 79 public function test_gradereport_user_myprofile_navigation_without_permission() { 80 $this->setUser($this->user); 81 $iscurrentuser = true; 82 83 gradereport_user_myprofile_navigation($this->tree, $this->user, $iscurrentuser, $this->course); 84 $reflector = new ReflectionObject($this->tree); 85 $nodes = $reflector->getProperty('nodes'); 86 $nodes->setAccessible(true); 87 $this->assertArrayNotHasKey('grade', $nodes->getValue($this->tree)); 88 } 89 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body