Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebleu committed Oct 21, 2023
1 parent 50ac54f commit e4a1fd8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 9 deletions.
51 changes: 51 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/phpunit/phpunit.xsd"
bootstrap="../../../lib/phpunit/bootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
backupGlobals="false"
backupStaticAttributes="false"
cacheResult="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
beStrictAboutTestsThatDoNotTestAnything="false"
beStrictAboutOutputDuringTests="true"
>

<php>
<!--<const name="PHPUNIT_LONGTEST" value="1"/> uncomment to execute also slow or otherwise expensive tests-->
<const name="PHPUNIT_SEQUENCE_START" value="145000"/>

<!--Following constants instruct tests to fetch external test files from alternative location
or skip tests if empty, clone https://github.com/moodlehq/moodle-exttests to local web server-->
<!--<const name="TEST_EXTERNAL_FILES_HTTP_URL" value="http://download.moodle.org/unittest"/>
uncomment and alter to fetch external test files from alternative location-->
<!--<const name="TEST_EXTERNAL_FILES_HTTPS_URL" value="https://download.moodle.org/unittest"/>
uncomment and alter to fetch external test files from alternative location-->
</php>

<testsuites>
<testsuite name="availability_language_testsuite">
<directory suffix="_test.php">.</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory suffix=".php">classes</directory>
<directory suffix=".php">tests/generator</directory>
<file>externallib.php</file>
<file>lib.php</file>
<file>locallib.php</file>
<file>renderer.php</file>
<file>rsslib.php</file>
</include>
</coverage>

</phpunit>
14 changes: 7 additions & 7 deletions tests/condition_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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';
Expand All @@ -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), '');
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<php>
<!--<const name="PHPUNIT_LONGTEST" value="1"/> uncomment to execute also slow or otherwise expensive tests-->
<const name="PHPUNIT_SEQUENCE_START" value="133000"/>
<const name="PHPUNIT_SEQUENCE_START" value="145000"/>

<!--Following constants instruct tests to fetch external test files from alternative location
or skip tests if empty, clone https://github.com/moodlehq/moodle-exttests to local web server-->
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 \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');
Expand Down

0 comments on commit e4a1fd8

Please sign in to comment.