Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 274... Línea 274...
274
    }
274
    }
Línea 275... Línea 275...
275
 
275
 
276
    /**
276
    /**
277
     * Test progress output when debug is on.
277
     * Test progress output when debug is on.
278
     */
278
     */
279
    public function test_statslib_progress_debug() {
279
    public function test_statslib_progress_debug(): void {
280
        set_debugging(DEBUG_ALL);
280
        set_debugging(DEBUG_ALL);
281
        $this->expectOutputString('1:0 ');
281
        $this->expectOutputString('1:0 ');
282
        stats_progress('init');
282
        stats_progress('init');
283
        stats_progress('1');
283
        stats_progress('1');
284
        $this->resetDebugging();
284
        $this->resetDebugging();
Línea 285... Línea 285...
285
    }
285
    }
286
 
286
 
287
    /**
287
    /**
288
     * Test progress output when debug is off.
288
     * Test progress output when debug is off.
289
     */
289
     */
290
    public function test_statslib_progress_no_debug() {
290
    public function test_statslib_progress_no_debug(): void {
291
        set_debugging(DEBUG_NONE);
291
        set_debugging(DEBUG_NONE);
292
        $this->expectOutputString('.');
292
        $this->expectOutputString('.');
293
        stats_progress('init');
293
        stats_progress('init');
294
        stats_progress('1');
294
        stats_progress('1');
Línea 295... Línea 295...
295
        $this->resetDebugging();
295
        $this->resetDebugging();
296
    }
296
    }
297
 
297
 
298
    /**
298
    /**
299
     * Test the function that gets the start date from the config.
299
     * Test the function that gets the start date from the config.
Línea 300... Línea 300...
300
     */
300
     */
