From 6c35a65e1ac5f2c2a84daafcfeeac5760d1ba9b9 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Thu, 30 May 2024 15:46:39 +0200 Subject: [PATCH] MDL-81522 phpunit: Add a few non-void return types to tests This is the final (3rd) commit, where we are adding missing return types to a few tests (using @depends) which return types are non-void, but something really returned (for consume by the dependent test). --- lib/filestorage/tests/file_storage_test.php | 2 +- lib/phpunit/tests/advanced_test.php | 4 ++-- lib/tests/navigationlib_test.php | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/filestorage/tests/file_storage_test.php b/lib/filestorage/tests/file_storage_test.php index 2c1500942b9..7ca75a1e202 100644 --- a/lib/filestorage/tests/file_storage_test.php +++ b/lib/filestorage/tests/file_storage_test.php @@ -209,7 +209,7 @@ class file_storage_test extends \advanced_testcase { * * @covers ::get_file */ - public function test_get_file() { + public function test_get_file(): stored_file { global $CFG; $this->resetAfterTest(false); diff --git a/lib/phpunit/tests/advanced_test.php b/lib/phpunit/tests/advanced_test.php index b876bacadf4..179864489a8 100644 --- a/lib/phpunit/tests/advanced_test.php +++ b/lib/phpunit/tests/advanced_test.php @@ -422,7 +422,7 @@ class advanced_test extends \advanced_testcase { $this->assertEquals(count($processors1) + 1, count($processors3)); } - public function test_message_redirection() { + public function test_message_redirection(): \phpunit_message_sink { $this->preventResetByRollback(); // Messaging is not compatible with transactions... $this->resetAfterTest(false); @@ -544,7 +544,7 @@ class advanced_test extends \advanced_testcase { /** * @depends test_message_redirection */ - public function test_message_redirection_noreset($sink): void { + public function test_message_redirection_noreset(\phpunit_message_sink $sink): void { if ($this->isInIsolation()) { $this->markTestSkipped('State cannot be carried over between tests in isolated tests'); } diff --git a/lib/tests/navigationlib_test.php b/lib/tests/navigationlib_test.php index 522af3ff65c..76c45426d3e 100644 --- a/lib/tests/navigationlib_test.php +++ b/lib/tests/navigationlib_test.php @@ -358,7 +358,7 @@ class navigationlib_test extends \advanced_testcase { $this->assertFalse($node->exposed_module_extends_navigation('test1')); } - public function test_navbar_prepend_and_add() { + public function test_navbar_prepend_and_add(): \moodle_page { global $PAGE; // Unfortunate hack needed because people use global $PAGE around the place. $PAGE->set_url('/'); @@ -452,7 +452,7 @@ class navigationlib_test extends \advanced_testcase { $this->assertEquals($cache->software, 'Moodle'); } - public function test_setting___construct() { + public function test_setting___construct(): settings_navigation { global $PAGE, $SITE; $this->resetAfterTest(false); @@ -470,7 +470,7 @@ class navigationlib_test extends \advanced_testcase { * @param mixed $node * @return mixed */ - public function test_setting__initialise($node) { + public function test_setting__initialise($node): settings_navigation { $this->resetAfterTest(false); $node->initialise();