Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 22... Línea 22...
22
 * @package core
22
 * @package core
23
 * @copyright 2014 The Open University
23
 * @copyright 2014 The Open University
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
 * @covers \core_user\fields
25
 * @covers \core_user\fields
26
 */
26
 */
27
class fields_test extends \advanced_testcase {
27
final class fields_test extends \advanced_testcase {
Línea 28... Línea 28...
28
 
28
 
29
    /**
29
    /**
30
     * Tests getting the user picture fields.
30
     * Tests getting the user picture fields.
31
     */
31
     */
Línea 102... Línea 102...
102
        $this->setUser($user);
102
        $this->setUser($user);
103
        $this->assertEquals([], fields::get_identity_fields($coursecontext));
103
        $this->assertEquals([], fields::get_identity_fields($coursecontext));
Línea 104... Línea 104...
104
 
104
 
105
        // Give the student the basic identity fields permission (also makes them count as 'teacher'
105
        // Give the student the basic identity fields permission (also makes them count as 'teacher'
106
        // for the teacher-restricted field).
-
 
107
        $COURSE = $course; // Horrible hack, because PROFILE_VISIBLE_TEACHERS relies on this global.
106
        // for the teacher-restricted field).
108
        $roleid = $DB->get_field('role', 'id', ['shortname' => 'student']);
107
        $roleid = $DB->get_field('role', 'id', ['shortname' => 'student']);
109
        role_change_permission($roleid, $coursecontext, 'moodle/site:viewuseridentity', CAP_ALLOW);
108
        role_change_permission($roleid, $coursecontext, 'moodle/site:viewuseridentity', CAP_ALLOW);
110
        $this->assertEquals(['department', 'profile_field_a', 'profile_field_d'],
109
        $this->assertEquals(['department', 'profile_field_a', 'profile_field_d'],
111
                fields::get_identity_fields($coursecontext));
110
                fields::get_identity_fields($coursecontext));
Línea 130... Línea 129...
130
        // Even if we give them student role in the user context they can't view anything...
129
        // Even if we give them student role in the user context they can't view anything...
131
        $generator->role_assign($roleid, $user->id, $usercontext->id);
130
        $generator->role_assign($roleid, $user->id, $usercontext->id);
132
        $this->assertEquals([], fields::get_identity_fields($usercontext));
131
        $this->assertEquals([], fields::get_identity_fields($usercontext));
Línea 133... Línea 132...
133
 
132
 
-
 
133
        // Give them basic permission.
134
        // Give them basic permission.
134
        $COURSE = $course; // Horrible hack, because PROFILE_VISIBLE_TEACHERS relies on this global.
135
        role_change_permission($roleid, $usercontext, 'moodle/site:viewuseridentity', CAP_ALLOW);
135
        role_change_permission($roleid, $usercontext, 'moodle/site:viewuseridentity', CAP_ALLOW);
136
        $this->assertEquals(['department', 'profile_field_a', 'profile_field_d'],
136
        $this->assertEquals(['department', 'profile_field_a', 'profile_field_d'],
137
                fields::get_identity_fields($usercontext));
137
                fields::get_identity_fields($usercontext));
138
        $this->assertEquals(['department'],
138
        $this->assertEquals(['department'],
Línea 547... Línea 547...
547
    /**
547
    /**
548
     * Data provider for {@see test_get_sql_fullname}
548
     * Data provider for {@see test_get_sql_fullname}
549
     *
549
     *
550
     * @return array
550
     * @return array
551
     */
551
     */
552
    public function get_sql_fullname_provider(): array {
552
    public static function get_sql_fullname_provider(): array {
553
        return [
553
        return [
554
            ['firstname lastname', 'FN LN'],
554
            ['firstname lastname', 'FN LN'],
555
            ['lastname, firstname', 'LN, FN'],
555
            ['lastname, firstname', 'LN, FN'],
556
            ['alternatename \'middlename\' lastname!', 'AN \'MN\' LN!'],
556
            ['alternatename \'middlename\' lastname!', 'AN \'MN\' LN!'],
557
            ['[firstname lastname alternatename]', '[FN LN AN]'],
557
            ['[firstname lastname alternatename]', '[FN LN AN]'],