Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 97... Línea 97...
97
     * @param mixed $configkey SEB config key.
97
     * @param mixed $configkey SEB config key.
98
     * @param mixed $messageregex Error message regex to check.
98
     * @param mixed $messageregex Error message regex to check.
99
     *
99
     *
100
     * @dataProvider bad_parameters_provider
100
     * @dataProvider bad_parameters_provider
101
     */
101
     */
102
    public function test_invalid_parameters($cmid, $url, $configkey, $messageregex) {
102
    public function test_invalid_parameters($cmid, $url, $configkey, $messageregex): void {
103
        $params = [];
103
        $params = [];
104
        if (!empty($cmid)) {
104
        if (!empty($cmid)) {
105
            $params['cmid'] = $cmid;
105
            $params['cmid'] = $cmid;
106
        }
106
        }
107
        if (!empty($url)) {
107
        if (!empty($url)) {
Línea 117... Línea 117...
117
    }
117
    }
Línea 118... Línea 118...
118
 
118
 
119
    /**
119
    /**
120
     * Test that the user has permissions to access context.
120
     * Test that the user has permissions to access context.
121
     */
121
     */
122
    public function test_context_is_not_valid_for_user() {
122
    public function test_context_is_not_valid_for_user(): void {
123
        // Set user as user not enrolled in course and quiz.
123
        // Set user as user not enrolled in course and quiz.
124
        $this->user = $this->getDataGenerator()->create_user();
124
        $this->user = $this->getDataGenerator()->create_user();
Línea 125... Línea 125...
125
        $this->setUser($this->user);
125
        $this->setUser($this->user);
Línea 130... Línea 130...
130
    }
130
    }
Línea 131... Línea 131...
131
 
131
 
132
    /**
132
    /**
133
     * Test exception thrown when no key provided.
133
     * Test exception thrown when no key provided.
134
     */
134
     */
135
    public function test_no_keys_provided() {
135
    public function test_no_keys_provided(): void {
136
        $this->expectException(\invalid_parameter_exception::class);
136
        $this->expectException(\invalid_parameter_exception::class);
137
        $this->expectExceptionMessage('At least one Safe Exam Browser key must be provided.');
137
        $this->expectExceptionMessage('At least one Safe Exam Browser key must be provided.');
138
        validate_quiz_keys::execute($this->quiz->cmid, 'https://www.example.com/moodle');
138
        validate_quiz_keys::execute($this->quiz->cmid, 'https://www.example.com/moodle');
Línea 139... Línea 139...
139
    }
139
    }
140
 
140
 
141
    /**
141
    /**
142
     * Test exception thrown if cmid doesn't match a quiz.
142
     * Test exception thrown if cmid doesn't match a quiz.
143
     */
143
     */
144
    public function test_quiz_does_not_exist() {
144
    public function test_quiz_does_not_exist(): void {
145
        $this->setAdminUser();
145
        $this->setAdminUser();
146
        $forum = $this->getDataGenerator()->create_module('forum', ['course' => $this->course->id]);
146
        $forum = $this->getDataGenerator()->create_module('forum', ['course' => $this->course->id]);
147
        $this->expectException(\invalid_parameter_exception::class);
147
        $this->expectException(\invalid_parameter_exception::class);
148
        $this->expectExceptionMessage('Quiz not found matching course module ID: ' . $forum->cmid);
148
        $this->expectExceptionMessage('Quiz not found matching course module ID: ' . $forum->cmid);
Línea 149... Línea 149...
149
        validate_quiz_keys::execute($forum->cmid, 'https://www.example.com/moodle', 'configkey');
149
        validate_quiz_keys::execute($forum->cmid, 'https://www.example.com/moodle', 'configkey');
150
    }
150
    }
151
 
151
 
152
    /**
152
    /**
153
     * Test config key is valid.
153
     * Test config key is valid.
154
     */
154
     */
155
    public function test_config_key_valid() {
155
    public function test_config_key_valid(): void {
156
        $sink = $this->redirectEvents();
156
        $sink = $this->redirectEvents();
157
        // Test settings to populate the quiz.
157
        // Test settings to populate the quiz.
Línea 175... Línea 175...
175
    }
175
    }
Línea 176... Línea 176...
176
 
176
 
177
    /**
177
    /**
178
     * Test config key is not valid.
178
     * Test config key is not valid.
179
     */
179
     */
180
    public function test_config_key_not_valid() {
180
    public function test_config_key_not_valid(): void {
181
        $sink = $this->redirectEvents();
181
        $sink = $this->redirectEvents();
182
        // Test settings to populate the quiz.
182
        // Test settings to populate the quiz.
183
        $settings = $this->get_test_settings([
183
        $settings = $this->get_test_settings([
184
            'quizid' => $this->quiz->id,
184
            'quizid' => $this->quiz->id,
Línea 200... Línea 200...
200
    }
200
    }
Línea 201... Línea 201...
201
 
201
 
202
    /**
202
    /**
203
     * Test browser exam key is valid.
203
     * Test browser exam key is valid.
204
     */
204
     */
205
    public function test_browser_exam_key_valid() {
205
    public function test_browser_exam_key_valid(): void {
206
        $sink = $this->redirectEvents();
206
        $sink = $this->redirectEvents();
207
        // Test settings to populate the quiz.
207
        // Test settings to populate the quiz.
208
        $url = 'https://www.example.com/moodle';
208
        $url = 'https://www.example.com/moodle';
209
        $validbrowserexamkey = hash('sha256', 'validbrowserexamkey');
209
        $validbrowserexamkey = hash('sha256', 'validbrowserexamkey');
Línea 227... Línea 227...
227
    }
227
    }
Línea 228... Línea 228...
228
 
228
 
229
    /**
229
    /**
230
     * Test browser exam key is not valid.
230
     * Test browser exam key is not valid.
231
     */
231
     */
232
    public function test_browser_exam_key_not_valid() {
232
    public function test_browser_exam_key_not_valid(): void {
233
        $sink = $this->redirectEvents();
233
        $sink = $this->redirectEvents();
234
        // Test settings to populate the quiz.
234
        // Test settings to populate the quiz.
235
        $validbrowserexamkey = hash('sha256', 'validbrowserexamkey');
235
        $validbrowserexamkey = hash('sha256', 'validbrowserexamkey');
236
        $settings = $this->get_test_settings([
236
        $settings = $this->get_test_settings([