Skip to content

Commit 4e7e62c

Browse files
committed
Fix PHPCS missing coverage info error
Apparently the DataProvider-Attribute prevents the missing coverage info Sniff from correctly parsing the @Covers annotation in the PHPDoc comment. I have rewritten the data provider as recommended on moodledev.io. References: https://moodledev.io/docs/5.1/guides/testing#make-use-of-the-dataprovider-functionality
1 parent 319a670 commit 4e7e62c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tests/output_image_test.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
use core\url;
2828

29-
use PHPUnit\Framework\Attributes\DataProvider;
30-
3129
/**
3230
* PHPUnit output image testcase
3331
* @package block_qrcode
@@ -64,17 +62,27 @@ protected function setUp(): void {
6462
}
6563

6664
/**
67-
* Data provider for the custom_wwwroot admin setting.
65+
* Data provider for {@see self::test_that_the_course_link_generation_respects_the_custom_wwwroot_setting}
66+
*
67+
* @return array
6868
*/
69-
public static function wwwroot_provider(): array {
70-
return [[''], ['https://www.example.de'], ['https://www.example.org/moodle']];
69+
public static function wwwroot_provider(): \Generator {
70+
yield 'Empty admin setting' => [
71+
'wwwroot' => '',
72+
];
73+
yield 'Custom wwwroot without path part' => [
74+
'wwwroot' => 'https://www.example.de',
75+
];
76+
yield 'Custom wwwroot with path part' => [
77+
'wwwroot' => 'https://www.example.org/moodle',
78+
];
7179
}
7280

7381
/**
7482
* The course link generation respects the custom wwwroot setting.
83+
* @dataProvider wwwroot_provider
7584
* @covers \block_qrcode\output_image
7685
*/
77-
#[DataProvider('wwwroot_provider')]
7886
public function test_that_the_course_link_generation_respects_the_custom_wwwroot_setting(string $wwwroot): void {
7987
set_config('custom_wwwroot', $wwwroot, 'block_qrcode');
8088
$image = new output_image(1, 150, $this->course->id, $this->block->id);

0 commit comments

Comments
 (0)