Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 24... Línea 24...
24
 * @package   core
24
 * @package   core
25
 * @category  phpunit
25
 * @category  phpunit
26
 * @copyright 2022 Andrew Lyons <andrew@thelyons.family>
26
 * @copyright 2022 Andrew Lyons <andrew@thelyons.family>
27
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 */
28
 */
29
class upgradelib_test extends \advanced_testcase {
29
final class upgradelib_test extends \advanced_testcase {
Línea 30... Línea 30...
30
 
30
 
31
    /**
31
    /**
32
     * Shared setup for the testcase.
32
     * Shared setup for the testcase.
33
     */
33
     */
34
    public function setUp(): void {
34
    public function setUp(): void {
Línea 35... Línea 35...
35
        global $CFG;
35
        global $CFG;
36
 
36
 
-
 
37
        require_once("{$CFG->libdir}/db/upgradelib.php");
37
        require_once("{$CFG->libdir}/db/upgradelib.php");
38
        require_once("{$CFG->dirroot}/my/lib.php");
Línea 38... Línea 39...
38
        require_once("{$CFG->dirroot}/my/lib.php");
39
        parent::setUp();
39
    }
40
    }
40
 
41
 
Línea 537... Línea 538...
537
            $expected = (object) $original;
538
            $expected = (object) $original;
538
            $expected->parentcontextid = $usercontext->id;
539
            $expected->parentcontextid = $usercontext->id;
539
            $this->assertEquals($expected, $block);
540
            $this->assertEquals($expected, $block);
540
        }
541
        }
541
    }
542
    }
-
 
543
 
-
 
544
    /**
-
 
545
     * Ensure that the upgrade_create_async_mimetype_upgrade_task function performs as expected.
-
 
546
     *
-
 
547
     * @covers ::upgrade_create_async_mimetype_upgrade_task
-
 
548
     */
-
 
549
    public function test_upgrade_create_async_mimetype_upgrade_task(): void {
-
 
550
        global $DB;
-
 
551
        $this->resetAfterTest();
-
 
552
        $clock = $this->mock_clock_with_frozen();
-
 
553
 
-
 
554
        upgrade_create_async_mimetype_upgrade_task('type/subtype', ['extension1', 'extension2']);
-
 
555
 
-
 
556
        // Ensure that the task was created with correct next runtime.
-
 
557
        $nextruntime = $DB->get_field(
-
 
558
            table: 'task_adhoc',
-
 
559
            return: 'nextruntime',
-
 
560
            conditions: ['component' => 'core', 'classname' => '\core_files\task\asynchronous_mimetype_upgrade_task'],
-
 
561
            strictness: MUST_EXIST,
-
 
562
        );
-
 
563
        $this->assertEquals(expected: $clock->time() - 1, actual: $nextruntime);
-
 
564
 
-
 
565
        // Ensure that the task has the correct custom data.
-
 
566
        $customdata = $DB->get_field(
-
 
567
            table: 'task_adhoc',
-
 
568
            return: 'customdata',
-
 
569
            conditions: ['component' => 'core', 'classname' => '\core_files\task\asynchronous_mimetype_upgrade_task'],
-
 
570
            strictness: MUST_EXIST,
-
 
571
        );
-
 
572
        $customdata = json_decode($customdata);
-
 
573
        $this->assertEquals(expected: 'type/subtype', actual: $customdata->mimetype);
-
 
574
        $this->assertEquals(expected: ['extension1', 'extension2'], actual: $customdata->extensions);
-
 
575
    }
542
}
576
}