Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 33... Línea 33...
33
 * @category   test
33
 * @category   test
34
 * @copyright  2020 Ferran Recio <ferran@moodle.com>
34
 * @copyright  2020 Ferran Recio <ferran@moodle.com>
35
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 * @covers     \mod_h5pactivity\xapi\handler
36
 * @covers     \mod_h5pactivity\xapi\handler
37
 */
37
 */
38
class handler_test extends \advanced_testcase {
38
final class handler_test extends \advanced_testcase {
Línea 39... Línea 39...
39
 
39
 
40
    /**
40
    /**
41
     * Setup to ensure that fixtures are loaded.
41
     * Setup to ensure that fixtures are loaded.
42
     */
42
     */
Línea 77... Línea 77...
77
    }
77
    }
Línea 78... Línea 78...
78
 
78
 
79
    /**
79
    /**
80
     * Test for xapi_handler with valid statements.
80
     * Test for xapi_handler with valid statements.
81
     */
81
     */
82
    public function test_xapi_handler() {
82
    public function test_xapi_handler(): void {
Línea 83... Línea 83...
83
        global $DB;
83
        global $DB;
84
 
84
 
85
        $data = $this->generate_testing_scenario();
85
        $data = $this->generate_testing_scenario();
Línea 139... Línea 139...
139
     * @param bool $hascontext valid context
139
     * @param bool $hascontext valid context
140
     * @param bool $hasuser valid user
140
     * @param bool $hasuser valid user
141
     * @param bool $generateattempt if generates an empty attempt
141
     * @param bool $generateattempt if generates an empty attempt
142
     */
142
     */
143
    public function test_xapi_handler_errors(bool $hasverb, bool $hasdefinition, bool $hasresult,
143
    public function test_xapi_handler_errors(bool $hasverb, bool $hasdefinition, bool $hasresult,
144
            bool $hascontext, bool $hasuser, bool $generateattempt) {
144
            bool $hascontext, bool $hasuser, bool $generateattempt): void {
145
        global $DB, $CFG;
145
        global $DB, $CFG;
Línea 146... Línea 146...
146
 
146
 
147
        $data = $this->generate_testing_scenario();
147
        $data = $this->generate_testing_scenario();
148
        $xapihandler = $data->xapihandler;
148
        $xapihandler = $data->xapihandler;
Línea 200... Línea 200...
200
    /**
200
    /**
201
     * Data provider for data request creation tests.
201
     * Data provider for data request creation tests.
202
     *
202
     *
203
     * @return array
203
     * @return array
204
     */
204
     */
205
    public function xapi_handler_errors_data(): array {
205
    public static function xapi_handler_errors_data(): array {
206
        return [
206
        return [
207
            // Invalid Definitions and results possibilities.
207
            // Invalid Definitions and results possibilities.
208
            'Invalid definition and result' => [
208
            'Invalid definition and result' => [
209
                true, false, false, true, true, false
209
                true, false, false, true, true, false
210
            ],
210
            ],
Línea 219... Línea 219...
219
                false, false, false, true, true, false
219
                false, false, false, true, true, false
220
            ],
220
            ],
221
            'Invalid verb and result' => [
221
            'Invalid verb and result' => [
222
                false, true, false, true, true, false
222
                false, true, false, true, true, false
223
            ],
223
            ],
224
            'Invalid verb and result' => [
224
            'Invalid verb and definition' => [
225
                false, false, true, true, true, false
225
                false, false, true, true, true, false
226
            ],
226
            ],
227
            // Invalid context possibilities.
227
            // Invalid context possibilities.
228
            'Invalid definition, result and context' => [
228
            'Invalid definition, result and context' => [
229
                true, false, false, false, true, false
229
                true, false, false, false, true, false
230
            ],
230
            ],
231
            'Invalid result' => [
231
            'Invalid result and context' => [
232
                true, true, false, false, true, false
232
                true, true, false, false, true, false
233
            ],
233
            ],
234
            'Invalid result and context' => [
234
            'Invalid definition and context' => [
235
                true, false, true, false, true, false
235
                true, false, true, false, true, false
236
            ],
236
            ],
237
            'Invalid verb, definition result and context' => [
237
            'Invalid verb, definition result and context' => [
238
                false, false, false, false, true, false
238
                false, false, false, false, true, false
239
            ],
239
            ],
240
            'Invalid verb, result and context' => [
240
            'Invalid verb, result and context' => [
241
                false, true, false, false, true, false
241
                false, true, false, false, true, false
242
            ],
242
            ],
243
            'Invalid verb, result and context' => [
243
            'Invalid verb, definition and context' => [
244
                false, false, true, false, true, false
244
                false, false, true, false, true, false
245
            ],
245
            ],
246
            // Invalid user possibilities.
246
            // Invalid user possibilities.
247
            'Invalid definition, result and user' => [
247
            'Invalid definition, result and user' => [
248
                true, false, false, true, false, false
248
                true, false, false, true, false, false
Línea 257... Línea 257...
257
                false, false, false, true, false, false
257
                false, false, false, true, false, false
258
            ],
258
            ],
259
            'Invalid verb, result and user' => [
259
            'Invalid verb, result and user' => [
260
                false, true, false, true, false, false
260
                false, true, false, true, false, false
261
            ],
261
            ],
262
            'Invalid verb, result and user' => [
262
            'Invalid verb, definition and user' => [
263
                false, false, true, true, false, false
263
                false, false, true, true, false, false
264
            ],
264
            ],
265
            'Invalid definition, result, context and user' => [
265
            'Invalid definition, result, context and user' => [
266
                true, false, false, false, false, false
266
                true, false, false, false, false, false
267
            ],
267
            ],
Línea 275... Línea 275...
275
                false, false, false, false, false, false
275
                false, false, false, false, false, false
276
            ],
276
            ],
277
            'Invalid verb, result, context and user' => [
277
            'Invalid verb, result, context and user' => [
278
                false, true, false, false, false, false
278
                false, true, false, false, false, false
279
            ],
279
            ],
280
            'Invalid verb, result, context and user' => [
280
            'Invalid verb, definition, context and user' => [
281
                false, false, true, false, false, false
281
                false, false, true, false, false, false
282
            ],
282
            ],
283
        ];
283
        ];
284
    }
284
    }
Línea 285... Línea 285...
285
 
285
 
286
    /**
286
    /**
287
     * Test xapi_handler stored statements.
287
     * Test xapi_handler stored statements.
288
     */
288
     */
289
    public function test_stored_statements() {
289
    public function test_stored_statements(): void {
Línea 290... Línea 290...
290
        global $DB;
290
        global $DB;
291
 
291
 
292
        $data = $this->generate_testing_scenario();
292
        $data = $this->generate_testing_scenario();