Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 34... Línea 34...
34
    }
34
    }
Línea 35... Línea 35...
35
 
35
 
36
    /**
36
    /**
37
     * Do a test of the user search SQL with database users.
37
     * Do a test of the user search SQL with database users.
38
     */
38
     */
39
    public function test_users_search_sql() {
39
    public function test_users_search_sql(): void {
40
        global $DB;
40
        global $DB;
Línea 41... Línea 41...
41
        $this->resetAfterTest();
41
        $this->resetAfterTest();
42
 
42
 
Línea 152... Línea 152...
152
        foreach ($results as $record) {
152
        foreach ($results as $record) {
153
            $this->assertSame('snake', $record->value);
153
            $this->assertSame('snake', $record->value);
154
        }
154
        }
155
    }
155
    }
Línea 156... Línea 156...
156
 
156
 
157
    public function test_users_order_by_sql_simple() {
157
    public function test_users_order_by_sql_simple(): void {
158
        list($sort, $params) = users_order_by_sql();
158
        list($sort, $params) = users_order_by_sql();
159
        $this->assert_same_sql('lastname, firstname, id', $sort);
159
        $this->assert_same_sql('lastname, firstname, id', $sort);
160
        $this->assertEquals(array(), $params);
160
        $this->assertEquals(array(), $params);
Línea 161... Línea 161...
161
    }
161
    }
162
 
162
 
163
    public function test_users_order_by_sql_table_prefix() {
163
    public function test_users_order_by_sql_table_prefix(): void {
164
        list($sort, $params) = users_order_by_sql('u');
164
        list($sort, $params) = users_order_by_sql('u');
165
        $this->assert_same_sql('u.lastname, u.firstname, u.id', $sort);
165
        $this->assert_same_sql('u.lastname, u.firstname, u.id', $sort);
Línea 166... Línea 166...
166
        $this->assertEquals(array(), $params);
166
        $this->assertEquals(array(), $params);
167
    }
167
    }
168
 
168
 
Línea 169... Línea 169...
169
    public function test_users_order_by_sql_search_no_extra_fields() {
169
    public function test_users_order_by_sql_search_no_extra_fields(): void {
Línea 180... Línea 180...
180
                THEN 0 ELSE 1 END, lastname, firstname, id', $sort);
180
                THEN 0 ELSE 1 END, lastname, firstname, id', $sort);
181
        $this->assertEquals(array('usersortexact1' => 'search', 'usersortexact2' => 'search',
181
        $this->assertEquals(array('usersortexact1' => 'search', 'usersortexact2' => 'search',
182
                'usersortexact3' => 'search'), $params);
182
                'usersortexact3' => 'search'), $params);
183
    }
183
    }
Línea 184... Línea 184...
184
 
184
 
185
    public function test_users_order_by_sql_search_with_extra_fields_and_prefix() {
185
    public function test_users_order_by_sql_search_with_extra_fields_and_prefix(): void {
186
        global $CFG, $DB;
186
        global $CFG, $DB;
Línea 187... Línea 187...
187
        $this->resetAfterTest();
187
        $this->resetAfterTest();
188
 
188
 
Línea 218... Línea 218...
218
                THEN 0 ELSE 1 END, u.lastname, u.firstname, u.id', $sort);
218
                THEN 0 ELSE 1 END, u.lastname, u.firstname, u.id', $sort);
219
        $this->assertEquals(array('usersortexact1' => 'search', 'usersortexact2' => 'search',
219
        $this->assertEquals(array('usersortexact1' => 'search', 'usersortexact2' => 'search',
220
                'usersortexact3' => 'search', 'usersortexact4' => 'search'), $params);
220
                'usersortexact3' => 'search', 'usersortexact4' => 'search'), $params);
221
    }
221
    }
Línea 222... Línea 222...
222
 
222
 
223
    public function test_get_admin() {
223
    public function test_get_admin(): void {
224
        global $CFG, $DB;
224
        global $CFG, $DB;
Línea 225... Línea 225...
225
        $this->resetAfterTest();
225
        $this->resetAfterTest();
226
 
226
 
Línea 250... Línea 250...
250
        get_admin();
250
        get_admin();
251
        get_admin();
251
        get_admin();
252
        $this->assertEquals($odlread, $DB->perf_get_reads());
252
        $this->assertEquals($odlread, $DB->perf_get_reads());
253
    }
253
    }
Línea 254... Línea 254...
254
 
254
 
255
    public function test_get_admins() {
255
    public function test_get_admins(): void {
256
        global $CFG, $DB;
256
        global $CFG, $DB;
Línea 257... Línea 257...
257
        $this->resetAfterTest();
257
        $this->resetAfterTest();
Línea 281... Línea 281...
281
        $odlread = $DB->perf_get_reads();
281
        $odlread = $DB->perf_get_reads();
282
        get_admins(); // This should make just one query.
282
        get_admins(); // This should make just one query.
283
        $this->assertEquals($odlread+1, $DB->perf_get_reads());
283
        $this->assertEquals($odlread+1, $DB->perf_get_reads());
284
    }
284
    }
