Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * Unit tests for the behat coursecompleted condition.
19
 *
20
 * @package   availability_coursecompleted
21
 * @copyright 2017 iplusacademy (www.iplusacademy.org)
22
 * @author    Renaat Debleu <info@eWallah.net>
23
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
namespace availability_coursecompleted;
27
 
28
/**
29
 * Unit tests for the behat coursecompleted condition.
30
 *
31
 * @package   availability_coursecompleted
32
 * @copyright 2017 iplusacademy (www.iplusacademy.org)
33
 * @author    Renaat Debleu <info@eWallah.net>
34
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 * @coversDefaultClass \availability_coursecompleted
36
 */
37
final class behat_test extends \advanced_testcase {
38
    /**
39
     * Test behat funcs
40
     * @covers \behat_availability_coursecompleted
41
     */
42
    public function test_behat(): void {
43
        global $CFG;
44
        require_once($CFG->dirroot . '/availability/condition/coursecompleted/tests/behat/behat_availability_coursecompleted.php');
45
        $class = new \behat_availability_coursecompleted();
46
        $this->resetAfterTest();
47
        $this->setAdminUser();
48
        $CFG->enablecompletion = true;
49
        $CFG->enableavailability = true;
50
        set_config('enableavailability', true);
51
        $dg = $this->getDataGenerator();
52
        $course = $dg->create_course(['enablecompletion' => 1]);
53
        $user = $dg->create_user();
54
        $class->i_mark_course_completed_for_user($course->fullname, $user->username);
55
        $this->expectExceptionMessage("A user with username 'otheruser' does not exist");
56
        $class->i_mark_course_completed_for_user($course->fullname, 'otheruser');
57
    }
58
}