Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebleu committed Nov 22, 2023
1 parent 61e84e2 commit 955e70a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions tests/bulk_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function setUp():void {
* @covers \enrol_coursecompleted_bulkdelete
* @covers \enrol_coursecompleted\form\bulkdelete
*/
public function test_bulkdeleted() {
public function test_bulkdeleted(): void {
global $CFG, $DB;
require_once($CFG->dirroot . '/enrol/coursecompleted/classes/enrol_coursecompleted_bulkdelete.php');
require_once($CFG->dirroot . '/enrol/coursecompleted/classes/form/bulkdelete.php');
Expand Down Expand Up @@ -99,7 +99,7 @@ public function test_bulkdeleted() {
* @covers \enrol_coursecompleted_bulkedit
* @covers \enrol_coursecompleted\form\bulkedit
*/
public function test_bulkedit() {
public function test_bulkedit(): void {
global $CFG, $DB;
require_once($CFG->dirroot . '/enrol/coursecompleted/classes/enrol_coursecompleted_bulkedit.php');
require_once($CFG->dirroot . '/enrol/coursecompleted/classes/form/bulkedit.php');
Expand Down
20 changes: 10 additions & 10 deletions tests/enrol_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function setUp():void {
* Test if user is enrolled after completing a course.
* @covers \enrol_coursecompleted_observer
*/
public function test_enrolled() {
public function test_enrolled(): void {
global $CFG, $PAGE;
require_once($CFG->dirroot . '/enrol/locallib.php');
require_once($CFG->dirroot . '/enrol/coursecompleted/classes/enrol_coursecompleted_bulkdelete.php');
Expand Down Expand Up @@ -138,7 +138,7 @@ public function test_enrolled() {
* @covers \enrol_coursecompleted_plugin
* @covers \enrol_coursecompleted_observer
*/
public function test_time_enrolled() {
public function test_time_enrolled(): void {
global $CFG, $DB, $PAGE;
require_once($CFG->dirroot . '/enrol/locallib.php');

Expand Down Expand Up @@ -216,7 +216,7 @@ public function test_time_enrolled() {
* Test if user is enrolled after completing a course.
* @covers \enrol_coursecompleted_plugin
*/
public function test_completion() {
public function test_completion(): void {
global $PAGE;
$manager = new \course_enrolment_manager($PAGE, $this->course2);
$this->assertCount(0, $manager->get_user_enrolments($this->student->id));
Expand All @@ -233,7 +233,7 @@ public function test_completion() {
* Test ue.
* @covers \enrol_coursecompleted_plugin
*/
public function test_ue() {
public function test_ue(): void {
global $PAGE;
$ccompletion = new \completion_completion(['course' => $this->course1->id, 'userid' => $this->student->id]);
$ccompletion->mark_complete(time());
Expand Down Expand Up @@ -267,7 +267,7 @@ public function test_ue() {
* Test instances.
* @covers \enrol_coursecompleted_plugin
*/
public function test_instances() {
public function test_instances(): void {
global $DB;
$records = $DB->get_records('enrol', ['enrol' => 'coursecompleted']);
foreach ($records as $record) {
Expand All @@ -280,7 +280,7 @@ public function test_instances() {
* @covers \enrol_coursecompleted_plugin
* @covers \enrol_coursecompleted_observer
*/
public function test_library() {
public function test_library(): void {
global $DB;
$studentrole = $DB->get_field('role', 'id', ['shortname' => 'student']);
$this->assertEquals($this->plugin->get_name(), 'coursecompleted');
Expand Down Expand Up @@ -353,7 +353,7 @@ public function test_library() {
* Test form.
* @covers \enrol_coursecompleted_plugin
*/
public function test_form() {
public function test_form(): void {
$page = new \moodle_page();
$context = \context_course::instance($this->course1->id);
$page->set_context($context);
Expand All @@ -376,7 +376,7 @@ public function test_form() {
* Test access.
* @covers \enrol_coursecompleted_plugin
*/
public function test_access() {
public function test_access(): void {
global $DB;
$context = \context_course::instance($this->course2->id);
$this->assertTrue(has_capability('enrol/coursecompleted:config', $context));
Expand Down Expand Up @@ -406,7 +406,7 @@ public function test_access() {
* Test backup.
* @covers \enrol_coursecompleted_plugin
*/
public function test_backup() {
public function test_backup(): void {
global $CFG, $DB, $PAGE;
$this->assertEquals(3, $DB->count_records('enrol', ['enrol' => 'coursecompleted']));
$ccompletion = new \completion_completion(['course' => $this->course1->id, 'userid' => $this->student->id]);
Expand Down Expand Up @@ -459,7 +459,7 @@ public function test_backup() {
* @covers \enrol_coursecompleted_observer
* @covers \enrol_coursecompleted_plugin
*/
public function test_deletedcourse() {
public function test_deletedcourse(): void {
$sink = $this->redirectEvents();
ob_start();
delete_course($this->course1->id, false);
Expand Down
14 changes: 7 additions & 7 deletions tests/manager_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function setUp():void {
* Test missing enrolid param.
* @covers \enrol_coursecompleted_plugin
*/
public function test_manager_empty_param() {
public function test_manager_empty_param(): void {
global $CFG;
chdir($CFG->dirroot . '/enrol/coursecompleted');
$this->expectException(\moodle_exception::class);
Expand All @@ -88,7 +88,7 @@ public function test_manager_empty_param() {
* Test manager without permission.
* @covers \enrol_coursecompleted_plugin
*/
public function test_manager_wrong_permission() {
public function test_manager_wrong_permission(): void {
global $CFG;
chdir($CFG->dirroot . '/enrol/coursecompleted');
$this->setUser($this->student);
Expand All @@ -102,7 +102,7 @@ public function test_manager_wrong_permission() {
* Test manager wrong permission.
* @covers \enrol_coursecompleted_plugin
*/
public function test_manager_wrong_permission2() {
public function test_manager_wrong_permission2(): void {
global $CFG, $DB;
chdir($CFG->dirroot . '/enrol/coursecompleted');
$generator = $this->getDataGenerator();
Expand All @@ -127,7 +127,7 @@ public function test_manager_wrong_permission2() {
* @covers \enrol_coursecompleted\form\bulkedit
* @covers \enrol_coursecompleted\form\bulkdelete
*/
public function test_manager_bare() {
public function test_manager_bare(): void {
global $CFG;
chdir($CFG->dirroot . '/enrol/coursecompleted');
$_POST['enrolid'] = $this->instance->id;
Expand All @@ -141,7 +141,7 @@ public function test_manager_bare() {
* Test manager oldusers.
* @covers \enrol_coursecompleted_plugin
*/
public function test_manager_oldusers() {
public function test_manager_oldusers(): void {
global $CFG;
$this->preventResetByRollback();
$this->setAdminUser();
Expand All @@ -163,7 +163,7 @@ public function test_manager_oldusers() {
* Test submit manager oldusers.
* @covers \enrol_coursecompleted_plugin
*/
public function test_manager_submit() {
public function test_manager_submit(): void {
global $CFG;
$this->preventResetByRollback();
$this->setAdminUser();
Expand All @@ -188,7 +188,7 @@ public function test_manager_submit() {
* Tests settings.
* @covers \enrol_coursecompleted_plugin
*/
public function test_enrol_courescompleted_settings() {
public function test_enrol_courescompleted_settings(): void {
global $ADMIN, $CFG;
require_once($CFG->dirroot . '/lib/adminlib.php');
$ADMIN = admin_get_root(true, true);
Expand Down
16 changes: 8 additions & 8 deletions tests/other_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function setUp():void {
* Basic test.
* @covers \enrol_coursecompleted_plugin
*/
public function test_basics() {
public function test_basics(): void {
$this->assertTrue(enrol_is_enabled('coursecompleted'));
$this->assertEquals(ENROL_EXT_REMOVED_SUSPENDNOROLES, get_config('enrol_coursecompleted', 'expiredaction'));
$plugin = enrol_get_plugin('coursecompleted');
Expand All @@ -71,7 +71,7 @@ public function test_basics() {
* Test other files.
* @covers \enrol_coursecompleted_plugin
*/
public function test_files() {
public function test_files(): void {
global $CFG;
include($CFG->dirroot . '/enrol/coursecompleted/db/tasks.php');
include($CFG->dirroot . '/enrol/coursecompleted/db/access.php');
Expand All @@ -82,7 +82,7 @@ public function test_files() {
* Test invalid instance.
* @covers \enrol_coursecompleted_plugin
*/
public function test_invalid_instance() {
public function test_invalid_instance(): void {
$plugin = enrol_get_plugin('coursecompleted');
$tst = new \stdClass();
$tst->enrol = 'wrong';
Expand All @@ -95,7 +95,7 @@ public function test_invalid_instance() {
* Test static enrol from past.
* @covers \enrol_coursecompleted_plugin
*/
public function test_static_past() {
public function test_static_past(): void {
global $CFG, $DB;
require_once($CFG->libdir.'/completionlib.php');
$generator = $this->getDataGenerator();
Expand All @@ -121,7 +121,7 @@ public function test_static_past() {
* Test invalid role.
* @covers \enrol_coursecompleted_observer
*/
public function test_invalid_role() {
public function test_invalid_role(): void {
global $DB;
$generator = $this->getDataGenerator();
$plugin = enrol_get_plugin('coursecompleted');
Expand Down Expand Up @@ -155,7 +155,7 @@ public function test_invalid_role() {
* @covers \enrol_coursecompleted_observer
* @covers \enrol_coursecompleted_plugin
*/
public function test_groups_child() {
public function test_groups_child(): void {
global $DB;
$generator = $this->getDataGenerator();
$plugin = enrol_get_plugin('coursecompleted');
Expand Down Expand Up @@ -204,7 +204,7 @@ public function test_groups_child() {
* Test expiration task.
* @covers \enrol_coursecompleted\task\process_expirations
*/
public function test_task() {
public function test_task(): void {
$task = new \enrol_coursecompleted\task\process_expirations;
$this->assertEquals('Course completed enrolment expiry task', $task->get_name());
ob_start();
Expand All @@ -218,7 +218,7 @@ public function test_task() {
* Test adhoc sending of welcome messages.
* @covers \enrol_coursecompleted\task\send_welcome
*/
public function test_adhoc_email_welcome_message() {
public function test_adhoc_email_welcome_message(): void {
global $DB;
$generator = $this->getDataGenerator();
$sink = $this->redirectEmails();
Expand Down
2 changes: 1 addition & 1 deletion tests/privacy/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class privacy_test extends provider_testcase {
* Test returning metadata.
* @covers \enrol_coursecompleted\privacy\provider
*/
public function test_get_metadata() {
public function test_get_metadata(): void {
$this->resetAfterTest(true);
$collection = new \core_privacy\local\metadata\collection('enrol_coursecompleted');
$reason = \enrol_coursecompleted\privacy\provider::get_reason($collection);
Expand Down

0 comments on commit 955e70a

Please sign in to comment.