Línea 285... Línea 285...
285
 
285
 
286
    public function test_get_course() {
286
    public function test_get_course(): void {
287
        global $DB, $PAGE, $SITE;
287
        global $DB, $PAGE, $SITE;
Línea 288... Línea 288...
288
        $this->resetAfterTest();
288
        $this->resetAfterTest();
289
 
289
 
Línea 336... Línea 336...
336
            'shortname' => $course->shortname,
336
            'shortname' => $course->shortname,
337
            'fullname' => $course->fullname,
337
            'fullname' => $course->fullname,
338
        ], reset($courses));
338
        ], reset($courses));
339
    }
339
    }
Línea 340... Línea 340...
340
 
340
 
341
    public function test_increment_revision_number() {
341
    public function test_increment_revision_number(): void {
342
        global $DB;
342
        global $DB;
Línea 343... Línea 343...
343
        $this->resetAfterTest();
343
        $this->resetAfterTest();
344
 
344
 
Línea 393... Línea 393...
393
        $record2 = $DB->get_record('course', array('id'=>$course2->id));
393
        $record2 = $DB->get_record('course', array('id'=>$course2->id));
394
        $this->assertTimeCurrent($record1->cacherev);
394
        $this->assertTimeCurrent($record1->cacherev);
395
        $this->assertEquals($record1->cacherev, $record2->cacherev);
395
        $this->assertEquals($record1->cacherev, $record2->cacherev);
396
    }
396
    }
Línea 397... Línea 397...
397
 
397
 
398
    public function test_get_coursemodule_from_id() {
398
    public function test_get_coursemodule_from_id(): void {
Línea 399... Línea 399...
399
        global $CFG;
399
        global $CFG;
400
 
400
 
Línea 459... Línea 459...
459
        } catch (\moodle_exception $e) {
459
        } catch (\moodle_exception $e) {
460
            $this->assertInstanceOf('dml_read_exception', $e);
460
            $this->assertInstanceOf('dml_read_exception', $e);
461
        }
461
        }
462
    }
462
    }
Línea 463... Línea 463...
463
 
463
 
464
    public function test_get_coursemodule_from_instance() {
464
    public function test_get_coursemodule_from_instance(): void {
Línea 465... Línea 465...
465
        global $CFG;
465
        global $CFG;
466
 
466
 
Línea 523... Línea 523...
523
        } catch (\moodle_exception $e) {
523
        } catch (\moodle_exception $e) {
524
            $this->assertInstanceOf('dml_read_exception', $e);
524
            $this->assertInstanceOf('dml_read_exception', $e);
525
        }
525
        }
526
    }
526
    }
Línea 527... Línea 527...
527
 
527
 
528
    public function test_get_coursemodules_in_course() {
528
    public function test_get_coursemodules_in_course(): void {
Línea 529... Línea 529...
529
        global $CFG;
529
        global $CFG;
530
 
530
 
Línea 592... Línea 592...
592
        } catch (\moodle_exception $e) {
592
        } catch (\moodle_exception $e) {
593
            $this->assertInstanceOf('dml_read_exception', $e);
593
            $this->assertInstanceOf('dml_read_exception', $e);
594
        }
594
        }
595
    }
595
    }
Línea 596... Línea 596...
596
 
596
 
597
    public function test_get_all_instances_in_courses() {
597
    public function test_get_all_instances_in_courses(): void {
Línea 598... Línea 598...
598
        global $CFG;
598
        global $CFG;
599
 
599
 
Línea 647... Línea 647...
647
        } catch (\moodle_exception $e) {
647
        } catch (\moodle_exception $e) {
648
            $this->assertInstanceOf('coding_exception', $e);
648
            $this->assertInstanceOf('coding_exception', $e);
649
        }
649
        }
650
    }
650
    }
Línea 651... Línea 651...
651
 
651
 
652
    public function test_get_all_instances_in_course() {
652
    public function test_get_all_instances_in_course(): void {
Línea 653... Línea 653...
653
        global $CFG;
653
        global $CFG;
654
 
654
 
Línea 703... Línea 703...
703
    }
703
    }
Línea 704... Línea 704...
704
 
704
 
705
    /**
705
    /**
706
     * Test max courses in category
706
     * Test max courses in category
707
     */
707
     */
708
    public function test_max_courses_in_category() {
708
    public function test_max_courses_in_category(): void {
709
        global $CFG;
709
        global $CFG;
Línea 710... Línea 710...
710
        $this->resetAfterTest();
710
        $this->resetAfterTest();
711
 
711
 
Línea 768... Línea 768...
768
    }
768
    }
Línea 769... Línea 769...
769
 
769
 
770
    /**
770
    /**
771
     * Test debug message for max courses in category
771
     * Test debug message for max courses in category
772
     */
772
     */
773
    public function test_debug_max_courses_in_category() {
773
    public function test_debug_max_courses_in_category(): void {
774
        global $CFG;
774
        global $CFG;
Línea 775... Línea 775...
775
        $this->resetAfterTest();
775
        $this->resetAfterTest();
776
 
776