Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 31... Línea 31...
31
 * @copyright  2019 Mihail Geshoski <mihail@moodle.com>
31
 * @copyright  2019 Mihail Geshoski <mihail@moodle.com>
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 * @covers     \core_h5p\framework
33
 * @covers     \core_h5p\framework
34
 * @runTestsInSeparateProcesses
34
 * @runTestsInSeparateProcesses
35
 */
35
 */
36
class framework_test extends \advanced_testcase {
36
final class framework_test extends \advanced_testcase {
Línea 37... Línea 37...
37
 
37
 
38
    /** @var \core_h5p\framework */
38
    /** @var \core_h5p\framework */
Línea 39... Línea 39...
39
    private $framework;
39
    private $framework;
40
 
40
 
41
    /**
41
    /**
42
     * Set up function for tests.
42
     * Set up function for tests.
-
 
43
     */
43
     */
44
    public function setUp(): void {
44
    public function setUp(): void {
45
        parent::setUp();
45
        $factory = new \core_h5p\factory();
46
        $factory = new \core_h5p\factory();
Línea 46... Línea 47...
46
        $this->framework = $factory->get_framework();
47
        $this->framework = $factory->get_framework();
Línea 653... Línea 654...
653
    /**
654
    /**
654
     * Data provider for test_isPatchedLibrary().
655
     * Data provider for test_isPatchedLibrary().
655
     *
656
     *
656
     * @return array
657
     * @return array
657
     */
658
     */
658
    public function isPatchedLibrary_provider(): array {
659
    public static function isPatchedLibrary_provider(): array {
659
        return [
660
        return [
660
            'Unpatched library. No different versioning' => [
661
            'Unpatched library. No different versioning' => [
661
                [
662
                [
662
                    ['TestLibrary', 'Test', 1, 1, 2],
663
                    ['TestLibrary', 'Test', 1, 1, 2],
663
                ],
664
                ],
Línea 801... Línea 802...
801
        list(, $labelcm) = get_course_and_cm_from_instance($label->id, 'label');
802
        list(, $labelcm) = get_course_and_cm_from_instance($label->id, 'label');
802
        $contextlabel = \context_module::instance($labelcm->id);
803
        $contextlabel = \context_module::instance($labelcm->id);
803
        $this->getDataGenerator()->enrol_user($user->id, $course->id, 'student');
804
        $this->getDataGenerator()->enrol_user($user->id, $course->id, 'student');
Línea 804... Línea 805...
804
 
805
 
805
        // Create the .h5p file.
806
        // Create the .h5p file.
Línea 806... Línea 807...
806
        $path = __DIR__ . '/fixtures/h5ptest.zip';
807
        $path = self::get_fixture_path(__NAMESPACE__, 'h5ptest.zip');
807
 
808
 
808
        // Admin and manager should have permission to update libraries.
809
        // Admin and manager should have permission to update libraries.
809
        $file = helper::create_fake_stored_file_from_path($path, $admin->id, $contextsys);
810
        $file = helper::create_fake_stored_file_from_path($path, $admin->id, $contextsys);
Línea 858... Línea 859...
858
        // Create some users.
859
        // Create some users.
859
        $contextsys = \context_system::instance();
860
        $contextsys = \context_system::instance();
860
        $user = $this->getDataGenerator()->create_user();
861
        $user = $this->getDataGenerator()->create_user();
Línea 861... Línea 862...
861
 
862
 
862
        // The H5P file.
863
        // The H5P file.
Línea 863... Línea 864...
863
        $path = __DIR__ . '/fixtures/h5ptest.zip';
864
        $path = self::get_fixture_path(__NAMESPACE__, 'h5ptest.zip');
864
 
865
 
865
        // An error should be raised when it's called before initialitzing it.
866
        // An error should be raised when it's called before initialitzing it.
866
        $this->expectException('coding_exception');
867
        $this->expectException('coding_exception');
Línea 1096... Línea 1097...
1096
        $this->assertEquals($content['disable'], $h5pcontent->displayoptions);
1097
        $this->assertEquals($content['disable'], $h5pcontent->displayoptions);
1097
    }
1098
    }
Línea 1098... Línea 1099...
1098
 
1099
 
1099
    /**
1100
    /**
1100
     * Test the behaviour of updateContent() with metadata.
-
 
1101
     *
-
 
1102
     * @covers ::updateContent
1101
     * Test the behaviour of updateContent() with metadata.
1103
     */
1102
     */
1104
    public function test_updateContent_withmetadata(): void {
1103
    public function test_updateContent_withmetadata(): void {
Línea 1105... Línea 1104...
1105
        global $DB;
1104
        global $DB;
Línea 1555... Línea 1554...
1555
    /**
1554
    /**
1556
     * Data provider for test_loadLibrarySemantics().
1555
     * Data provider for test_loadLibrarySemantics().
1557
     *
1556
     *
1558
     * @return array
1557
     * @return array
1559
     */
1558
     */
1560
    public function loadLibrarySemantics_provider(): array {
1559
    public static function loadLibrarySemantics_provider(): array {
Línea 1561... Línea 1560...
1561
 
1560
 
1562
        $semantics = json_encode(
1561
        $semantics = json_encode(
1563
            [
1562
            [
1564
                'type' => 'text',
1563
                'type' => 'text',
Línea 2346... Línea 2345...
2346
    /**
2345
    /**
2347
     * Data provider for test_libraryHasUpgrade().
2346
     * Data provider for test_libraryHasUpgrade().
2348
     *
2347
     *
2349
     * @return array
2348
     * @return array
2350
     */
2349
     */
2351
    public function libraryHasUpgrade_provider(): array {
2350
    public static function libraryHasUpgrade_provider(): array {
2352
        return [
2351
        return [
2353
            'Lower major version; Identical lower version' => [
2352
            'Lower major version; Identical lower version' => [
2354
                [
2353
                [
2355
                    ['Library', 'Lib', 2, 2],
2354
                    ['Library', 'Lib', 2, 2],
2356
                ],
2355
                ],