Skip to content

Commit

Permalink
fix codechecker warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
irinahpe committed Jul 4, 2024
1 parent 87dca24 commit d045818
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 15 deletions.
4 changes: 2 additions & 2 deletions tests/backup_restore_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \backup\moodle2
*/
class backup_restore_test extends \advanced_testcase {
final class backup_restore_test extends \advanced_testcase {

public function test_backup_restore() {
public function test_backup_restore(): void {
// TODO this test does not check if userids are correctly mapped.
global $CFG, $DB;
\core_php_time_limit::raise();
Expand Down
2 changes: 1 addition & 1 deletion tests/cron_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \classes\task\cron_task
*/
class cron_test extends \advanced_testcase {
final class cron_test extends \advanced_testcase {

/** @var $teacher */
private $teacher;
Expand Down
23 changes: 19 additions & 4 deletions tests/locallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \locallib
*/
class locallib_test extends \advanced_testcase {
final class locallib_test extends \advanced_testcase {

public function test_simple() {
public function test_simple(): void {
global $DB;
\core_php_time_limit::raise();
$this->resetAfterTest();
Expand Down Expand Up @@ -145,6 +145,13 @@ public function test_simple() {
. 'a student, so this one should not have been distributed.');
}

/**
* Filter allocations by choice
*
* @param $allocations
* @param $choiceid
* @return array
*/
private static function filter_allocations_by_choice($allocations, $choiceid) {
$filterchoiceid = function($elem) use ($choiceid) {
return $elem->{this_db\ratingallocate_allocations::CHOICEID} == $choiceid;
Expand Down Expand Up @@ -292,8 +299,16 @@ public function test_reset_userdata(): void {
$this->assertEquals(2, count($ratingallocate->get_allocations()));

// Keep dates for comparison.
$accesstimestart = $DB->get_record('ratingallocate', ['id' => $ratingallocate->get_ratingallocateid()], 'accesstimestart')->accesstimestart;
$accesstimestop = $DB->get_record('ratingallocate', ['id' => $ratingallocate->get_ratingallocateid()], 'accesstimestop')->accesstimestop;
$accesstimestart = $DB->get_record(
'ratingallocate',
['id' => $ratingallocate->get_ratingallocateid()],
'accesstimestart'
)->accesstimestart;
$accesstimestop = $DB->get_record(
'ratingallocate',
['id' => $ratingallocate->get_ratingallocateid()],
'accesstimestop'
)->accesstimestop;

// Now try and reset.
$data = new \stdClass();
Expand Down
2 changes: 1 addition & 1 deletion tests/mod_generator_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \mod_ratingallocate_generator
*/
class mod_generator_test extends \advanced_testcase {
final class mod_generator_test extends \advanced_testcase {

public function test_create_instance(): void {

Expand Down
2 changes: 1 addition & 1 deletion tests/mod_ratingallocate_choice_groups_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @author David Thompson <david.thompson@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_ratingallocate_choice_groups_test extends \advanced_testcase {
final class mod_ratingallocate_choice_groups_test extends \advanced_testcase {

/** Helper function - Create a range of choices.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/mod_ratingallocate_choice_importer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \choice_importer
*/
class mod_ratingallocate_choice_importer_test extends \advanced_testcase {
final class mod_ratingallocate_choice_importer_test extends \advanced_testcase {

/**
* Return lines of text for a sample CSV file.
Expand Down
2 changes: 1 addition & 1 deletion tests/mod_ratingallocate_privacy_provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \classes\privacy\provider
*/
class mod_ratingallocate_privacy_provider_test extends \core_privacy\tests\provider_testcase {
final class mod_ratingallocate_privacy_provider_test extends \core_privacy\tests\provider_testcase {
/** @var \mod_ratingallocate_generated_module $testmodule */
protected $testmodule;

Expand Down
7 changes: 6 additions & 1 deletion tests/mod_ratingallocate_processor_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @copyright reischmann
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_ratingallocate_processor_test extends \advanced_testcase {
final class mod_ratingallocate_processor_test extends \advanced_testcase {

public function setUp(): void {
global $PAGE;
Expand Down Expand Up @@ -131,6 +131,11 @@ public function test_ratings_table_filter(): void {

}

/**
* @return void
* @throws \coding_exception
* @covers \classes\ratings_and_allocations_table
*/
public function test_ratings_table_groupfilter(): void {
$this->resetAfterTest();

Expand Down
14 changes: 13 additions & 1 deletion tests/mod_ratingallocate_solver_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \solver
*/
class mod_ratingallocate_solver_test extends \basic_testcase {
final class mod_ratingallocate_solver_test extends \basic_testcase {

/**
* Perform race.
*
* @param $groupsnum
* @param $ratersnum
* @return array
*/
private function perform_race($groupsnum, $ratersnum) {
$groupsmaxsizemin = floor($ratersnum / $groupsnum);
$groupsmaxsizemax = ceil($ratersnum / $groupsnum) + 1;
Expand Down Expand Up @@ -89,6 +96,11 @@ private function perform_race($groupsnum, $ratersnum) {
return $result;
}

/**
* Test on random.
*
* @return void
*/
public function teston_random() {
if (!PHPUNIT_LONGTEST) {
return; // This test takes longer than 10s.
Expand Down
4 changes: 2 additions & 2 deletions tests/mod_ratingallocate_status_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @copyright reischmann
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_ratingallocate_status_test extends \advanced_testcase {
final class mod_ratingallocate_status_test extends \advanced_testcase {

public function setUp(): void {
global $PAGE;
Expand All @@ -46,7 +46,7 @@ public function setUp(): void {
*
* @return array
*/
public function ratingallocate_provider(): array {
public static function ratingallocate_provider(): array {
return [
'Rating phase is not started.' => [
3, 6, false, false, \ratingallocate::DISTRIBUTION_STATUS_TOO_EARLY],
Expand Down
13 changes: 13 additions & 0 deletions tests/mod_ratingallocate_strategy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ final class mod_ratingallocate_strategy_test extends \advanced_testcase {

/**
* Test for correct validation of settings
*
* @return void
* @covers \strategy\strategy01_yes_no
*/
public function test_yes_no_validation(): void {
// Attribute required.
Expand All @@ -53,6 +56,8 @@ public function test_yes_no_validation(): void {

/**
* Test for correct validation of settings
*
* @covers \strategy\strategy02_yes_maybe_no
*/
public function test_yes_maybe_no_validation(): void {
// Attribute required.
Expand All @@ -71,6 +76,8 @@ public function test_yes_maybe_no_validation(): void {

/**
* Test for correct validation of settings
*
* @covers \strategy\strategy03_lickert
*/
public function test_lickert_validation(): void {
// Attribute required.
Expand Down Expand Up @@ -101,6 +108,8 @@ public function test_lickert_validation(): void {

/**
* Test for correct validation of settings
*
* @covers \strategy\strategy04_points
*/
public function test_points_validation(): void {
// Attribute required.
Expand Down Expand Up @@ -143,6 +152,8 @@ public function test_points_validation(): void {

/**
* Test for correct validation of settings
*
* @covers \strategy\strategy05_order
*/
public function test_order_validation(): void {
// Attribute required.
Expand All @@ -161,6 +172,8 @@ public function test_order_validation(): void {

/**
* Test for correct validation of settings
*
* @covers \strategy\strategy06_tickyes
*/
public function test_tickyes_validation(): void {
// Attribute required.
Expand Down

0 comments on commit d045818

Please sign in to comment.