Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 25... Línea 25...
25
 * @category   test
25
 * @category   test
26
 * @copyright  2023 Stevani Andolo <stevani.andolo@moodle.com>
26
 * @copyright  2023 Stevani Andolo <stevani.andolo@moodle.com>
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 * @covers \communication_matrix\matrix_user_manager
28
 * @covers \communication_matrix\matrix_user_manager
29
 */
29
 */
30
class matrix_user_manager_test extends \advanced_testcase {
30
final class matrix_user_manager_test extends \advanced_testcase {
31
    /**
31
    /**
32
     * Test fetcihing a users matrix userid from Moodle.
32
     * Test fetcihing a users matrix userid from Moodle.
33
     */
33
     */
34
    public function test_get_matrixid_from_moodle_without_field(): void {
34
    public function test_get_matrixid_from_moodle_without_field(): void {
35
        $user = get_admin();
35
        $user = get_admin();
Línea 84... Línea 84...
84
     * @param string $server
84
     * @param string $server
85
     * @param string $username The moodle username to turn into a Matrix username
85
     * @param string $username The moodle username to turn into a Matrix username
86
     * @param string $expecteduserid The expected matrix user id
86
     * @param string $expecteduserid The expected matrix user id
87
     */
87
     */
88
    public function test_get_formatted_matrix_userid(
88
    public function test_get_formatted_matrix_userid(
-
 
89
        ?string $servername,
89
        string $server,
90
        string $server,
90
        string $username,
91
        string $username,
91
        string $expecteduserid,
92
        string $expecteduserid,
92
    ): void {
93
    ): void {
93
        $this->resetAfterTest();
94
        $this->resetAfterTest();
94
 
-
 
-
 
95
        set_config('matrixhomeservername', $servername, 'communication_matrix');
95
        set_config('matrixhomeserverurl', $server, 'communication_matrix');
96
        set_config('matrixhomeserverurl', $server, 'communication_matrix');
96
        $this->assertEquals(
97
        $this->assertEquals(
97
            $expecteduserid,
98
            $expecteduserid,
98
            matrix_user_manager::get_formatted_matrix_userid($username),
99
            matrix_user_manager::get_formatted_matrix_userid($username),
99
        );
100
        );
Línea 104... Línea 105...
104
     *
105
     *
105
     * @return array
106
     * @return array
106
     */
107
     */
107
    public static function get_formatted_matrix_userid_provider(): array {
108
    public static function get_formatted_matrix_userid_provider(): array {
108
        return [
109
        return [
-
 
110
            'servername' => [
-
 
111
                'example.org',
-
 
112
                'https://matrix.example.org',
-
 
113
                'user',
-
 
114
                '@user:example.org',
-
 
115
            ],
-
 
116
            'servername empty string' => [
-
 
117
                '',
-
 
118
                'https://matrix.example.org',
-
 
119
                'user',
-
 
120
                '@user:matrix.example.org',
-
 
121
            ],
109
            'alphanumeric' => [
122
            'alphanumeric' => [
-
 
123
                null,
110
                'https://matrix.example.org',
124
                'https://matrix.example.org',
111
                'alphabet1',
125
                'alphabet1',
112
                '@alphabet1:matrix.example.org',
126
                '@alphabet1:matrix.example.org',
113
            ],
127
            ],
114
            'chara' => [
128
            'chara' => [
-
 
129
                null,
115
                'https://matrix.example.org',
130
                'https://matrix.example.org',
116
                'asdf#$%^&*()+{}|<>?!,asdf',
131
                'asdf#$%^&*()+{}|<>?!,asdf',
117
                '@asdf.................asdf:matrix.example.org',
132
                '@asdf.................asdf:matrix.example.org',
118
            ],
133
            ],
119
            'local server' => [
134
            'local server' => [
-
 
135
                null,
120
                'https://synapse',
136
                'https://synapse',
121
                'colin.creavey',
137
                'colin.creavey',
122
                '@colin.creavey:synapse',
138
                '@colin.creavey:synapse',
123
            ],
139
            ],
124
            'server with port' => [
140
            'server with port' => [
-
 
141
                null,
125
                'https://matrix.example.org:8448',
142
                'https://matrix.example.org:8448',
126
                'colin.creavey',
143
                'colin.creavey',
127
                '@colin.creavey:matrix.example.org',
144
                '@colin.creavey:matrix.example.org',
128
            ],
145
            ],
129
            'numeric username' => [
146
            'numeric username' => [
-
 
147
                null,
130
                'https://matrix.example.org',
148
                'https://matrix.example.org',
131
                '123456',
149
                '123456',
132
                '@' . matrix_user_manager::MATRIX_USER_PREFIX . '123456:matrix.example.org',
150
                '@' . matrix_user_manager::MATRIX_USER_PREFIX . '123456:matrix.example.org',
133
            ],
151
            ],
134
        ];
152
        ];