Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 29... Línea 29...
29
    public static function setUpBeforeClass(): void {
29
    public static function setUpBeforeClass(): void {
30
        global $CFG;
30
        global $CFG;
31
        require_once(__DIR__ . '/fixtures/adhoc_test_task.php');
31
        require_once(__DIR__ . '/fixtures/adhoc_test_task.php');
32
    }
32
    }
Línea 33... Línea 33...
33
 
33
 
34
    public function test_debugging() {
34
    public function test_debugging(): void {
35
        global $CFG;
35
        global $CFG;
Línea 36... Línea 36...
36
        $this->resetAfterTest();
36
        $this->resetAfterTest();
37
 
37
 
Línea 74... Línea 74...
74
    public function debugging_called_with_annotation() {
74
    public function debugging_called_with_annotation() {
75
        debugging('pokus', DEBUG_MINIMAL);
75
        debugging('pokus', DEBUG_MINIMAL);
76
        $this->assertDebuggingCalled('pokus', DEBUG_MINIMAL);
76
        $this->assertDebuggingCalled('pokus', DEBUG_MINIMAL);
77
    }
77
    }
Línea 78... Línea 78...
78
 
78
 
79
    public function test_set_user() {
79
    public function test_set_user(): void {
Línea 80... Línea 80...
80
        global $USER, $DB, $SESSION;
80
        global $USER, $DB, $SESSION;
Línea 81... Línea 81...
81
 
81
 
Línea 121... Línea 121...
121
        $SESSION->sometestvalue = true;
121
        $SESSION->sometestvalue = true;
122
        $this->setUser($user);
122
        $this->setUser($user);
123
        $this->assertObjectNotHasProperty('sometestvalue', $SESSION);
123
        $this->assertObjectNotHasProperty('sometestvalue', $SESSION);
124
    }
124
    }
Línea 125... Línea 125...
125
 
125
 
126
    public function test_set_admin_user() {
126
    public function test_set_admin_user(): void {
Línea 127... Línea 127...
127
        global $USER;
127
        global $USER;
Línea 128... Línea 128...
128
 
128
 
129
        $this->resetAfterTest();
129
        $this->resetAfterTest();
130
 
130
 
131
        $this->setAdminUser();
131
        $this->setAdminUser();
Línea 132... Línea 132...
132
        $this->assertEquals($USER->id, 2);
132
        $this->assertEquals($USER->id, 2);
133
        $this->assertTrue(is_siteadmin());
133
        $this->assertTrue(is_siteadmin());
Línea 134... Línea 134...
134
    }
134
    }
Línea 135... Línea 135...
135
 
135
 
136
    public function test_set_guest_user() {
136
    public function test_set_guest_user(): void {
137
        global $USER;
137
        global $USER;
138
 
138
 
Línea 139... Línea 139...
139
        $this->resetAfterTest();
139
        $this->resetAfterTest();
140
 
140
 
Línea 141... Línea 141...
141
        $this->setGuestUser();
141
        $this->setGuestUser();
Línea 142... Línea 142...
142
        $this->assertEquals($USER->id, 1);
142
        $this->assertEquals($USER->id, 1);
Línea 204... Línea 204...
204
        $this->assertEquals($numcourses + 1, $DB->count_records('course'));
204
        $this->assertEquals($numcourses + 1, $DB->count_records('course'));
Línea 205... Línea 205...
205
 
205
 
206
        $this->assertEquals(2, $DB->count_records('user'));
206
        $this->assertEquals(2, $DB->count_records('user'));
Línea 207... Línea 207...
207
    }
207
    }
208
 
208
 
Línea 209... Línea 209...
209
    public function test_change_detection() {
209
    public function test_change_detection(): void {
210
        global $DB, $CFG, $COURSE, $SITE, $USER;
210
        global $DB, $CFG, $COURSE, $SITE, $USER;
Línea 285... Línea 285...
285
            $this->assertInstanceOf('PHPUnit\Framework\Error\Warning', $e);
285
            $this->assertInstanceOf('PHPUnit\Framework\Error\Warning', $e);
286
            $this->assertEquals(0, $USER->id);
286
            $this->assertEquals(0, $USER->id);
287
        }
287
        }
288
    }
288
    }
Línea 289... Línea 289...
289
 
289
 
290
    public function test_getDataGenerator() {
290
    public function test_getDataGenerator(): void {
291
        $generator = $this->getDataGenerator();
291
        $generator = $this->getDataGenerator();
292
        $this->assertInstanceOf('testing_data_generator', $generator);
292
        $this->assertInstanceOf('testing_data_generator', $generator);
Línea 293... Línea 293...
293
    }
293
    }
294
 
294
 
Línea 295... Línea 295...
295
    public function test_database_mock1() {
295
    public function test_database_mock1(): void {
296
        global $DB;
296
        global $DB;
297
 
297
 
Línea 304... Línea 304...
304
        $DB = $this->createMock(get_class($DB));
304
        $DB = $this->createMock(get_class($DB));
305
        $this->assertNull($DB->get_record('pokus', array()));
305
        $this->assertNull($DB->get_record('pokus', array()));
306
        // Rest continues after reset.
306
        // Rest continues after reset.
307
    }
307
    }
