Skip to content

Commit

Permalink
MDL-83807 h5p test: rename fixtures to use the right file extension
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Dec 2, 2024
1 parent 5112bd2 commit 276b0a6
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Disable H5P content-types from the content bank
| contextlevel | reference | contenttype | user | contentname | filepath |
| Course | C1 | contenttype_h5p | admin | filltheblanks | /h5p/tests/fixtures/filltheblanks.h5p |
| Course | C1 | contenttype_h5p | admin | accordion | /h5p/tests/fixtures/ipsums.h5p |
| Course | C1 | contenttype_h5p | admin | invalidh5p | /h5p/tests/fixtures/h5ptest.zip |
| Course | C1 | contenttype_h5p | admin | invalidh5p | /h5p/tests/fixtures/h5ptest.h5p |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And the following config values are set as admin:
Expand Down
6 changes: 3 additions & 3 deletions h5p/tests/api_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1230,17 +1230,17 @@ public static function is_valid_package_provider(): array {
'skipcontent' => true,
],
'Invalid H5P file (as admin)' => [
'filename' => '/fixtures/h5ptest.zip',
'filename' => '/fixtures/h5ptest.h5p',
'expected' => false,
'isadmin' => true,
],
'Invalid H5P file (as user)' => [
'filename' => '/fixtures/h5ptest.zip',
'filename' => '/fixtures/h5ptest.h5p',
'expected' => false,
'isadmin' => false,
],
'Invalid H5P file (as user) skipping content' => [
'filename' => '/fixtures/h5ptest.zip',
'filename' => '/fixtures/h5ptest.h5p',
'expected' => true, // Content check is skipped so the package will be considered valid.
'isadmin' => false,
'onlyupdatelibs' => false,
Expand Down
4 changes: 2 additions & 2 deletions h5p/tests/behat/h5p_libraries.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Upload and list H5P libraries and content types installed
Scenario: Upload an invalid content type.
Given I log in as "admin"
And I navigate to "H5P > Manage H5P content types" in site administration
When I upload "h5p/tests/fixtures/h5ptest.zip" file to "H5P content type" filemanager
When I upload "h5p/tests/fixtures/h5ptest.h5p" file to "H5P content type" filemanager
And I click on "Upload H5P content types" "button" in the "#fitem_id_uploadlibraries" "css_element"
And I wait until the page is ready
Then I should see "Invalid H5P content type"
Expand All @@ -35,7 +35,7 @@ Feature: Upload and list H5P libraries and content types installed
And I should see "Question"
And I should see "1.4" in the "Question" "table_row"
And I should not see "1.3" in the "Question" "table_row"
And I upload "h5p/tests/fixtures/essay.zip" file to "H5P content type" filemanager
And I upload "h5p/tests/fixtures/essay.h5p" file to "H5P content type" filemanager
And I click on "Upload H5P content types" "button" in the "#fitem_id_uploadlibraries" "css_element"
And I wait until the page is ready
# Existing content types are kept and new added
Expand Down
2 changes: 1 addition & 1 deletion h5p/tests/file_storage_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public function test_getUpgradeScript(): void {
public function test_saveFileFromZip(): void {

$ziparchive = new zip_archive();
$path = self::get_fixture_path(__NAMESPACE__, 'h5ptest.zip');
$path = self::get_fixture_path(__NAMESPACE__, 'h5ptest.h5p');
$result = $ziparchive->open($path, file_archive::OPEN);

$files = $ziparchive->list_files();
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions h5p/tests/framework_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ public function test_mayUpdateLibraries(): void {
$this->getDataGenerator()->enrol_user($user->id, $course->id, 'student');

// Create the .h5p file.
$path = self::get_fixture_path(__NAMESPACE__, 'h5ptest.zip');
$path = self::get_fixture_path(__NAMESPACE__, 'h5ptest.h5p');

// Admin and manager should have permission to update libraries.
$file = helper::create_fake_stored_file_from_path($path, $admin->id, $contextsys);
Expand Down Expand Up @@ -861,7 +861,7 @@ public function test_get_file(): void {
$user = $this->getDataGenerator()->create_user();

// The H5P file.
$path = self::get_fixture_path(__NAMESPACE__, 'h5ptest.zip');
$path = self::get_fixture_path(__NAMESPACE__, 'h5ptest.h5p');

// An error should be raised when it's called before initialitzing it.
$this->expectException('coding_exception');
Expand Down
4 changes: 2 additions & 2 deletions h5p/tests/helper_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function test_save_h5p_invalid_file(): void {
$this->setUser($user);

// Prepare an invalid .H5P file.
$path = self::get_fixture_path(__NAMESPACE__, 'h5ptest.zip');
$path = self::get_fixture_path(__NAMESPACE__, 'h5ptest.h5p');
$file = helper::create_fake_stored_file_from_path($path, (int)$user->id);
$factory->get_framework()->set_file($file);
$config = (object)[
Expand Down Expand Up @@ -385,7 +385,7 @@ public function test_get_messages(): void {
$this->assertCount(2, $messages->info);

// When saving an invalid .h5p file, 6 errors should be raised.
$path = self::get_fixture_path(__NAMESPACE__, 'h5ptest.zip');
$path = self::get_fixture_path(__NAMESPACE__, 'h5ptest.h5p');
$file = helper::create_fake_stored_file_from_path($path);
$factory->get_framework()->set_file($file);
$config = (object)[
Expand Down
2 changes: 1 addition & 1 deletion mod/h5pactivity/tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function create_instance($record = null, ?array $options = null): stdClas

// Fill in optional values if not specified.
if (!isset($record->packagefilepath)) {
$record->packagefilepath = $CFG->dirroot.'/h5p/tests/fixtures/h5ptest.zip';
$record->packagefilepath = $CFG->dirroot.'/h5p/tests/fixtures/h5ptest.h5p';
} else if (strpos($record->packagefilepath, $CFG->dirroot) !== 0) {
$record->packagefilepath = "{$CFG->dirroot}/{$record->packagefilepath}";
}
Expand Down

0 comments on commit 276b0a6

Please sign in to comment.