Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 35... Línea 35...
35
 * Event container test..
35
 * Event container test..
36
 *
36
 *
37
 * @package core_calendar
37
 * @package core_calendar
38
 * @copyright 2017 Cameron Ball <cameron@cameron1729.xyz>
38
 * @copyright 2017 Cameron Ball <cameron@cameron1729.xyz>
39
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
40
 * @covers \core_calendar\local\event\container
40
 */
41
 */
41
class container_test extends \advanced_testcase {
42
final class container_test extends \advanced_testcase {
Línea 42... Línea 43...
42
 
43
 
43
    /**
44
    /**
44
     * Test setup.
45
     * Test setup.
45
     */
46
     */
-
 
47
    public function setUp(): void {
46
    public function setUp(): void {
48
        parent::setUp();
47
        $this->resetAfterTest();
49
        $this->resetAfterTest();
48
        $this->setAdminUser();
50
        $this->setAdminUser();
Línea 49... Línea 51...
49
    }
51
    }
Línea 65... Línea 67...
65
    }
67
    }
Línea 66... Línea 68...
66
 
68
 
67
    /**
69
    /**
68
     * Test that the event factory correctly creates instances of events.
70
     * Test that the event factory correctly creates instances of events.
69
     *
71
     *
70
     * @dataProvider get_event_factory_testcases()
72
     * @dataProvider get_event_factory_testcases
71
     * @param \stdClass $dbrow Row from the "database".
73
     * @param \stdClass $dbrow Row from the "database".
72
     */
74
     */
73
    public function test_event_factory_create_instance($dbrow): void {
75
    public function test_event_factory_create_instance($dbrow): void {
74
        $legacyevent = $this->create_event($dbrow);
76
        $legacyevent = $this->create_event($dbrow);
Línea 126... Línea 128...
126
    }
128
    }
Línea 127... Línea 129...
127
 
129
 
128
    /**
130
    /**
129
     * Test that the event factory deals with invisible modules properly as admin.
131
     * Test that the event factory deals with invisible modules properly as admin.
130
     *
132
     *
131
     * @dataProvider get_event_factory_testcases()
133
     * @dataProvider get_event_factory_testcases
132
     * @param \stdClass $dbrow Row from the "database".
134
     * @param \stdClass $dbrow Row from the "database".
133
     */
135
     */
134
    public function test_event_factory_when_module_visibility_is_toggled_as_admin($dbrow): void {
136
    public function test_event_factory_when_module_visibility_is_toggled_as_admin($dbrow): void {
135
        $legacyevent = $this->create_event($dbrow);
137
        $legacyevent = $this->create_event($dbrow);
Línea 152... Línea 154...
152
    }
154
    }
Línea 153... Línea 155...
153
 
155
 
154
    /**
156
    /**
155
     * Test that the event factory deals with invisible modules properly as a guest.
157
     * Test that the event factory deals with invisible modules properly as a guest.
156
     *
158
     *
157
     * @dataProvider get_event_factory_testcases()
159
     * @dataProvider get_event_factory_testcases
158
     * @param \stdClass $dbrow Row from the "database".
160
     * @param \stdClass $dbrow Row from the "database".
159
     */
161
     */
160
    public function test_event_factory_when_module_visibility_is_toggled_as_guest($dbrow): void {
162
    public function test_event_factory_when_module_visibility_is_toggled_as_guest($dbrow): void {
161
        $legacyevent = $this->create_event($dbrow);
163
        $legacyevent = $this->create_event($dbrow);
Línea 181... Línea 183...
181
    }
183
    }
Línea 182... Línea 184...
182
 
184
 
183
    /**
185
    /**
184
     * Test that the event factory deals with invisible courses as an admin.
186
     * Test that the event factory deals with invisible courses as an admin.
185
     *
187
     *
186
     * @dataProvider get_event_factory_testcases()
188
     * @dataProvider get_event_factory_testcases
187
     * @param \stdClass $dbrow Row from the "database".
189
     * @param \stdClass $dbrow Row from the "database".
188
     */
190
     */
189
    public function test_event_factory_when_course_visibility_is_toggled_as_admin($dbrow): void {
191
    public function test_event_factory_when_course_visibility_is_toggled_as_admin($dbrow): void {
190
        $legacyevent = $this->create_event($dbrow);
192
        $legacyevent = $this->create_event($dbrow);
Línea 206... Línea 208...
206
    }
208
    }
Línea 207... Línea 209...
207
 
209
 
208
    /**
210
    /**
209
     * Test that the event factory deals with invisible courses as a student.
211
     * Test that the event factory deals with invisible courses as a student.
210
     *
212
     *
211
     * @dataProvider get_event_factory_testcases()
213
     * @dataProvider get_event_factory_testcases
212
     * @param \stdClass $dbrow Row from the "database".
214
     * @param \stdClass $dbrow Row from the "database".
213
     */
215
     */
214
    public function test_event_factory_when_course_visibility_is_toggled_as_student($dbrow): void {
216
    public function test_event_factory_when_course_visibility_is_toggled_as_student($dbrow): void {
215
        $legacyevent = $this->create_event($dbrow);
217
        $legacyevent = $this->create_event($dbrow);
Línea 367... Línea 369...
367
        $this->assertNull($factory->create_instance($event));
369
        $this->assertNull($factory->create_instance($event));
368
    }
370
    }
Línea 369... Línea 371...
369
 
371
 
370
    /**
372
    /**
371
     * Checks that completed activities events do not show.
-
 
372
     * @covers \core_calendar\local\event::init
373
     * Checks that completed activities events do not show.
373
     */
374
     */
374
    public function test_event_factory_with_completed_module_related_event(): void {
375
    public function test_event_factory_with_completed_module_related_event(): void {
Línea 375... Línea 376...
375
        global $CFG, $DB;
376
        global $CFG, $DB;
Línea 502... Línea 503...
502
    }
503
    }
Línea 503... Línea 504...
503
 
504
 
504
    /**
505
    /**
505
     * Test cases for the get event factory test.
506
     * Test cases for the get event factory test.
506
     */
507
     */
507
    public function get_event_factory_testcases() {
508
    public static function get_event_factory_testcases(): array {
508
        return [
509
        return [
509
            'Data set 1' => [
510
            'Data set 1' => [
510
                'dbrow' => (object)[
511
                'dbrow' => (object)[
511
                    'name' => 'Test event',
512
                    'name' => 'Test event',