Skip to content

Commit

Permalink
MDL-81522 phpunit: Add a few non-void return types to tests
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
stronk7 committed May 31, 2024
1 parent 1d77d06 commit e1acd8e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/filestorage/tests/file_storage_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function test_create_file_from_pathname(): void {
*
* @covers ::get_file
*/
public function test_get_file() {
public function test_get_file(): stored_file {
global $CFG;

$this->resetAfterTest(false);
Expand Down
4 changes: 2 additions & 2 deletions lib/phpunit/tests/advanced_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public function test_message_processors_reset(): void {
$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);

Expand Down Expand Up @@ -544,7 +544,7 @@ public function test_message_redirection() {
/**
* @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');
}
Expand Down
6 changes: 3 additions & 3 deletions lib/tests/navigationlib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public function test_module_extends_navigation(): void {
$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('/');
Expand Down Expand Up @@ -452,7 +452,7 @@ public function test_cache_set(): void {
$this->assertEquals($cache->software, 'Moodle');
}

public function test_setting___construct() {
public function test_setting___construct(): settings_navigation {
global $PAGE, $SITE;

$this->resetAfterTest(false);
Expand All @@ -470,7 +470,7 @@ public function test_setting___construct() {
* @param mixed $node
* @return mixed
*/
public function test_setting__initialise($node) {
public function test_setting__initialise($node): settings_navigation {
$this->resetAfterTest(false);

$node->initialise();
Expand Down

0 comments on commit e1acd8e

Please sign in to comment.