Skip to content

Commit

Permalink
Moodle CI Test
Browse files Browse the repository at this point in the history
  • Loading branch information
NinaHerrmann committed Dec 27, 2023
1 parent 1b17747 commit 270215a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
2 changes: 0 additions & 2 deletions classes/table/never_logged_in_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

use core_user\fields;

defined('MOODLE_INTERNAL') || die();

/**
* Create a class for a custom sql_table for the tool_cleanupusers
*
Expand Down
2 changes: 0 additions & 2 deletions classes/table/users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

use core_user\fields;

defined('MOODLE_INTERNAL') || die();

/**
* Create a class for a custom sql_table for the tool_cleanupusers
*
Expand Down
24 changes: 12 additions & 12 deletions tests/tool_cleanupusers_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function test_archiveduser_deleteme() {
* usersuspendedbypluginandmanually | tendaysago | yes | yes | no
* usersuspendedbyplugin | oneyearago | yes | yes | no
* @see archiveduser
* @covers archiveduser activate_me function.
* @covers \archiveduser activate_me function.
*/
public function test_archiveduser_activateme() {
global $DB;
Expand Down Expand Up @@ -183,7 +183,7 @@ public function test_archiveduser_activateme() {
* Only uses an admin user and a user that was already suspended manually.
* @throws \tool_cleanupusers\cleanupusers_exception
* @throws dml_exception
* @covers archiveduser archive_me function.
* @covers \archiveduser archive_me function.
*/
public function test_exception_archiveme () {
global $DB, $USER;
Expand All @@ -207,7 +207,7 @@ public function test_exception_archiveme () {
$this->expectException('tool_cleanupusers\cleanupusers_exception');
$this->expectExceptionMessage('Not able to suspend user');
$suspendedmanually->archive_me();
$recordtooltable = $DB->get_record('tool_cleanupusers', array('id' => $data['usersuspendedmanually']->id));
$recordtooltable = $DB->get_record('tool_cleanupusers', ['id' => $data['usersuspendedmanually']->id]);
$this->assertEmpty($recordtooltable);

$this->resetAfterTest(true);
Expand All @@ -222,7 +222,7 @@ public function test_exception_archiveme () {
* admin | - | no | no | no
* @throws \tool_cleanupusers\cleanupusers_exception
* @throws dml_exception
* @covers archiveduser delete_me function.
* @covers \archiveduser delete_me function.
*/
public function test_exception_deleteme () {
global $DB, $USER;
Expand Down Expand Up @@ -281,7 +281,7 @@ public function test_exception_deleteme () {
* admin | - | no | no | no
* @throws \tool_cleanupusers\cleanupusers_exception
* @throws dml_exception
* @covers archiveduser activate_me function.
* @covers \archiveduser activate_me function.
*/
public function test_exception_activateme () {
global $DB, $USER;
Expand Down Expand Up @@ -393,15 +393,15 @@ public function test_cronjob() {
$msg = str_replace(["\r\n", "\r", "\n", "<br>", "</br>"], '', $messages[0]->body);

$this->assertStringContainsString('In the last cron-job 1 users were archived',
$msg); // useroneyearnotloggedin
$msg); // Useroneyearnotloggedin.
$this->assertStringContainsString('In the last cron-job 1 users were deleted',
$msg); // usersuspendedbyplugin
$msg); // Usersuspendedbyplugin.
$this->assertStringContainsString('In the last cron-job 1 users caused exception and could not be deleted',
$msg); // 236465(from this function) and userdeleted, but deleted users are already filtered
$msg); // 236465(from this function) and userdeleted, but deleted users are already filtered.
$this->assertStringContainsString('In the last cron-job 1 users caused exception and could not be suspended',
$msg); // userinconsistentsuspended
$msg); // Userinconsistentsuspended.
$this->assertStringContainsString('In the last cron-job 1 users caused exception and could not be reactivated',
$msg); // originaluser
$msg); // Originaluser.

// Users not changed by the Cronjob.
$recordusertable = $DB->get_record('user', ['id' => $data['user']->id]);
Expand Down Expand Up @@ -517,7 +517,7 @@ public function test_logging() {

/**
* Methods recommended by moodle to assure database and dataroot is reset.
* @covers archiveduser actually a DB test.
* @covers \archiveduser actually a DB test.
*/
public function test_deleting() {
global $DB;
Expand All @@ -530,7 +530,7 @@ public function test_deleting() {

/**
* Methods recommended by moodle to assure database is reset.
* @covers archiveduser actually a DB test.
* @covers \archiveduser actually a DB test.
*/
public function test_user_table_was_reset() {
global $DB;
Expand Down

0 comments on commit 270215a

Please sign in to comment.