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
@@ -80,7 +80,7 @@ class task_check_subscriptions_test extends \advanced_testcase {
/**
* Test to confirm the task is named correctly.
*/
public function test_task_name() {
public function test_task_name(): void {
$task = new \tool_monitor\task\check_subscriptions();
$this->assertEquals(get_string('taskchecksubscriptions', 'tool_monitor'), $task->get_name());
}
@@ -88,7 +88,7 @@ class task_check_subscriptions_test extends \advanced_testcase {
/**
* Test to confirm that site level subscriptions are activated and deactivated according to system capabilities.
*/
public function test_site_level_subscription() {
public function test_site_level_subscription(): void {
// Create a site level subscription.
$monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor');
$sub = new \stdClass();
@@ -119,7 +119,7 @@ class task_check_subscriptions_test extends \advanced_testcase {
/**
* Test to confirm that if the module is disabled, no changes are made to active subscriptions.
*/
public function test_module_disabled() {
public function test_module_disabled(): void {
set_config('enablemonitor', 0, 'tool_monitor');
// Subscription should be active to start with.
@@ -137,7 +137,7 @@ class task_check_subscriptions_test extends \advanced_testcase {
/**
* Test to confirm an active, valid subscription stays active once the scheduled task is run.
*/
public function test_active_unaffected() {
public function test_active_unaffected(): void {
// Enrol the user as a teacher. This role should have the required capability.
$this->getDataGenerator()->enrol_user($this->user->id, $this->course->id, $this->teacherrole->id);
@@ -156,7 +156,7 @@ class task_check_subscriptions_test extends \advanced_testcase {
/**
* Test to confirm that a subscription for a user without an enrolment to the course is made inactive.
*/
public function test_course_enrolment() {
public function test_course_enrolment(): void {
// Subscription should be active until deactivated by the scheduled task. Remember, by default the test setup
// doesn't enrol the user, so the first run of the task should deactivate it.
$this->assertEquals(true, \tool_monitor\subscription_manager::subscription_is_active($this->subscription));
@@ -184,7 +184,7 @@ class task_check_subscriptions_test extends \advanced_testcase {
/**
* Test to confirm that subscriptions for enrolled users without the required capability are made inactive.
*/
public function test_enrolled_user_with_no_capability() {
public function test_enrolled_user_with_no_capability(): void {
// Enrol the user. By default, students won't have the required capability.
$this->getDataGenerator()->enrol_user($this->user->id, $this->course->id, $this->studentrole->id);
@@ -203,7 +203,7 @@ class task_check_subscriptions_test extends \advanced_testcase {
/**
* Test to confirm that subscriptions for users who fail can_access_course(), are deactivated.
*/
public function test_can_access_course() {
public function test_can_access_course(): void {
// Enrol the user as a teacher. This role should have the required capability.
$this->getDataGenerator()->enrol_user($this->user->id, $this->course->id, $this->teacherrole->id);
@@ -229,7 +229,7 @@ class task_check_subscriptions_test extends \advanced_testcase {
/**
* Test to confirm that subscriptions for enrolled users who don't have CM access, are deactivated.
*/
public function test_cm_access() {
public function test_cm_access(): void {
// Enrol the user as a student but grant to ability to subscribe. Students cannot view hidden activities.
$context = \context_course::instance($this->course->id);
assign_capability('tool/monitor:subscribe', CAP_ALLOW, $this->studentrole->id, $context);
@@ -284,7 +284,7 @@ class task_check_subscriptions_test extends \advanced_testcase {
/**
* Test to confirm that long term inactive subscriptions are removed entirely.
*/
public function test_stale_subscription_removal() {
public function test_stale_subscription_removal(): void {
global $DB;
// Manually set the inactivedate to 1 day older than the limit allowed.
$daysold = 1 + \tool_monitor\subscription_manager::INACTIVE_SUBSCRIPTION_LIFESPAN_IN_DAYS;
@@ -307,7 +307,7 @@ class task_check_subscriptions_test extends \advanced_testcase {
/**
* Test to confirm that subscriptions for a partially set up user are deactivated.
*/
public function test_user_not_fully_set_up() {
public function test_user_not_fully_set_up(): void {
global $DB;
// Enrol the user as a teacher.
@@ -331,7 +331,7 @@ class task_check_subscriptions_test extends \advanced_testcase {
/**
* Test to confirm that a suspended user's subscriptions are deactivated properly.
*/
public function test_suspended_user() {
public function test_suspended_user(): void {
global $DB;
// Enrol the user as a teacher. This role should have the required capability.