Línea 308... Línea 308...
308
 
308
 
309
    public function test_database_mock2() {
309
    public function test_database_mock2(): void {
Línea 310... Línea 310...
310
        global $DB;
310
        global $DB;
311
 
311
 
312
        // Now the database should be back to normal.
312
        // Now the database should be back to normal.
Línea 313... Línea 313...
313
        $this->assertFalse($DB->get_record('user', array('id'=>9999)));
313
        $this->assertFalse($DB->get_record('user', array('id'=>9999)));
314
    }
314
    }
Línea 315... Línea 315...
315
 
315
 
316
    public function test_assert_time_current() {
316
    public function test_assert_time_current(): void {
317
        $this->assertTimeCurrent(time());
317
        $this->assertTimeCurrent(time());
Línea 393... Línea 393...
393
            'wrong_get_url' => ['\core\event\context_used_in_event_get_url', true],
393
            'wrong_get_url' => ['\core\event\context_used_in_event_get_url', true],
394
            'wrong_get_description' => ['\core\event\context_used_in_event_get_description', true],
394
            'wrong_get_description' => ['\core\event\context_used_in_event_get_description', true],
395
        ];
395
        ];
396
    }
396
    }
Línea 397... Línea 397...
397
 
397
 
398
    public function test_message_processors_reset() {
398
    public function test_message_processors_reset(): void {
Línea 399... Línea 399...
399
        global $DB;
399
        global $DB;
Línea 400... Línea 400...
400
 
400
 
Línea 420... Línea 420...
420
        // And we should have one more message processor in the list.
420
        // And we should have one more message processor in the list.
421
        $this->assertNotSame($processors1, $processors3);
421
        $this->assertNotSame($processors1, $processors3);
422
        $this->assertEquals(count($processors1) + 1, count($processors3));
422
        $this->assertEquals(count($processors1) + 1, count($processors3));
423
    }
423
    }
Línea 424... Línea 424...
424
 
424
 
425
    public function test_message_redirection() {
425
    public function test_message_redirection(): \phpunit_message_sink {
426
        $this->preventResetByRollback(); // Messaging is not compatible with transactions...
426
        $this->preventResetByRollback(); // Messaging is not compatible with transactions...
Línea 427... Línea 427...
427
        $this->resetAfterTest(false);
427
        $this->resetAfterTest(false);
428
 
428
 
Línea 542... Línea 542...
542
    }
542
    }
Línea 543... Línea 543...
543
 
543
 
544
    /**
544
    /**
545
     * @depends test_message_redirection
545
     * @depends test_message_redirection
546
     */
546
     */
547
    public function test_message_redirection_noreset($sink) {
547
    public function test_message_redirection_noreset(\phpunit_message_sink $sink): void {
548
        if ($this->isInIsolation()) {
548
        if ($this->isInIsolation()) {
549
            $this->markTestSkipped('State cannot be carried over between tests in isolated tests');
549
            $this->markTestSkipped('State cannot be carried over between tests in isolated tests');
Línea 550... Línea 550...
550
        }
550
        }
Línea 573... Línea 573...
573
    }
573
    }
Línea 574... Línea 574...
574
 
574
 
575
    /**
575
    /**
576
     * @depends test_message_redirection_noreset
576
     * @depends test_message_redirection_noreset
577
     */
577
     */
578
    public function test_message_redirection_reset() {
578
    public function test_message_redirection_reset(): void {
579
        $this->assertFalse(\phpunit_util::is_redirecting_messages(), 'Test reset must stop message redirection.');
579
        $this->assertFalse(\phpunit_util::is_redirecting_messages(), 'Test reset must stop message redirection.');
Línea 580... Línea 580...
580
    }
580
    }
581
 
581
 
582
    public function test_set_timezone() {
582
    public function test_set_timezone(): void {
Línea 583... Línea 583...
583
        global $CFG;
583
        global $CFG;
584
        $this->resetAfterTest();
584
        $this->resetAfterTest();
Línea 620... Línea 620...
620
            $this->assertInstanceOf('PHPUnit\Framework\Error\Warning', $e);
620
            $this->assertInstanceOf('PHPUnit\Framework\Error\Warning', $e);
621
        }
621
        }
Línea 622... Línea 622...
622
 
622
 
Línea 623... Línea 623...
623
    }
623
    }
624
 
624
 
Línea 625... Línea 625...
625
    public function test_locale_reset() {
625
    public function test_locale_reset(): void {
Línea 626... Línea 626...
626
        global $CFG;
626
        global $CFG;
Línea 669... Línea 669...
669
    }
669
    }
Línea 670... Línea 670...
670
 
670
 
671
    /**
671
    /**
672
     * This test sets a user agent and makes sure that it is cleared when the test is reset.
672
     * This test sets a user agent and makes sure that it is cleared when the test is reset.
673
     */
673
     */
674
    public function test_it_resets_useragent_after_test() {
674
    public function test_it_resets_useragent_after_test(): void {
675
        $this->resetAfterTest();
675
        $this->resetAfterTest();
Línea 676... Línea 676...
676
        $fakeagent = 'New user agent set.';
676
        $fakeagent = 'New user agent set.';
677
 
677