Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 37... Línea 37...
37
 * @covers     \core_xapi\external\delete_states
37
 * @covers     \core_xapi\external\delete_states
38
 * @since      Moodle 4.3
38
 * @since      Moodle 4.3
39
 * @copyright  2023 Laurent David <laurent.david@moodle.com>
39
 * @copyright  2023 Laurent David <laurent.david@moodle.com>
40
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
41
 */
41
 */
42
class delete_states_test extends externallib_advanced_testcase {
42
final class delete_states_test extends externallib_advanced_testcase {
Línea 43... Línea 43...
43
 
43
 
44
    /**
44
    /**
45
     * Setup to ensure that fixtures are loaded.
45
     * Setup to ensure that fixtures are loaded.
46
     */
46
     */
47
    public static function setUpBeforeClass(): void {
47
    public static function setUpBeforeClass(): void {
48
        global $CFG;
48
        global $CFG;
-
 
49
        require_once($CFG->dirroot . '/lib/xapi/tests/helper.php');
49
        require_once($CFG->dirroot . '/lib/xapi/tests/helper.php');
50
        parent::setUpBeforeClass();
Línea 50... Línea 51...
50
    }
51
    }
51
 
52
 
52
    /**
53
    /**
Línea 133... Línea 134...
133
    /**
134
    /**
134
     * Data provider for the test_component_names tests.
135
     * Data provider for the test_component_names tests.
135
     *
136
     *
136
     * @return  array
137
     * @return  array
137
     */
138
     */
138
    public function components_provider(): array {
139
    public static function components_provider(): array {
139
        return [
140
        return [
140
            'Inexistent component' => [
141
            'Inexistent component' => [
141
                'component' => 'inexistent_component',
142
                'component' => 'inexistent_component',
142
                'expected' => (object) ['exception' => xapi_exception::class],
143
                'expected' => (object) ['exception' => xapi_exception::class],
143
            ],
144
            ],
Línea 186... Línea 187...
186
     * @param string $testedactivityname
187
     * @param string $testedactivityname
187
     * @param array $states
188
     * @param array $states
188
     * @param array $expectedstates
189
     * @param array $expectedstates
189
     * @return void
190
     * @return void
190
     */
191
     */
191
    public function test_delete_states(string $testedusername,
192
    public function test_delete_states(
-
 
193
        string $testedusername,
192
        string $testedcomponent,
194
        string $testedcomponent,
193
        string $testedactivityname,
195
        string $testedactivityname,
194
        array $states,
196
        array $states,
195
        array $expectedstates
197
        array $expectedstates
196
    ): void {
198
    ): void {
Línea 261... Línea 263...
261
    /**
263
    /**
262
     * Data provider for the test_get_state tests.
264
     * Data provider for the test_get_state tests.
263
     *
265
     *
264
     * @return array
266
     * @return array
265
     */
267
     */
266
    public function states_provider(): array {
268
    public static function states_provider(): array {
267
        return [
269
        return [
268
            'Activities with different users and components' => [
270
            'Activities with different users and components' => [
269
                'username' => 'user1',
271
                'testedusername' => 'user1',
270
                'component' => 'mod_h5pactivity',
272
                'testedcomponent' => 'mod_h5pactivity',
271
                'activity' => 'Activity 1',
273
                'testedactivityname' => 'Activity 1',
272
                'states' => [
274
                'states' => [
273
                    [
275
                    [
274
                        'user' => 'user1',
276
                        'user' => 'user1',
275
                        'activity' => 'Activity 1',
277
                        'activity' => 'Activity 1',
276
                        'component' => 'mod_h5pactivity'
278
                        'component' => 'mod_h5pactivity'
Línea 290... Línea 292...
290
                        'user' => 'user1',
292
                        'user' => 'user1',
291
                        'activity' => 'Activity 1',
293
                        'activity' => 'Activity 1',
292
                        'component' => 'mod_h5pactivity'
294
                        'component' => 'mod_h5pactivity'
293
                    ],
295
                    ],
294
                ],
296
                ],
295
                'expectedstatesleft' => [
297
                'expectedstates' => [
296
                    ['user' => 'user2', 'activity' => 'Activity 1'],
298
                    ['user' => 'user2', 'activity' => 'Activity 1'],
297
                    ['user' => 'user1', 'activity' => 'Activity 3']
299
                    ['user' => 'user1', 'activity' => 'Activity 3']
298
                ]
300
                ]
299
            ],
301
            ],
300
            'Activities with one single user' => [
302
            'Activities with one single user' => [
301
                'username' => 'user1',
303
                'testedusername' => 'user1',
302
                'component' => 'mod_h5pactivity',
304
                'testedcomponent' => 'mod_h5pactivity',
303
                'activity' => 'Activity 1',
305
                'testedactivityname' => 'Activity 1',
304
                'states' => [
306
                'states' => [
305
                    [
307
                    [
306
                        'user' => 'user1',
308
                        'user' => 'user1',
307
                        'activity' => 'Activity 1',
309
                        'activity' => 'Activity 1',
308
                        'component' => 'mod_h5pactivity'
310
                        'component' => 'mod_h5pactivity'
Línea 316... Línea 318...
316
                        'user' => 'user1',
318
                        'user' => 'user1',
317
                        'activity' => 'Activity 1',
319
                        'activity' => 'Activity 1',
318
                        'component' => 'mod_h5pactivity'
320
                        'component' => 'mod_h5pactivity'
319
                    ],
321
                    ],
320
                ],
322
                ],
321
                'expectedstatesleft' => []
323
                'expectedstates' => []
322
            ],
324
            ],
323
        ];
325
        ];
324
    }
326
    }
325
}
327
}