MDL-67156 core_h5p: change DIRECTORY_SEPARATOR by slashes
authorVíctor Déniz Falcón <victor@moodle.com>
Fri, 8 Nov 2019 22:18:11 +0000 (22:18 +0000)
committerVíctor Déniz Falcón <victor@moodle.com>
Fri, 8 Nov 2019 22:18:11 +0000 (22:18 +0000)
In Windows, the value of DIRECTORY_SEPARATOR is "\", causing failures in
the tests when compared to the path strings that use "/".

h5p/tests/h5p_file_storage_test.php

index 832b4f0..6726fce 100644 (file)
@@ -462,7 +462,7 @@ class h5p_file_storage_testcase extends \advanced_testcase {
         ];
         $filestorage = new file_storage();
         $fs->create_file_from_string($filerecord, 'test string info');
-        $expectedfilepath = DIRECTORY_SEPARATOR . file_storage::LIBRARY_FILEAREA . $filepath . 'upgrade.js';
+        $expectedfilepath = '/' . file_storage::LIBRARY_FILEAREA . $filepath . 'upgrade.js';
         $this->assertEquals($expectedfilepath, $filestorage->getUpgradeScript($machinename, $majorversion, $minorversion));
         $this->assertNull($filestorage->getUpgradeScript($machinename, $majorversion, 7));
     }
@@ -489,9 +489,9 @@ class h5p_file_storage_testcase extends \advanced_testcase {
         foreach ($files as $file) {
             if (!$file->is_directory) {
                 $stream = $ziparchive->get_stream($file->index);
-                $items = explode(DIRECTORY_SEPARATOR, $file->pathname);
+                $items = explode('/', $file->pathname);
                 array_shift($items);
-                $path = implode(DIRECTORY_SEPARATOR, $items);
+                $path = implode('/', $items);
                 $this->h5p_file_storage->saveFileFromZip($this->h5p_tempath, $path, $stream);
                 $filestocheck[] = $path;
             }