MDL-81522 phpunit: Add missing void return type to all tests

While this change is not 100% required now, it's good habit
and we are checking for it since Moodle 4.4.

All the changes in this commit have been applied automatically
using the moodle.PHPUnit.TestReturnType sniff and are, exclusively
adding the ": void" return types when missing.
This commit is contained in:
Eloy Lafuente (stronk7)
2024-06-11 12:18:04 +02:00
parent db07c09afc
commit 1093256560
1360 changed files with 9928 additions and 9928 deletions
+16 -16
View File
@@ -31,7 +31,7 @@ class advanced_test extends \advanced_testcase {
require_once(__DIR__ . '/fixtures/adhoc_test_task.php');
}
public function test_debugging() {
public function test_debugging(): void {
global $CFG;
$this->resetAfterTest();
@@ -76,7 +76,7 @@ class advanced_test extends \advanced_testcase {
$this->assertDebuggingCalled('pokus', DEBUG_MINIMAL);
}
public function test_set_user() {
public function test_set_user(): void {
global $USER, $DB, $SESSION;
$this->resetAfterTest();
@@ -123,7 +123,7 @@ class advanced_test extends \advanced_testcase {
$this->assertObjectNotHasProperty('sometestvalue', $SESSION);
}
public function test_set_admin_user() {
public function test_set_admin_user(): void {
global $USER;
$this->resetAfterTest();
@@ -133,7 +133,7 @@ class advanced_test extends \advanced_testcase {
$this->assertTrue(is_siteadmin());
}
public function test_set_guest_user() {
public function test_set_guest_user(): void {
global $USER;
$this->resetAfterTest();
@@ -143,7 +143,7 @@ class advanced_test extends \advanced_testcase {
$this->assertTrue(isguestuser());
}
public function test_database_reset() {
public function test_database_reset(): void {
global $DB;
$this->resetAfterTest();
@@ -206,7 +206,7 @@ class advanced_test extends \advanced_testcase {
$this->assertEquals(2, $DB->count_records('user'));
}
public function test_change_detection() {
public function test_change_detection(): void {
global $DB, $CFG, $COURSE, $SITE, $USER;
$this->preventResetByRollback();
@@ -287,12 +287,12 @@ class advanced_test extends \advanced_testcase {
}
}
public function test_getDataGenerator() {
public function test_getDataGenerator(): void {
$generator = $this->getDataGenerator();
$this->assertInstanceOf('testing_data_generator', $generator);
}
public function test_database_mock1() {
public function test_database_mock1(): void {
global $DB;
try {
@@ -306,14 +306,14 @@ class advanced_test extends \advanced_testcase {
// Rest continues after reset.
}
public function test_database_mock2() {
public function test_database_mock2(): void {
global $DB;
// Now the database should be back to normal.
$this->assertFalse($DB->get_record('user', array('id'=>9999)));
}
public function test_assert_time_current() {
public function test_assert_time_current(): void {
$this->assertTimeCurrent(time());
$this->setCurrentTimeStart();
@@ -395,7 +395,7 @@ class advanced_test extends \advanced_testcase {
];
}
public function test_message_processors_reset() {
public function test_message_processors_reset(): void {
global $DB;
$this->resetAfterTest(true);
@@ -544,7 +544,7 @@ class advanced_test extends \advanced_testcase {
/**
* @depends test_message_redirection
*/
public function test_message_redirection_noreset($sink) {
public function test_message_redirection_noreset($sink): void {
if ($this->isInIsolation()) {
$this->markTestSkipped('State cannot be carried over between tests in isolated tests');
}
@@ -575,11 +575,11 @@ class advanced_test extends \advanced_testcase {
/**
* @depends test_message_redirection_noreset
*/
public function test_message_redirection_reset() {
public function test_message_redirection_reset(): void {
$this->assertFalse(\phpunit_util::is_redirecting_messages(), 'Test reset must stop message redirection.');
}
public function test_set_timezone() {
public function test_set_timezone(): void {
global $CFG;
$this->resetAfterTest();
@@ -622,7 +622,7 @@ class advanced_test extends \advanced_testcase {
}
public function test_locale_reset() {
public function test_locale_reset(): void {
global $CFG;
$this->resetAfterTest();
@@ -671,7 +671,7 @@ class advanced_test extends \advanced_testcase {
/**
* This test sets a user agent and makes sure that it is cleared when the test is reset.
*/
public function test_it_resets_useragent_after_test() {
public function test_it_resets_useragent_after_test(): void {
$this->resetAfterTest();
$fakeagent = 'New user agent set.';
+5 -5
View File
@@ -42,7 +42,7 @@ class basic_test extends \basic_testcase {
* Tests that bootstrapping has occurred correctly
* @return void
*/
public function test_bootstrap() {
public function test_bootstrap(): void {
global $CFG;
// The httpswwwroot has been deprecated, we keep it as an alias for backwards compatibility with plugins only.
@@ -55,7 +55,7 @@ class basic_test extends \basic_testcase {
* This is just a verification if I understand the PHPUnit assert docs right --skodak
* @return void
*/
public function test_assert_behaviour() {
public function test_assert_behaviour(): void {
// Arrays.
$a = array('a', 'b', 'c');
$b = array('a', 'c', 'b');
@@ -120,7 +120,7 @@ class basic_test extends \basic_testcase {
* Make sure there are no sloppy Windows line endings
* that would break our tests.
*/
public function test_lineendings() {
public function test_lineendings(): void {
$string = <<<STRING
a
b
@@ -132,7 +132,7 @@ STRING;
/**
* Make sure asserts in setUp() do not create problems.
*/
public function test_setup_assert() {
public function test_setup_assert(): void {
$this->assertTrue($this->testassertexecuted);
$this->testassertexecuted = false;
}
@@ -140,7 +140,7 @@ STRING;
/**
* Test assert Tag
*/
public function test_assert_tag() {
public function test_assert_tag(): void {
// This should succeed.
self::assertTag(['id' => 'testid'], "<div><span id='testid'></span></div>");
$this->expectException(\PHPUnit\Framework\ExpectationFailedException::class);
+7 -7
View File
@@ -42,7 +42,7 @@ class phpunit_dataset_test extends advanced_testcase {
/**
* @covers ::from_files
*/
public function test_from_files() {
public function test_from_files(): void {
$ds = new phpunit_dataset();
@@ -148,7 +148,7 @@ class phpunit_dataset_test extends advanced_testcase {
* @covers ::from_file
*/
public function test_from_file(string $fullpath, string $tablename, ?string $exception,
array $tables, array $columns, array $rows) {
array $tables, array $columns, array $rows): void {
$ds = new phpunit_dataset();
@@ -238,7 +238,7 @@ class phpunit_dataset_test extends advanced_testcase {
* @covers ::from_string
*/
public function test_from_string(string $content, string $type, string $tablename, ?string $exception,
array $tables, array $columns, array $rows) {
array $tables, array $columns, array $rows): void {
$ds = new phpunit_dataset();
@@ -381,7 +381,7 @@ class phpunit_dataset_test extends advanced_testcase {
* @covers ::from_array
*/
public function test_from_array(array $structure, ?string $exception,
array $tables, array $columns, array $rows, ?bool $repeated = false) {
array $tables, array $columns, array $rows, ?bool $repeated = false): void {
$ds = new phpunit_dataset();
@@ -472,7 +472,7 @@ class phpunit_dataset_test extends advanced_testcase {
* @covers ::load_csv
*/
public function test_load_csv(array $files, ?string $exception,
array $tables, array $columns, array $rows) {
array $tables, array $columns, array $rows): void {
$ds = new phpunit_dataset();
@@ -640,7 +640,7 @@ class phpunit_dataset_test extends advanced_testcase {
* @covers ::load_xml
*/
public function test_load_xml(array $files, ?string $exception,
array $tables, array $columns, array $rows) {
array $tables, array $columns, array $rows): void {
$ds = new phpunit_dataset();
@@ -908,7 +908,7 @@ class phpunit_dataset_test extends advanced_testcase {
* @dataProvider get_rows_provider
* @covers ::get_rows
*/
public function test_get_rows(array $files, array $filter, ?string $exception, array $rows) {
public function test_get_rows(array $files, array $filter, ?string $exception, array $rows): void {
$ds = new phpunit_dataset();
+1 -1
View File
@@ -28,7 +28,7 @@ class util_test extends \advanced_testcase {
/**
* @dataProvider set_table_modified_by_sql_provider
*/
public function test_set_table_modified_by_sql($sql, $expectations) {
public function test_set_table_modified_by_sql($sql, $expectations): void {
\phpunit_util::reset_updated_table_list();
\phpunit_util::set_table_modified_by_sql($sql);
foreach ($expectations as $table => $present) {