From e4a1fd8a104385dbbb0e3456f209fb666efedaf7 Mon Sep 17 00:00:00 2001 From: Renaat Debleu Date: Sat, 21 Oct 2023 15:11:29 +0200 Subject: [PATCH] code review --- phpunit.xml | 51 ++++++++++++++++++++++++++++++++++ tests/condition_test.php | 14 +++++----- tests/phpunit.xml | 2 +- tests/privacy/privacy_test.php | 2 +- 4 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 phpunit.xml diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..0f85aa8 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + . + + + + + + classes + tests/generator + externallib.php + lib.php + locallib.php + renderer.php + rsslib.php + + + + diff --git a/tests/condition_test.php b/tests/condition_test.php index 05620c7..2d55300 100755 --- a/tests/condition_test.php +++ b/tests/condition_test.php @@ -52,7 +52,7 @@ public function setUp():void { * Tests constructing and using language condition as part of tree. * @covers \availability_language\condition */ - public function test_in_tree() { + public function test_in_tree(): void { global $DB; $this->resetAfterTest(); @@ -101,7 +101,7 @@ public function test_in_tree() { * Tests section availability. * @covers \availability_language\condition */ - public function test_sections() { + public function test_sections(): void { global $DB; $this->resetAfterTest(); set_config('enableavailability', true); @@ -138,7 +138,7 @@ public function test_sections() { * Tests the constructor including error conditions. * @covers \availability_language\condition */ - public function test_constructor() { + public function test_constructor(): void { // This works with no parameters. $structure = (object)[]; $language = new condition($structure); @@ -170,7 +170,7 @@ public function test_constructor() { * Tests the save() function. * @covers \availability_language\condition */ - public function test_save() { + public function test_save(): void { $structure = (object)['id' => 'fr']; $cond = new condition($structure); $structure->type = 'language'; @@ -182,7 +182,7 @@ public function test_save() { * Tests the get_description and get_standalone_description functions. * @covers \availability_language\condition */ - public function test_get_description() { + public function test_get_description(): void { $info = new mock_info(); $language = new condition((object)['type' => 'language', 'id' => '']); $this->assertEquals($language->get_description(false, false, $info), ''); @@ -201,7 +201,7 @@ public function test_get_description() { * Tests using language condition in front end. * @covers \availability_language\frontend */ - public function test_frontend() { + public function test_frontend(): void { global $CFG; require_once($CFG->dirroot.'/mod/lesson/locallib.php'); $this->resetAfterTest(); @@ -252,7 +252,7 @@ public function test_frontend() { * Tests using language condition in back end. * @covers \availability_language\condition */ - public function test_backend() { + public function test_backend(): void { global $CFG, $DB, $PAGE; $this->resetAfterTest(); $this->setAdminUser(); diff --git a/tests/phpunit.xml b/tests/phpunit.xml index 54e0037..09e52fc 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -20,7 +20,7 @@ - + diff --git a/tests/privacy/privacy_test.php b/tests/privacy/privacy_test.php index 0e26150..90cde38 100644 --- a/tests/privacy/privacy_test.php +++ b/tests/privacy/privacy_test.php @@ -41,7 +41,7 @@ class privacy_test extends provider_testcase { * Test returning metadata. * @covers \availability_language\privacy\provider */ - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new \core_privacy\local\metadata\collection('availability_language'); $reason = provider::get_reason($collection); $this->assertEquals($reason, 'privacy:metadata');