Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 28... Línea 28...
28
 *
28
 *
29
 * @package   core_completion
29
 * @package   core_completion
30
 * @copyright 2021 Jun Pataleta <jun@moodle.com>
30
 * @copyright 2021 Jun Pataleta <jun@moodle.com>
31
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32
 */
32
 */
33
class activity_custom_completion_test extends advanced_testcase {
33
final class activity_custom_completion_test extends advanced_testcase {
Línea 34... Línea 34...
34
 
34
 
35
    /**
35
    /**
36
     * Fetches a mocked activity_custom_completion instance.
36
     * Fetches a mocked activity_custom_completion instance.
37
     *
37
     *
Línea 46... Línea 46...
46
    }
46
    }
Línea 47... Línea 47...
47
 
47
 
48
    /**
48
    /**
49
     * Data provider for test_get_overall_completion_state().
49
     * Data provider for test_get_overall_completion_state().
50
     */
50
     */
51
    public function overall_completion_state_provider(): array {
51
    public static function overall_completion_state_provider(): array {
52
        global $CFG;
52
        global $CFG;
53
        require_once($CFG->libdir . '/completionlib.php');
53
        require_once($CFG->libdir . '/completionlib.php');
54
        return [
54
        return [
55
            'First incomplete, second complete' => [
55
            'First incomplete, second complete' => [
Línea 111... Línea 111...
111
            ->method('get_available_custom_rules')
111
            ->method('get_available_custom_rules')
112
            ->willReturn($rules);
112
            ->willReturn($rules);
Línea 113... Línea 113...
113
 
113
 
114
        // Mock activity_custom_completion's get_state() method.
114
        // Mock activity_custom_completion's get_state() method.
115
        if ($invokecount > 0) {
115
        if ($invokecount > 0) {
-
 
116
            $stateinvocations = $this->exactly($invokecount);
116
            $stub->expects($this->exactly($invokecount))
117
            $stub->expects($stateinvocations)
-
 
118
                ->method('get_state')
117
                ->method('get_state')
119
                ->willReturnCallback(function ($rule) use ($stateinvocations, $rules, $rulestates) {
118
                ->withConsecutive(
120
                    $index = self::getInvocationCount($stateinvocations) - 1;
119
                    [$rules[0]],
121
                    $this->assertEquals($rules[$index], $rule);
120
                    [$rules[1]]
122
                    return $rulestates[$index];
121
                )
-
 
122
                ->willReturn($rulestates[0], $rulestates[1]);
123
                });
123
        } else {
124
        } else {
124
            $stub->expects($this->never())
125
            $stub->expects($this->never())
125
                ->method('get_state');
126
                ->method('get_state');
Línea 131... Línea 132...
131
    /**
132
    /**
132
     * Data provider for test_validate_rule().
133
     * Data provider for test_validate_rule().
133
     *
134
     *
134
     * @return array[]
135
     * @return array[]
135
     */
136
     */
136
    public function validate_rule_provider() {
137
    public static function validate_rule_provider(): array {
137
        return [
138
        return [
138
            'Not defined' => [
139
            'Not defined' => [
139
                false, true, coding_exception::class
140
                false, true, coding_exception::class
140
            ],
141
            ],
141
            'Not available' => [
142
            'Not available' => [