Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 21... Línea 21...
21
 *
21
 *
22
 * @package    core
22
 * @package    core
23
 * @copyright  2015 Jetha Chan <jetha@moodle.com>
23
 * @copyright  2015 Jetha Chan <jetha@moodle.com>
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
25
 */
26
class user_menu_test extends \advanced_testcase {
26
final class user_menu_test extends \advanced_testcase {
Línea 27... Línea 27...
27
 
27
 
28
    /**
28
    /**
29
     * Custom user menu data for the test_custom_user_menu test.
29
     * Custom user menu data for the test_custom_user_menu test.
30
     *
30
     *
31
     * @return array containing testing data
31
     * @return array containing testing data
32
     */
32
     */
33
    public function custom_user_menu_data() {
33
    public static function custom_user_menu_data(): array {
34
        return array(
34
        return array(
35
            // These are fillers only.
35
            // These are fillers only.
36
            array('###', 0, 1),
36
            array('###', 0, 1),
Línea 90... Línea 90...
90
        $PAGE->set_url('/');
90
        $PAGE->set_url('/');
91
        $CFG->theme = 'classic';
91
        $CFG->theme = 'classic';
92
        $PAGE->reset_theme_and_output();
92
        $PAGE->reset_theme_and_output();
93
        $PAGE->initialise_theme_and_output();
93
        $PAGE->initialise_theme_and_output();
Línea -... Línea 94...
-
 
94
 
-
 
95
        // Empty the custom user menu items.
-
 
96
        // This should only contain default items and items added by extend_user_menu.
-
 
97
        set_config('customusermenuitems', '');
-
 
98
 
-
 
99
        // Default menu items.
-
 
100
        $defaultmenu = $OUTPUT->user_menu($USER);
-
 
101
 
-
 
102
        // Count the number of entries and dividers in the default menu.
-
 
103
        preg_match_all('/<a [^>]+role="menuitem"[^>]+>/', $defaultmenu, $results);
-
 
104
        $defaultentrycount = count($results[0]);
-
 
105
        preg_match_all('/<span class="filler">/', $defaultmenu, $results);
-
 
106
        $defaultdividercount = count($results[0]);
94
 
107
 
95
        // Set the configuration.
108
        // Set the configuration.
Línea 96... Línea 109...
96
        set_config('customusermenuitems', $data);
109
        set_config('customusermenuitems', $data);
97
 
110
 
Línea 98... Línea 111...
98
        // We always add two dividers as standard.
111
        // We always add two dividers as standard.
99
        $dividercount += 2;
112
        $dividercount += $defaultdividercount;
Línea 100... Línea 113...
100
 
113
 
101
        // The basic entry count will additionally include the wrapper menu, Preferences, Logout and switch roles link.
114
        // The basic entry count will additionally include the wrapper menu, Preferences, Logout and switch roles link.
102
        $entrycount += 3;
115
        $entrycount += $defaultentrycount;