|
| 1 | +<?php |
| 2 | + |
| 3 | +// This file is part of Moodle - https://moodle.org/ |
| 4 | +// |
| 5 | +// Moodle is free software: you can redistribute it and/or modify |
| 6 | +// it under the terms of the GNU General Public License as published by |
| 7 | +// the Free Software Foundation, either version 3 of the License, or |
| 8 | +// (at your option) any later version. |
| 9 | +// |
| 10 | +// Moodle is distributed in the hope that it will be useful, |
| 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +// GNU General Public License for more details. |
| 14 | +// |
| 15 | +// You should have received a copy of the GNU General Public License |
| 16 | +// along with Moodle. If not, see <https://www.gnu.org/licenses/>. |
| 17 | + |
| 18 | +namespace MoodleHQ\MoodleCS\moodle\Tests\Sniffs\Commenting; |
| 19 | + |
| 20 | +use MoodleHQ\MoodleCS\moodle\Tests\MoodleCSBaseTestCase; |
| 21 | + |
| 22 | +/** |
| 23 | + * Test the MissingDocblockSniff sniff. |
| 24 | + * |
| 25 | + * @copyright 2024 onwards Andrew Lyons <andrew@nicols.co.uk> |
| 26 | + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| 27 | + * |
| 28 | + * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\LineLengthSniff |
| 29 | + */ |
| 30 | +class LineLengthSniffTest extends MoodleCSBaseTestCase |
| 31 | +{ |
| 32 | + /** |
| 33 | + * @dataProvider fixtureProvider |
| 34 | + */ |
| 35 | + public function testSniffWithFixtures( |
| 36 | + string $fixture, |
| 37 | + ?string $fixturePath, |
| 38 | + array $errors, |
| 39 | + array $warnings |
| 40 | + ): void { |
| 41 | + // xdebug_break(); |
| 42 | + $this->setStandard('moodle'); |
| 43 | + $this->setSniff('moodle.Files.LineLength'); |
| 44 | + $this->setFixture( |
| 45 | + sprintf("%s/fixtures/LineLength/%s.php", __DIR__, $fixture), |
| 46 | + $fixturePath, |
| 47 | + ); |
| 48 | + $this->setErrors($errors); |
| 49 | + $this->setWarnings($warnings); |
| 50 | + |
| 51 | + $this->verifyCsResults(); |
| 52 | + } |
| 53 | + |
| 54 | + public static function fixtureProvider(): array { |
| 55 | + $cases = [ |
| 56 | + [ |
| 57 | + 'fixture' => 'langfile', |
| 58 | + 'fixturePath' => '/lang/en/assignfeedback_editpdf.php', |
| 59 | + 'errors' => [], |
| 60 | + 'warnings' => [], |
| 61 | + ], |
| 62 | + [ |
| 63 | + 'fixture' => 'standard', |
| 64 | + 'fixturePath' => null, |
| 65 | + 'errors' => [ |
| 66 | + 13 => 'Line exceeds maximum limit of 180 characters; contains 182 characters', |
| 67 | + ], |
| 68 | + 'warnings' => [ |
| 69 | + |
| 70 | + ], |
| 71 | + ], |
| 72 | + ]; |
| 73 | + return $cases; |
| 74 | + } |
| 75 | +} |
0 commit comments