diff --git a/tests/external/favourite_package_test.php b/tests/external/favourite_package_test.php index d94b6727..6001d553 100644 --- a/tests/external/favourite_package_test.php +++ b/tests/external/favourite_package_test.php @@ -45,7 +45,7 @@ * @copyright 2024 TU Berlin, innoCampus {@link https://www.questionpy.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class favourite_package_test extends \externallib_advanced_testcase { +final class favourite_package_test extends \externallib_advanced_testcase { /** * This method is called before each test. */ diff --git a/tests/external/get_tags_test.php b/tests/external/get_tags_test.php index d7db4301..9bc0bda2 100644 --- a/tests/external/get_tags_test.php +++ b/tests/external/get_tags_test.php @@ -44,7 +44,7 @@ * @copyright 2024 TU Berlin, innoCampus {@link https://www.questionpy.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class get_tags_test extends \externallib_advanced_testcase { +final class get_tags_test extends \externallib_advanced_testcase { /** * Test that the user needs to be logged in. * diff --git a/tests/external/search_packages_test.php b/tests/external/search_packages_test.php index 19332492..e5061d6e 100644 --- a/tests/external/search_packages_test.php +++ b/tests/external/search_packages_test.php @@ -47,7 +47,7 @@ * @copyright 2023 TU Berlin, innoCampus {@link https://www.questionpy.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class search_packages_test extends \externallib_advanced_testcase { +final class search_packages_test extends \externallib_advanced_testcase { /** * This method is called before each test. */ @@ -839,7 +839,7 @@ public function test_favourites_are_not_shared_across_users(): void { * @return void * @throws moodle_exception */ - public function test_search_with_tags() { + public function test_search_with_tags(): void { global $DB; package_provider(['namespace' => 'ns1', 'tags' => ['a']])->store(); diff --git a/tests/form/elements/element_html_test.php b/tests/form/elements/element_html_test.php index 7dbf23f5..7ff5ab79 100644 --- a/tests/form/elements/element_html_test.php +++ b/tests/form/elements/element_html_test.php @@ -32,7 +32,7 @@ * @copyright 2022 TU Berlin, innoCampus {@link https://www.questionpy.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class element_html_test extends \advanced_testcase { +final class element_html_test extends \advanced_testcase { /** * Implements a snapshot testing approach similar to that of {@link https://jestjs.io/docs/snapshot-testing Jest}. * diff --git a/tests/form/elements/element_json_test.php b/tests/form/elements/element_json_test.php index a7094a95..706f3b3e 100644 --- a/tests/form/elements/element_json_test.php +++ b/tests/form/elements/element_json_test.php @@ -31,7 +31,7 @@ * @copyright 2022 TU Berlin, innoCampus {@link https://www.questionpy.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class element_json_test extends \advanced_testcase { +final class element_json_test extends \advanced_testcase { /** * Serializes values and compares resulting JSON to an expected file. * diff --git a/tests/http_response_container_test.php b/tests/http_response_container_test.php index 3ddbee71..7025a8ae 100644 --- a/tests/http_response_container_test.php +++ b/tests/http_response_container_test.php @@ -26,7 +26,7 @@ * @copyright 2022 Jan Britz, TU Berlin, innoCampus - www.questionpy.org * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class http_response_container_test extends \advanced_testcase { +final class http_response_container_test extends \advanced_testcase { /** * Tests the function get_data with json. * @@ -59,7 +59,7 @@ public function test_get_data_with_json(): void { * @return void * @throws moodle_exception */ - public function test_get_data_not_json() { + public function test_get_data_not_json(): void { $code = 200; $data = 'This is not a json.'; diff --git a/tests/last_used_service_test.php b/tests/last_used_service_test.php index 8d4ceb3a..bf98e82b 100644 --- a/tests/last_used_service_test.php +++ b/tests/last_used_service_test.php @@ -25,14 +25,14 @@ * @copyright 2024 Jan Britz, TU Berlin, innoCampus - www.questionpy.org * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class last_used_service_test extends \advanced_testcase { +final class last_used_service_test extends \advanced_testcase { /** * Tests {@see last_used_service::add()} create correct timestamp. * * @throws moodle_exception * @covers \qtype_questionpy\last_used_service::add */ - public function test_add_creates_entry() { + public function test_add_creates_entry(): void { global $DB; $this->resetAfterTest(); @@ -53,7 +53,7 @@ public function test_add_creates_entry() { * @throws moodle_exception * @covers \qtype_questionpy\last_used_service::add */ - public function test_add_updates_timestamp_if_package_was_already_used() { + public function test_add_updates_timestamp_if_package_was_already_used(): void { global $DB; $this->resetAfterTest(); @@ -81,7 +81,7 @@ public function test_add_updates_timestamp_if_package_was_already_used() { * @throws moodle_exception * @covers \qtype_questionpy\last_used_service::add */ - public function test_add_inserts_entries_if_packages_differ() { + public function test_add_inserts_entries_if_packages_differ(): void { global $DB; $this->resetAfterTest(); @@ -107,7 +107,7 @@ public function test_add_inserts_entries_if_packages_differ() { * @throws moodle_exception * @covers \qtype_questionpy\last_used_service::add */ - public function test_add_inserts_entries_if_contexts_differ() { + public function test_add_inserts_entries_if_contexts_differ(): void { global $DB; $this->resetAfterTest(); @@ -133,7 +133,7 @@ public function test_add_inserts_entries_if_contexts_differ() { * @throws moodle_exception * @covers \qtype_questionpy\last_used_service::add */ - public function test_add_inserts_entries_if_packages_and_contexts_differ() { + public function test_add_inserts_entries_if_packages_and_contexts_differ(): void { global $DB; $this->resetAfterTest(); @@ -175,7 +175,7 @@ public static function context_count_provider(): array { * @dataProvider context_count_provider * @covers \qtype_questionpy\last_used_service::remove_by_package */ - public function test_remove_by_package_removes_the_entries(int $contexts) { + public function test_remove_by_package_removes_the_entries(int $contexts): void { global $DB; $this->resetAfterTest(); @@ -197,7 +197,7 @@ public function test_remove_by_package_removes_the_entries(int $contexts) { * @throws moodle_exception * @covers \qtype_questionpy\last_used_service::remove_by_package */ - public function test_remove_by_package_only_removes_the_given_package() { + public function test_remove_by_package_only_removes_the_given_package(): void { global $DB; $this->resetAfterTest(); diff --git a/tests/localizer_test.php b/tests/localizer_test.php index 1e9ea539..8e8603a2 100644 --- a/tests/localizer_test.php +++ b/tests/localizer_test.php @@ -23,7 +23,7 @@ * @copyright 2022 Jan Britz, TU Berlin, innoCampus - www.questionpy.org * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class localizer_test extends \advanced_testcase { +final class localizer_test extends \advanced_testcase { /** * Test the default of the function get_preferred_language. * diff --git a/tests/package/package_base_test.php b/tests/package/package_base_test.php index 504e65ea..dd818008 100644 --- a/tests/package/package_base_test.php +++ b/tests/package/package_base_test.php @@ -23,7 +23,7 @@ * @copyright 2023 Jan Britz, TU Berlin, innoCampus - www.questionpy.org * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class package_base_test extends \advanced_testcase { +final class package_base_test extends \advanced_testcase { /** * Tests the method get_localized_name. * diff --git a/tests/package/package_raw_test.php b/tests/package/package_raw_test.php index f56f577a..b4bed6ac 100644 --- a/tests/package/package_raw_test.php +++ b/tests/package/package_raw_test.php @@ -31,7 +31,7 @@ * @copyright 2023 Jan Britz, TU Berlin, innoCampus - www.questionpy.org * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class package_raw_test extends \advanced_testcase { +final class package_raw_test extends \advanced_testcase { /** * Provides valid package data. * @@ -138,7 +138,7 @@ public function test_from_array($packagedata): void { * @return void * @throws moodle_exception */ - public function test_faulty_from_array() { + public function test_faulty_from_array(): void { $this->expectException(moodle_exception::class); $faulty = ['faulty' => 'hash']; array_converter::from_array(package_raw::class, $faulty); @@ -154,7 +154,7 @@ public function test_faulty_from_array() { * @return void * @throws moodle_exception */ - public function test_store_package($packagedata) { + public function test_store_package($packagedata): void { global $DB; $this->resetAfterTest(); @@ -219,7 +219,7 @@ public function test_store_package($packagedata) { * @return void * @throws moodle_exception */ - public function test_store_package_twice() { + public function test_store_package_twice(): void { global $DB; $this->resetAfterTest(); @@ -241,7 +241,7 @@ public function test_store_package_twice() { * @return void * @throws moodle_exception */ - public function test_store_already_existing_package_with_different_hash_throws() { + public function test_store_already_existing_package_with_different_hash_throws(): void { $this->resetAfterTest(); $this->expectException(moodle_exception::class); $this->expectExceptionMessage('A package with the same version but different hash already exists.'); @@ -261,7 +261,7 @@ public function test_store_already_existing_package_with_different_hash_throws() * @return void * @throws moodle_exception */ - public function test_store_different_versions_of_a_package() { + public function test_store_different_versions_of_a_package(): void { global $DB; $this->resetAfterTest(); diff --git a/tests/package/package_test.php b/tests/package/package_test.php index a408a890..bb8cc493 100644 --- a/tests/package/package_test.php +++ b/tests/package/package_test.php @@ -30,7 +30,7 @@ * @copyright 2022 Jan Britz, TU Berlin, innoCampus - www.questionpy.org * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class package_test extends \advanced_testcase { +final class package_test extends \advanced_testcase { /** * Tests the method get_by_version. * @@ -38,7 +38,7 @@ class package_test extends \advanced_testcase { * @return void * @throws moodle_exception */ - public function test_get_by_version() { + public function test_get_by_version(): void { $this->resetAfterTest(); // Store a package. @@ -79,7 +79,7 @@ private function assert_records_count(int $pkgversion, int $package, int $langua * @return void * @throws moodle_exception */ - public function test_delete() { + public function test_delete(): void { $this->resetAfterTest(); // Store a package. @@ -99,7 +99,7 @@ public function test_delete() { * @return void * @throws moodle_exception */ - public function test_delete_with_multiple_versions() { + public function test_delete_with_multiple_versions(): void { $this->resetAfterTest(); // Store two versions of the same package. @@ -120,7 +120,7 @@ public function test_delete_with_multiple_versions() { * @return void * @throws moodle_exception */ - public function test_delete_with_multiple_packages() { + public function test_delete_with_multiple_packages(): void { $this->resetAfterTest(); // Store two packages. @@ -144,7 +144,7 @@ public function test_delete_with_multiple_packages() { * @covers \qtype_questionpy\package::equals * @return void */ - public function test_difference_from() { + public function test_difference_from(): void { $package1 = new package(0, 'shortname', 'namespace', [], 'type', 'author', 'url', ['en', 'de']); $package2 = new package(1, 'shortname', 'namespace', [], 'type', 'author', 'url', ['de', 'en']); diff --git a/tests/package/package_version_test.php b/tests/package/package_version_test.php index e59cfdcc..95434f67 100644 --- a/tests/package/package_version_test.php +++ b/tests/package/package_version_test.php @@ -31,14 +31,14 @@ * @copyright 2023 Jan Britz, TU Berlin, innoCampus - www.questionpy.org * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class package_version_test extends \advanced_testcase { +final class package_version_test extends \advanced_testcase { /** * Tests the get_by_id method. * * @covers \package_version::get_by_id * @throws moodle_exception */ - public function test_get_by_id() { + public function test_get_by_id(): void { $this->resetAfterTest(); // Store a package. @@ -59,7 +59,7 @@ public function test_get_by_id() { * @depends test_get_by_id * @throws moodle_exception */ - public function test_get_by_hash() { + public function test_get_by_hash(): void { $this->resetAfterTest(); // Store a package. @@ -80,7 +80,7 @@ public function test_get_by_hash() { * @depends test_get_by_id * @throws moodle_exception */ - public function test_delete() { + public function test_delete(): void { global $DB; $this->resetAfterTest(); @@ -105,7 +105,7 @@ public function test_delete() { * @depends test_get_by_id * @throws moodle_exception */ - public function test_delete_where_multiple_versions_exist() { + public function test_delete_where_multiple_versions_exist(): void { global $DB; $this->resetAfterTest(); diff --git a/tests/question_service_test.php b/tests/question_service_test.php index db0fefcc..639f4169 100644 --- a/tests/question_service_test.php +++ b/tests/question_service_test.php @@ -33,7 +33,7 @@ * @copyright 2022 TU Berlin, innoCampus {@link https://www.questionpy.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class question_service_test extends \advanced_testcase { +final class question_service_test extends \advanced_testcase { /** @var api */ private api $api; @@ -61,7 +61,7 @@ protected function setUp(): void { * @throws moodle_exception * @covers \qtype_questionpy\question_service::get_question */ - public function test_get_question_should_load_package_and_state() { + public function test_get_question_should_load_package_and_state(): void { $this->resetAfterTest(); $package = package_provider(); @@ -88,7 +88,7 @@ public function test_get_question_should_load_package_and_state() { * @throws moodle_exception * @covers \qtype_questionpy\question_service::get_question */ - public function test_get_question_should_return_empty_object_when_no_record() { + public function test_get_question_should_return_empty_object_when_no_record(): void { $this->assertEquals(new stdClass(), $this->questionservice->get_question(42)); } @@ -100,7 +100,7 @@ public function test_get_question_should_return_empty_object_when_no_record() { * @throws moodle_exception * @covers \qtype_questionpy\question_service::upsert_question */ - public function test_upsert_question_should_update_existing_record_if_changed() { + public function test_upsert_question_should_update_existing_record_if_changed(): void { global $PAGE; $this->resetAfterTest(); @@ -142,7 +142,7 @@ public function test_upsert_question_should_update_existing_record_if_changed() * @throws dml_exception * @covers \qtype_questionpy\question_service::upsert_question */ - public function test_upsert_question_should_do_nothing_if_unchanged() { + public function test_upsert_question_should_do_nothing_if_unchanged(): void { global $PAGE; $this->resetAfterTest(); @@ -182,7 +182,7 @@ public function test_upsert_question_should_do_nothing_if_unchanged() { * @throws dml_exception * @covers \qtype_questionpy\question_service::upsert_question */ - public function test_upsert_question_should_insert_record() { + public function test_upsert_question_should_insert_record(): void { global $PAGE; $this->resetAfterTest(); @@ -218,7 +218,7 @@ public function test_upsert_question_should_insert_record() { * @throws dml_exception * @covers \qtype_questionpy\question_service::upsert_question */ - public function test_upsert_question_should_throw_when_package_does_not_exist() { + public function test_upsert_question_should_throw_when_package_does_not_exist(): void { $hash = hash("sha256", rand()); $this->expectException(moodle_exception::class); @@ -242,7 +242,7 @@ public function test_upsert_question_should_throw_when_package_does_not_exist() * @throws dml_exception * @covers \qtype_questionpy\question_service::upsert_question */ - public function test_upsert_question_should_add_package_to_last_used_table() { + public function test_upsert_question_should_add_package_to_last_used_table(): void { global $DB, $PAGE; $this->resetAfterTest(); @@ -285,7 +285,7 @@ public function test_upsert_question_should_add_package_to_last_used_table() { * @throws dml_exception * @covers \qtype_questionpy\question_service::upsert_question */ - public function test_upsert_question_in_same_context_with_same_package_should_only_update_time_used_in_last_used_table() { + public function test_upsert_question_in_same_context_with_same_package_should_only_update_time_used_in_last_used_table(): void { global $DB, $PAGE; $this->resetAfterTest(); @@ -348,7 +348,7 @@ public function test_upsert_question_in_same_context_with_same_package_should_on * @throws moodle_exception * @covers \qtype_questionpy\question_service::upsert_question */ - public function test_delete_question() { + public function test_delete_question(): void { $this->resetAfterTest(); $package = package_provider(); diff --git a/tests/question_type_test.php b/tests/question_type_test.php index 21e63455..d5854753 100644 --- a/tests/question_type_test.php +++ b/tests/question_type_test.php @@ -23,14 +23,14 @@ * @copyright 2022 Martin Gauk, TU Berlin, innoCampus - www.questionpy.org * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class question_type_test extends \advanced_testcase { +final class question_type_test extends \advanced_testcase { /** * Dummy Test (replace when we have real methods testing the question type). * * @coversNothing * @return void */ - public function test_dummy() { + public function test_dummy(): void { $this->assertTrue(true); } } diff --git a/tests/question_ui_metadata_extractor_test.php b/tests/question_ui_metadata_extractor_test.php index 3fae7cba..f9b9904e 100644 --- a/tests/question_ui_metadata_extractor_test.php +++ b/tests/question_ui_metadata_extractor_test.php @@ -24,14 +24,14 @@ * @copyright 2023 TU Berlin, innoCampus {@link https://www.questionpy.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class question_ui_metadata_extractor_test extends \advanced_testcase { +final class question_ui_metadata_extractor_test extends \advanced_testcase { /** * Tests that metadata is correctly extracted from the UI's input elements. * * @covers \qtype_questionpy\question_ui_metadata_extractor * @covers \qtype_questionpy\question_metadata */ - public function test_should_extract_correct_metadata() { + public function test_should_extract_correct_metadata(): void { $input = file_get_contents(__DIR__ . "/question_uis/metadata.xhtml"); $metadata = new question_ui_metadata_extractor($input); diff --git a/tests/question_ui_renderer_test.php b/tests/question_ui_renderer_test.php index d260a570..ebe75644 100644 --- a/tests/question_ui_renderer_test.php +++ b/tests/question_ui_renderer_test.php @@ -26,7 +26,7 @@ * @copyright 2023 TU Berlin, innoCampus {@link https://www.questionpy.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class question_ui_renderer_test extends \advanced_testcase { +final class question_ui_renderer_test extends \advanced_testcase { /** * Asserts that two html strings are equal. * @@ -57,7 +57,7 @@ private function assert_html_string_equals_html_string(string $expectedhtml, str * @throws coding_exception * @covers \qtype_questionpy\question_ui_renderer */ - public function test_should_hide_inline_feedback() { + public function test_should_hide_inline_feedback(): void { $input = file_get_contents(__DIR__ . "/question_uis/feedbacks.xhtml"); $qa = $this->createStub(\question_attempt::class); @@ -82,7 +82,7 @@ public function test_should_hide_inline_feedback() { * @throws coding_exception * @covers \qtype_questionpy\question_ui_renderer */ - public function test_should_show_inline_feedback() { + public function test_should_show_inline_feedback(): void { $input = file_get_contents(__DIR__ . "/question_uis/feedbacks.xhtml"); $qa = $this->createStub(\question_attempt::class); @@ -108,7 +108,7 @@ public function test_should_show_inline_feedback() { * @throws coding_exception * @covers \qtype_questionpy\question_ui_renderer */ - public function test_should_mangle_names() { + public function test_should_mangle_names(): void { $input = file_get_contents(__DIR__ . "/question_uis/ids_and_names.xhtml"); $qa = $this->createStub(\question_attempt::class); @@ -152,7 +152,7 @@ public function test_should_mangle_names() { * @throws coding_exception * @covers \qtype_questionpy\question_ui_renderer */ - public function test_should_shuffle_the_same_way_in_same_attempt() { + public function test_should_shuffle_the_same_way_in_same_attempt(): void { $input = file_get_contents(__DIR__ . "/question_uis/shuffle.xhtml"); $qa = $this->createStub(\question_attempt::class); $qa->method("get_database_id") @@ -172,7 +172,7 @@ public function test_should_shuffle_the_same_way_in_same_attempt() { * @throws coding_exception * @covers \qtype_questionpy\question_ui_renderer */ - public function test_should_resolve_placeholders() { + public function test_should_resolve_placeholders(): void { $input = file_get_contents(__DIR__ . "/question_uis/placeholder.xhtml"); $qa = $this->createStub(\question_attempt::class); $qa->method("get_database_id") @@ -203,7 +203,7 @@ public function test_should_resolve_placeholders() { * @throws coding_exception * @covers \qtype_questionpy\question_ui_renderer */ - public function test_should_remove_placeholders_when_no_corresponding_value() { + public function test_should_remove_placeholders_when_no_corresponding_value(): void { $input = file_get_contents(__DIR__ . "/question_uis/placeholder.xhtml"); $qa = $this->createStub(\question_attempt::class); $qa->method("get_database_id") @@ -230,7 +230,7 @@ public function test_should_remove_placeholders_when_no_corresponding_value() { * @throws coding_exception * @covers \qtype_questionpy\question_ui_renderer */ - public function test_should_soften_validations() { + public function test_should_soften_validations(): void { $input = file_get_contents(__DIR__ . "/question_uis/validations.xhtml"); $qa = $this->createStub(\question_attempt::class); $qa->method("get_database_id") @@ -260,7 +260,7 @@ public function test_should_soften_validations() { * @throws coding_exception * @covers \qtype_questionpy\question_ui_renderer */ - public function test_should_defuse_buttons() { + public function test_should_defuse_buttons(): void { $input = file_get_contents(__DIR__ . "/question_uis/buttons.xhtml"); $qa = $this->createStub(\question_attempt::class); $qa->method("get_database_id") @@ -288,7 +288,7 @@ public function test_should_defuse_buttons() { * @throws coding_exception * @covers \qtype_questionpy\question_ui_renderer */ - public function test_should_remove_element_with_if_role_attribute() { + public function test_should_remove_element_with_if_role_attribute(): void { $input = file_get_contents(__DIR__ . "/question_uis/if-role.xhtml"); $qa = $this->createStub(\question_attempt::class); $qa->method("get_database_id") @@ -315,7 +315,7 @@ public function test_should_remove_element_with_if_role_attribute() { * @throws coding_exception * @covers \qtype_questionpy\question_ui_renderer */ - public function test_should_not_remove_element_with_if_role_attribute() { + public function test_should_not_remove_element_with_if_role_attribute(): void { $input = file_get_contents(__DIR__ . "/question_uis/if-role.xhtml"); $qa = $this->createStub(\question_attempt::class); $qa->method("get_database_id") @@ -349,7 +349,7 @@ public function test_should_not_remove_element_with_if_role_attribute() { * @throws coding_exception * @covers \qtype_questionpy\question_ui_renderer */ - public function test_should_format_floats_in_en() { + public function test_should_format_floats_in_en(): void { $input = file_get_contents(__DIR__ . "/question_uis/format-floats.xhtml"); $qa = $this->createStub(\question_attempt::class); $qa->method("get_database_id")