Skip to content

Commit

Permalink
updates to comply latest GHA requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Opitz committed Jan 29, 2024
1 parent 6e2bffc commit adabf21
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
6 changes: 3 additions & 3 deletions tests/freezecontext_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function setUp(): void {
* @covers \block_lifecycle\task\freezecontext::get_name()
* @return void
*/
public function test_get_name() {
public function test_get_name(): void {
$task = new freezecontext();
$this->assertEquals('Task to freeze course context', $task->get_name());
}
Expand All @@ -61,10 +61,10 @@ public function test_get_name() {
* Test execute.
*
* @covers \block_lifecycle\task\freezecontext::execute()
* @throws \coding_exception
* @return void
* @throws \dml_exception
*/
public function test_execute() {
public function test_execute(): void {
// Suppress text output during tests.
$this->setOutputCallback(function(){
});
Expand Down
39 changes: 21 additions & 18 deletions tests/manager_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function setUp(): void {
* @return void
* @throws \dml_exception
*/
public function test_get_potential_academic_years() {
public function test_get_potential_academic_years(): void {
$years = manager::get_potential_academic_years();
$this->assertCount(4, $years);

Expand All @@ -112,7 +112,7 @@ public function test_get_potential_academic_years() {
* @return void
* @throws \dml_exception
*/
public function test_get_clc_custom_course_fields() {
public function test_get_clc_custom_course_fields(): void {
$fields = manager::get_clc_custom_course_fields();
$this->assertCount(2, $fields);
}
Expand All @@ -121,24 +121,25 @@ public function test_get_clc_custom_course_fields() {
* Test get_courses_for_context_freezing
*
* @covers \block_lifecycle\manager::get_courses_for_context_freezing()
* @return void
* @throws \dml_exception
*/
public function test_get_courses_for_context_freezing() {
public function test_get_courses_for_context_freezing(): void {
$coursestofreeze = manager::get_courses_for_context_freezing();

// Test only one valid course can be found.
$this->assertCount(1, $coursestofreeze);
$this->assertEquals($this->courseshouldbefrozen->id, $coursestofreeze[0]->id);
}


/**
* Test freeze_course.
*
* @covers \block_lifecycle\manager::freeze_course()
* @throws \coding_exception
* @return void
* @throws coding_exception
*/
public function test_freeze_course() {
public function test_freeze_course(): void {
$dg = $this->getDataGenerator();
// Create course, set start date 2020-09-01, end date 2021-06-30.
$course = $dg->create_course(['startdate' => 1598914800, 'enddate' => 1625007600, 'customfield_course_year' => '2020']);
Expand All @@ -164,9 +165,11 @@ public function test_freeze_course() {
* Test check_course_is_eligible_for_context_freezing.
*
* @covers \block_lifecycle\manager::check_course_is_eligible_for_context_freezing()
* @return void
* @throws \ReflectionException
* @throws coding_exception
*/
public function test_check_course_is_eligible_for_context_freezing() {
public function test_check_course_is_eligible_for_context_freezing(): void {
$mockedinstance = $this->getMockBuilder(manager::class)
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -233,9 +236,10 @@ public function test_check_course_is_eligible_for_context_freezing() {
* Test get_course_clc_academic_year.
*
* @covers \block_lifecycle\manager::get_course_clc_academic_year()
* @return void
* @throws \ReflectionException
*/
public function test_get_course_clc_academic_year() {
public function test_get_course_clc_academic_year(): void {
$mockedinstance = $this->getMockBuilder(manager::class)
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -269,7 +273,7 @@ public function test_get_course_clc_academic_year() {
* @return void
* @throws \ReflectionException
*/
public function test_get_course_lifecycle_info() {
public function test_get_course_lifecycle_info(): void {
// Test course academic year is 2020.
$result = manager::get_course_lifecycle_info($this->course1->id);
$this->assertEquals(['class' => '', 'text' => 'Moodle 2020/21'], $result);
Expand All @@ -291,7 +295,7 @@ public function test_get_course_lifecycle_info() {
* @throws \dml_exception
* @throws coding_exception
*/
public function test_should_show_ay_label() {
public function test_should_show_ay_label(): void {
$dg = $this->getDataGenerator();
// Create courses.
// Start date 2021-09-01.
Expand Down Expand Up @@ -327,7 +331,6 @@ public function test_should_show_ay_label() {
$this->assertFalse($result);
}


/**
* Test should_show_auto_freezing_preferences().
*
Expand All @@ -336,7 +339,7 @@ public function test_should_show_ay_label() {
* @throws \dml_exception
* @throws coding_exception
*/
public function test_should_show_auto_freezing_preferences() {
public function test_should_show_auto_freezing_preferences(): void {
$dg = $this->getDataGenerator();

// Test teacher can see the block options.
Expand Down Expand Up @@ -375,7 +378,7 @@ public function test_should_show_auto_freezing_preferences() {
* @throws \dml_exception
* @throws coding_exception
*/
public function test_update_auto_freezing_preferences() {
public function test_update_auto_freezing_preferences(): void {
$dg = $this->getDataGenerator();
$course = $dg->create_course();
$preferences = new \stdClass();
Expand Down Expand Up @@ -411,7 +414,7 @@ public function test_update_auto_freezing_preferences() {
* @covers \block_lifecycle\manager::is_course_frozen()
* @return void
*/
public function test_is_course_frozen() {
public function test_is_course_frozen(): void {
// Test course is not frozen.
$result = manager::is_course_frozen($this->course1->id);
$this->assertFalse($result);
Expand All @@ -430,7 +433,7 @@ public function test_is_course_frozen() {
* @return void
* @throws \dml_exception
*/
public function test_get_auto_context_freezing_preferences() {
public function test_get_auto_context_freezing_preferences(): void {
$result = manager::get_auto_context_freezing_preferences($this->courseshouldbefrozen->id);
$this->assertEquals('0', $result->freezeexcluded);
$this->assertEquals(strtotime('2022-10-31'), $result->freezedate);
Expand All @@ -443,7 +446,7 @@ public function test_get_auto_context_freezing_preferences() {
* @return void
* @throws \dml_exception
*/
public function test_get_scheduled_freeze_date() {
public function test_get_scheduled_freeze_date(): void {
global $DB;

// Test course without CLC academic year, no scheduled freeze date should be returned.
Expand Down Expand Up @@ -480,7 +483,7 @@ public function test_get_scheduled_freeze_date() {
* @return void
* @throws \dml_exception
*/
public function test_get_weeks_delay_in_seconds() {
public function test_get_weeks_delay_in_seconds(): void {
// Test week delay config is 0.
$result = manager::get_weeks_delay_in_seconds();
$this->assertEquals('0', $result);
Expand All @@ -498,7 +501,7 @@ public function test_get_weeks_delay_in_seconds() {
* @return void
* @throws \ReflectionException
*/
public function test_get_furthest_date() {
public function test_get_furthest_date(): void {
$mockedinstance = $this->getMockBuilder(manager::class)
->disableOriginalConstructor()
->getMock();
Expand Down
2 changes: 1 addition & 1 deletion tests/privacy_provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function setUp(): void {
* @return void
* @throws \coding_exception
*/
public function test_get_reason() {
public function test_get_reason(): void {
$reason = get_string(provider::get_reason(), 'block_lifecycle');
$this->assertEquals('The Lifecycle block does not store personal data', $reason);
}
Expand Down

0 comments on commit adabf21

Please sign in to comment.