301
    public function test_statslib_get_start_from() {
301
    public function test_statslib_get_start_from(): void {
Línea 385... Línea 385...
385
     * Test the function that calculates the start of the day.
385
     * Test the function that calculates the start of the day.
386
     *
386
     *
387
     * NOTE: I don't think this is the way this function should work.
387
     * NOTE: I don't think this is the way this function should work.
388
     *       This test documents the current functionality.
388
     *       This test documents the current functionality.
389
     */
389
     */
390
    public function test_statslib_get_base_daily() {
390
    public function test_statslib_get_base_daily(): void {
391
        global $CFG;
391
        global $CFG;
Línea 392... Línea 392...
392
 
392
 
393
        for ($x = 0; $x < 13; $x += 1) {
393
        for ($x = 0; $x < 13; $x += 1) {
Línea 403... Línea 403...
403
    }
403
    }
Línea 404... Línea 404...
404
 
404
 
405
    /**
405
    /**
406
     * Test the function that gets the start of the next day.
406
     * Test the function that gets the start of the next day.
407
     */
407
     */
408
    public function test_statslib_get_next_day_start() {
408
    public function test_statslib_get_next_day_start(): void {
409
        $this->setTimezone(0);
409
        $this->setTimezone(0);
Línea 410... Línea 410...
410
        $this->assertEquals(1272758400, stats_get_next_day_start(1272686410));
410
        $this->assertEquals(1272758400, stats_get_next_day_start(1272686410));
411
 
411
 
Línea 433... Línea 433...
433
     * @param int $startwday Day in which the week starts (Sunday = 0)
433
     * @param int $startwday Day in which the week starts (Sunday = 0)
434
     * @param string $timezone Default timezone
434
     * @param string $timezone Default timezone
435
     * @param string $timestart Date and time for which the first day of the week will be obtained
435
     * @param string $timestart Date and time for which the first day of the week will be obtained
436
     * @param string $expected Expected date of the first day of the week
436
     * @param string $expected Expected date of the first day of the week
437
     */
437
     */
438
    public function test_statslib_get_base_weekly($startwday, $timezone, $timestart, $expected) {
438
    public function test_statslib_get_base_weekly($startwday, $timezone, $timestart, $expected): void {
439
        $this->setTimezone($timezone);
439
        $this->setTimezone($timezone);
440
        $time = strtotime($timestart);
440
        $time = strtotime($timestart);
441
        $expected = strtotime($expected);
441
        $expected = strtotime($expected);
442
        set_config('calendar_startwday', $startwday);
442
        set_config('calendar_startwday', $startwday);
443
        set_config('statslastweekly', $time);
443
        set_config('statslastweekly', $time);
Línea 451... Línea 451...
451
     * Test the function that gets the action names.
451
     * Test the function that gets the action names.
452
     *
452
     *
453
     * Note: The function results depend on installed modules.  The hard coded lists are the
453
     * Note: The function results depend on installed modules.  The hard coded lists are the
454
     *       defaults for a new Moodle 2.3 install.
454
     *       defaults for a new Moodle 2.3 install.
455
     */
455
     */
456
    public function test_statslib_get_action_names() {
456
    public function test_statslib_get_action_names(): void {
457
        $basepostactions = array (
457
        $basepostactions = array (
458
            0 => 'add',
458
            0 => 'add',
459
            1 => 'delete',
459
            1 => 'delete',
460
            2 => 'edit',
460
            2 => 'edit',
461
            3 => 'add mod',
461
            3 => 'add mod',
Línea 534... Línea 534...
534
    }
534
    }
Línea 535... Línea 535...
535
 
535
 
536
    /**
536
    /**
537
     * Test the temporary table creation and deletion.
537
     * Test the temporary table creation and deletion.
538
     */
538
     */
539
    public function test_statslib_temp_table_create_and_drop() {
539
    public function test_statslib_temp_table_create_and_drop(): void {
Línea 540... Línea 540...
540
        global $DB;
540
        global $DB;
541
 
541
 
542
        foreach ($this->tables as $table) {
542
        foreach ($this->tables as $table) {
Línea 559... Línea 559...
559
    /**
559
    /**
560
     * Test the temporary table creation and deletion.
560
     * Test the temporary table creation and deletion.
561
     *
561
     *
562
     * @depends test_statslib_temp_table_create_and_drop
562
     * @depends test_statslib_temp_table_create_and_drop
563
     */
563
     */
564
    public function test_statslib_temp_table_fill() {
564
    public function test_statslib_temp_table_fill(): void {
565
        global $CFG, $DB, $USER;
565
        global $CFG, $DB, $USER;
Línea 566... Línea 566...
566
 
566
 
567
        $dataset = $this->load_xml_data_file(__DIR__."/fixtures/statslib-test09.xml");
567
        $dataset = $this->load_xml_data_file(__DIR__."/fixtures/statslib-test09.xml");
Línea 661... Línea 661...
661
    /**
661
    /**
662
     * Test the temporary table creation and deletion.
662
     * Test the temporary table creation and deletion.
663
     *
663
     *
664
     * @depends test_statslib_temp_table_create_and_drop
664
     * @depends test_statslib_temp_table_create_and_drop
665
     */
665
     */
666
    public function test_statslib_temp_table_setup() {
666
    public function test_statslib_temp_table_setup(): void {
667
        global $DB;
667
        global $DB;
Línea 668... Línea 668...
668
 
668
 
Línea 669... Línea 669...
669
        $DB->delete_records('log');
669
        $DB->delete_records('log');
Línea 679... Línea 679...
679
    /**
679
    /**
680
     * Test the function that clean out the temporary tables.
680
     * Test the function that clean out the temporary tables.
681
     *
681
     *
682
     * @depends test_statslib_temp_table_create_and_drop
682
     * @depends test_statslib_temp_table_create_and_drop
683
     */
683
     */
684
    public function test_statslib_temp_table_clean() {
684
    public function test_statslib_temp_table_clean(): void {
685
        global $DB;
685
        global $DB;
Línea 686... Línea 686...
686
 
686
 
687
        $rows = array(
687
        $rows = array(
688
            'temp_log1'             => array('id' => 1, 'course' => 1),
688
            'temp_log1'             => array('id' => 1, 'course' => 1),
Línea 719... Línea 719...
719
     * @depends test_statslib_temp_table_create_and_drop
719
     * @depends test_statslib_temp_table_create_and_drop
720
     * @depends test_statslib_temp_table_setup
720
     * @depends test_statslib_temp_table_setup
721
     * @depends test_statslib_temp_table_fill
721
     * @depends test_statslib_temp_table_fill
722
     * @dataProvider daily_log_provider
722
     * @dataProvider daily_log_provider
723
     */
723
     */
724
    public function test_statslib_cron_daily($xmlfile) {
724
    public function test_statslib_cron_daily($xmlfile): void {
725
        global $CFG, $DB;
725
        global $CFG, $DB;
Línea 726... Línea 726...
726
 
726
 
727
        $dataset = $this->load_xml_data_file(__DIR__."/fixtures/{$xmlfile}");
727
        $dataset = $this->load_xml_data_file(__DIR__."/fixtures/{$xmlfile}");
728
        $stats = $this->prepare_db($dataset, array('log'));
728
        $stats = $this->prepare_db($dataset, array('log'));
Línea 741... Línea 741...
741
     * Test the daily stats function.
741
     * Test the daily stats function.
742
     *
742
     *
743
     * @depends test_statslib_get_base_daily
743
     * @depends test_statslib_get_base_daily
744
     * @depends test_statslib_get_next_day_start
744
     * @depends test_statslib_get_next_day_start
745
     */
745
     */
746
    public function test_statslib_cron_daily_no_default_profile_id() {
746
    public function test_statslib_cron_daily_no_default_profile_id(): void {
747
        global $CFG, $DB;
747
        global $CFG, $DB;
748
        $CFG->defaultfrontpageroleid = 0;
748
        $CFG->defaultfrontpageroleid = 0;
Línea 749... Línea 749...
749
 
749
 
750
        $course1  = $DB->get_record('course', array('shortname' => 'course1'));
750
        $course1  = $DB->get_record('course', array('shortname' => 'course1'));