diff --git a/moodle/Tests/FilesBoilerPlateCommentTest.php b/moodle/Tests/FilesBoilerPlateCommentTest.php index e83f4e5..b9fd94b 100644 --- a/moodle/Tests/FilesBoilerPlateCommentTest.php +++ b/moodle/Tests/FilesBoilerPlateCommentTest.php @@ -28,104 +28,104 @@ class FilesBoilerPlateCommentTest extends MoodleCSBaseTestCase { public function testMoodleFilesBoilerplateCommentOk() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/ok.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.BoilerplateComment'); + $this->setFixture(__DIR__ . '/fixtures/files/boilerplatecomment/ok.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([]); - $this->set_warnings([]); + $this->setErrors([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); // Also try with the set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/ok2.php'); + $this->setFixture(__DIR__ . '/fixtures/files/boilerplatecomment/ok2.php'); - $this->set_errors([]); - $this->set_warnings([]); + $this->setErrors([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } public function testMoodleFilesBoilerplateCommentNoPHP() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/nophp.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.BoilerplateComment'); + $this->setFixture(__DIR__ . '/fixtures/files/boilerplatecomment/nophp.php'); - $this->set_errors([ + $this->setErrors([ 1 => 'moodle.Files.BoilerplateComment.NoPHP', ]); - $this->set_warnings([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } public function testMoodleFilesBoilerplateCommentBlank() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/blank.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.BoilerplateComment'); + $this->setFixture(__DIR__ . '/fixtures/files/boilerplatecomment/blank.php'); - $this->set_errors([ + $this->setErrors([ 2 => 'followed by exactly one newline', ]); - $this->set_warnings([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } public function testMoodleFilesBoilerplateCommentShort() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/short.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.BoilerplateComment'); + $this->setFixture(__DIR__ . '/fixtures/files/boilerplatecomment/short.php'); - $this->set_errors([ + $this->setErrors([ 14 => 'FileTooShort', ]); - $this->set_warnings([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } public function testMoodleFilesBoilerplateCommentShortEmpty() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/short_empty.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.BoilerplateComment'); + $this->setFixture(__DIR__ . '/fixtures/files/boilerplatecomment/short_empty.php'); - $this->set_errors([ + $this->setErrors([ 1 => 'FileTooShort', ]); - $this->set_warnings([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } public function testMoodleFilesBoilerplateCommentWrongLine() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/wrongline.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.BoilerplateComment'); + $this->setFixture(__DIR__ . '/fixtures/files/boilerplatecomment/wrongline.php'); - $this->set_errors([ + $this->setErrors([ 6 => 'version 3', 11 => 'FITNESS', ]); - $this->set_warnings([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } public function testMoodleFilesBoilerplateCommentGnuHttp() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/gnu_http.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.BoilerplateComment'); + $this->setFixture(__DIR__ . '/fixtures/files/boilerplatecomment/gnu_http.php'); - $this->set_errors([]); - $this->set_warnings([]); + $this->setErrors([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -133,13 +133,13 @@ public function testMoodleFilesBoilerplateCommentGnuHttp() { */ public function testMoodleFilesBoilerplateCommentGnuHttps() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/gnu_https.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.BoilerplateComment'); + $this->setFixture(__DIR__ . '/fixtures/files/boilerplatecomment/gnu_https.php'); - $this->set_errors([]); - $this->set_warnings([]); + $this->setErrors([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/MoodleCSBaseTestCase.php b/moodle/Tests/MoodleCSBaseTestCase.php index 0e3a118..b5a5b2a 100644 --- a/moodle/Tests/MoodleCSBaseTestCase.php +++ b/moodle/Tests/MoodleCSBaseTestCase.php @@ -73,19 +73,33 @@ abstract class MoodleCSBaseTestCase extends \PHPUnit\Framework\TestCase */ protected ?array $warnings = null; - public function tearDown(): void { + /** + * Code to be executed after each test case (method) is run. + * + * In charge of resetting all the internal properties and removing any + * custom config option or mockup mapping. + */ + protected function tearDown(): void { + // Reset all the internal properties. + $this->standard = null; + $this->sniff = null; + $this->errors = null; + $this->warnings = null; + // Reset any mocked component mappings. \MoodleHQ\MoodleCS\moodle\Util\MoodleUtil::setMockedComponentMappings([]); - // If there are custom configs setup, remove them. + // If there is any custom config setup, remove it. foreach (array_keys($this->customConfigs) as $key) { Config::setConfigData($key, null, true); } + // Call to parent, always. + parent::tearDown(); } - public function set_component_mapping(array $mapping): void { + public function setComponentMapping(array $mapping): void { \MoodleHQ\MoodleCS\moodle\Util\MoodleUtil::setMockedComponentMappings($mapping); } - public function set_api_mapping(array $mapping): void { + public function setApiMappings(array $mapping): void { \MoodleHQ\MoodleCS\moodle\Util\MoodleUtil::setMockedApiMappings($mapping); } @@ -94,7 +108,7 @@ public function set_api_mapping(array $mapping): void { * * @param string $standard name of the standard to be tested. */ - protected function set_standard(string $standard) { + protected function setStandard(string $standard) { if (\PHP_CodeSniffer\Util\Standards::isInstalledStandard($standard) === false) { // They didn't select a valid coding standard, so help them // out by letting them know which standards are installed. @@ -108,18 +122,6 @@ protected function set_standard(string $standard) { $this->standard = $standard; } - /** - * Helper to skip tests where a real Moodle Root is required. - */ - protected function requireRealMoodleRoot(): void { - $moodleRoot = \MoodleHQ\MoodleCS\moodle\Util\MoodleUtil::getMoodleRoot(); - if (!empty($moodleRoot)) { - return; - } - - $this->markTestSkipped("Unable to complete test. No Moodle Root specified."); - } - /** * Set the name of the sniff to be tested. * @@ -131,7 +133,7 @@ protected function requireRealMoodleRoot(): void { * - moodle.Commenting.InlineComment * - PEAR.WhiteSpace.ScopeIndent */ - protected function set_sniff($sniff) { + protected function setSniff($sniff) { $this->sniff = $sniff; } @@ -140,7 +142,7 @@ protected function set_sniff($sniff) { * * @param string $fixture full path to the file used as input (fixture). */ - protected function set_fixture($fixture) { + protected function setFixture($fixture) { if (!is_readable($fixture)) { $this->fail('Unreadable fixture passed: ' . $fixture); } @@ -152,7 +154,7 @@ protected function set_fixture($fixture) { * * @param array $errors error expectations to ve verified against execution results. */ - protected function set_errors(array $errors) { + protected function setErrors(array $errors) { $this->errors = $errors; // Let's normalize numeric, empty and string errors. foreach ($this->errors as $line => $errordef) { @@ -166,26 +168,12 @@ protected function set_errors(array $errors) { } } - /** - * Adds a custom config element to be setup before running phpcs. - * - * Note that those config elements will be automatically removed - * after each test case (by tearDown()) - * - * @param string $key config key or name. - * @param string $value config value. - */ - protected function add_custom_config(string $key, string $value): void { - $this->customConfigs[$key] = $value; - Config::setConfigData($key, $value, true); - } - /** * Set the warning expectations to ve verified against execution results. * * @param array $warnings warning expectations to ve verified against execution results. */ - protected function set_warnings(array $warnings) { + protected function setWarnings(array $warnings) { $this->warnings = $warnings; // Let's normalize numeric, empty and string warnings. foreach ($this->warnings as $line => $warningdef) { @@ -199,21 +187,6 @@ protected function set_warnings(array $warnings) { } } - /** - * Code to be executed before each test case (method) is run. - * - * In charge of initializing the CS and reset all the internal - * properties. - */ - protected function setUp(): void { - $this->standard = null; - $this->sniff = null; - $this->errors = null; - $this->warnings = null; - - parent::setUp(); - } - /** * Run the CS and verify all the expected errors and warnings. * @@ -222,7 +195,7 @@ protected function setUp(): void { * the CS is called and finally its results are tested against the * defined expectations. */ - protected function verify_cs_results() { + protected function verifyCsResults() { $config = new \PHP_CodeSniffer\Config(); $config->cache = false; $config->standards = [$this->standard]; @@ -249,8 +222,8 @@ protected function verify_cs_results() { } // Let's compare expected errors with returned ones. - $this->verify_errors($phpcsfile->getErrors()); - $this->verify_warnings($phpcsfile->getWarnings()); + $this->verifyErrors($phpcsfile->getErrors()); + $this->verifyWarnings($phpcsfile->getWarnings()); $fixerrors = []; // Let's see if the file has fixable problems and if they become really fixed. @@ -280,17 +253,43 @@ protected function verify_cs_results() { } } + /** + * Helper to skip tests where a real Moodle Root is required. + */ + protected function requireRealMoodleRoot(): void { + $moodleRoot = \MoodleHQ\MoodleCS\moodle\Util\MoodleUtil::getMoodleRoot(); + if (!empty($moodleRoot)) { + return; + } + + $this->markTestSkipped("Unable to complete test. No Moodle Root specified."); + } + + /** + * Adds a custom config element to be setup before running phpcs. + * + * Note that those config elements will be automatically removed + * after each test case (by tearDown()) + * + * @param string $key config key or name. + * @param string $value config value. + */ + protected function addCustomConfig(string $key, string $value): void { + $this->customConfigs[$key] = $value; + Config::setConfigData($key, $value, true); + } + /** * Normalize result errors and verify them against error expectations. * * @param array $errors error results produced by the CS execution. */ - private function verify_errors($errors) { + private function verifyErrors($errors) { if (!is_array($errors)) { $this->fail('Unexpected errors structure received from CS execution.'); } - $errors = $this->normalize_cs_results($errors); - $this->assert_results($this->errors, $errors, 'errors'); + $errors = $this->normalizeCsResults($errors); + $this->assertResults($this->errors, $errors, 'errors'); } /** @@ -298,12 +297,12 @@ private function verify_errors($errors) { * * @param array $warnings warning results produced by the CS execution */ - private function verify_warnings($warnings) { + private function verifyWarnings($warnings) { if (!is_array($warnings)) { $this->fail('Unexpected warnings structure received from CS execution.'); } - $warnings = $this->normalize_cs_results($warnings); - $this->assert_results($this->warnings, $warnings, 'warnings'); + $warnings = $this->normalizeCsResults($warnings); + $this->assertResults($this->warnings, $warnings, 'warnings'); } /** @@ -313,7 +312,7 @@ private function verify_warnings($warnings) { * @param array $results error|warning generated results. * @param string $type results being asserted (errors, warnings). Used for output only. */ - private function assert_results($expectations, $results, $type) { + private function assertResults($expectations, $results, $type) { foreach ($expectations as $line => $expectation) { // Build some information to be shown in case of problems. $info = ''; @@ -361,7 +360,7 @@ private function assert_results($expectations, $results, $type) { * @param array $results raw CS results (errors or warnings), * @return array normalized array. */ - private function normalize_cs_results($results) { + private function normalizeCsResults($results) { $normalized = []; foreach ($results as $line => $lineerrors) { foreach ($lineerrors as $errors) { diff --git a/moodle/Tests/MoodleStandardTest.php b/moodle/Tests/MoodleStandardTest.php index dca7433..e3aad39 100644 --- a/moodle/Tests/MoodleStandardTest.php +++ b/moodle/Tests/MoodleStandardTest.php @@ -37,9 +37,9 @@ class MoodleStandardTest extends MoodleCSBaseTestCase public function testPSR12FunctionsReturnTypeDeclaration() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('PSR12.Functions.ReturnTypeDeclaration'); - $this->set_fixture(__DIR__ . '/fixtures/psr12_functions_returntypedeclaration.php'); + $this->setStandard('moodle'); + $this->setSniff('PSR12.Functions.ReturnTypeDeclaration'); + $this->setFixture(__DIR__ . '/fixtures/psr12_functions_returntypedeclaration.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or @@ -51,11 +51,11 @@ public function testPSR12FunctionsReturnTypeDeclaration() { 38 => 'SpaceBeforeReturnType', ]; $warnings = []; - $this->set_errors($errors); - $this->set_warnings($warnings); + $this->setErrors($errors); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -66,9 +66,9 @@ public function testPSR12FunctionsReturnTypeDeclaration() { public function testPSR12FunctionsNullableTypeDeclaration() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('PSR12.Functions.NullableTypeDeclaration'); - $this->set_fixture(__DIR__ . '/fixtures/psr12_functions_nullabletypedeclaration.php'); + $this->setStandard('moodle'); + $this->setSniff('PSR12.Functions.NullableTypeDeclaration'); + $this->setFixture(__DIR__ . '/fixtures/psr12_functions_nullabletypedeclaration.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or @@ -79,11 +79,11 @@ public function testPSR12FunctionsNullableTypeDeclaration() { 22 => 3, ]; $warnings = []; - $this->set_errors($errors); - $this->set_warnings($warnings); + $this->setErrors($errors); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -94,15 +94,15 @@ public function testPSR12FunctionsNullableTypeDeclaration() { public function testPSR2MethodsMethodDeclaration() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('PSR2.Methods.MethodDeclaration'); - $this->set_fixture(__DIR__ . '/fixtures/psr2_methods_methoddeclaration.php'); + $this->setStandard('moodle'); + $this->setSniff('PSR2.Methods.MethodDeclaration'); + $this->setFixture(__DIR__ . '/fixtures/psr2_methods_methoddeclaration.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 33 => 'The static declaration must come after the visibility', 34 => 1, 35 => 1, @@ -117,10 +117,10 @@ public function testPSR2MethodsMethodDeclaration() { 48 => ['AbstractAfterVisibility', 'StaticBeforeVisibility'], 49 => 2, ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -131,15 +131,15 @@ public function testPSR2MethodsMethodDeclaration() { public function testMoodleCommentingInlineComment() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Commenting.InlineComment'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_comenting_inlinecomment.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Commenting.InlineComment'); + $this->setFixture(__DIR__ . '/fixtures/moodle_comenting_inlinecomment.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 4 => ['3 slashes comments are not allowed'], 6 => 1, 8 => 'No space found before comment text', @@ -165,7 +165,7 @@ public function testMoodleCommentingInlineComment() { 144 => '@Source: moodle.Commenting.InlineComment.SpacingBefore', 146 => '@Message: Blank comments are not allowed', ]); - $this->set_warnings([ + $this->setWarnings([ 4 => 0, 6 => [null, 'Commenting.InlineComment.InvalidEndChar'], 55 => ['19 found'], @@ -185,7 +185,7 @@ public function testMoodleCommentingInlineComment() { ]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -201,25 +201,25 @@ public function testMoodleCommentingInlineComment() { public function testMoodleCommentingInlineCommentJS() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Commenting.InlineComment'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_comenting_inlinecomment.js'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Commenting.InlineComment'); + $this->setFixture(__DIR__ . '/fixtures/moodle_comenting_inlinecomment.js'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 1 => ['3 slashes comments are not allowed'], 3 => 1, 5 => 'No space found before comment text', ]); - $this->set_warnings([ + $this->setWarnings([ 3 => [null, 'Commenting.InlineComment.InvalidEndChar'], ]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -230,24 +230,24 @@ public function testMoodleCommentingInlineCommentJS() { public function testMoodleControlStructuresControlsignature() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.ControlStructures.ControlSignature'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_controlstructures_controlsignature.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.ControlStructures.ControlSignature'); + $this->setFixture(__DIR__ . '/fixtures/moodle_controlstructures_controlsignature.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 3 => 0, 4 => ['found "if(...) {'], 5 => 0, 6 => '@Message: Expected "} else {\n"', ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -258,19 +258,19 @@ public function testMoodleControlStructuresControlsignature() { public function testMoodleFilesLineLength() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.LineLength'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_linelength.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.LineLength'); + $this->setFixture(__DIR__ . '/fixtures/moodle_files_linelength.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 21 => 'maximum limit of 180 characters; contains 181 characters', 22 => 'maximum limit of 180 characters; contains 181 characters', ]); - $this->set_warnings([ + $this->setWarnings([ 13 => 'exceeds 132 characters; contains 133 characters', 14 => 'exceeds 132 characters; contains 133 characters', 17 => 'exceeds 132 characters; contains 180 characters', @@ -278,7 +278,7 @@ public function testMoodleFilesLineLength() { ]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -288,24 +288,24 @@ public function testMoodleFilesLineLength() { */ public function testGenericArraysDisallowLongArraySyntax(): void { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('Generic.Arrays.DisallowLongArraySyntax'); - $this->set_fixture(__DIR__ . '/fixtures/generic_array_longarraysyntax.php'); + $this->setStandard('moodle'); + $this->setSniff('Generic.Arrays.DisallowLongArraySyntax'); + $this->setFixture(__DIR__ . '/fixtures/generic_array_longarraysyntax.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 3 => 'Short array syntax must be used to define arrays @Source: Generic.Arrays.DisallowLongArraySyntax.Found', 5 => 'Short array syntax must be used to define arrays @Source: Generic.Arrays.DisallowLongArraySyntax.Found', 9 => 'Short array syntax must be used to define arrays @Source: Generic.Arrays.DisallowLongArraySyntax.Found', ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -316,22 +316,22 @@ public function testGenericArraysDisallowLongArraySyntax(): void { public function testGeneriFilesLineEndings() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('Generic.Files.LineEndings'); - $this->set_fixture(__DIR__ . '/fixtures/generic_files_lineendings.php'); + $this->setStandard('moodle'); + $this->setSniff('Generic.Files.LineEndings'); + $this->setFixture(__DIR__ . '/fixtures/generic_files_lineendings.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 1 => 'line character is invalid; expected "\n" but found "\r\n" @Source: Generic.Files.LineEndings.InvalidEOLChar', ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -342,22 +342,22 @@ public function testGeneriFilesLineEndings() { public function testGenericFilesEndFileNewLine() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('Generic.Files.EndFileNewline'); - $this->set_fixture(__DIR__ . '/fixtures/generic_files_endfilenewline.php'); + $this->setStandard('moodle'); + $this->setSniff('Generic.Files.EndFileNewline'); + $this->setFixture(__DIR__ . '/fixtures/generic_files_endfilenewline.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 4 => 'File must end with a newline character @Source: Generic.Files.EndFileNewline.NotFound', ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -368,24 +368,24 @@ public function testGenericFilesEndFileNewLine() { public function testGenericWhiteSpaceDisalowTabIndent() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('Generic.WhiteSpace.DisallowTabIndent'); - $this->set_fixture(__DIR__ . '/fixtures/generic_whitespace_disallowtabindent.php'); + $this->setStandard('moodle'); + $this->setSniff('Generic.WhiteSpace.DisallowTabIndent'); + $this->setFixture(__DIR__ . '/fixtures/generic_whitespace_disallowtabindent.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 9 => 'Spaces must be used to indent lines; tabs are not allowed', 10 => 1, 11 => 1, ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -396,15 +396,15 @@ public function testGenericWhiteSpaceDisalowTabIndent() { public function testGenericFunctionsOpeningFunctionBraceKernighanRitchie() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('Generic.Functions.OpeningFunctionBraceKernighanRitchie'); - $this->set_fixture(__DIR__ . '/fixtures/generic_functions_openingfunctionbracekerninghanritchie.php'); + $this->setStandard('moodle'); + $this->setSniff('Generic.Functions.OpeningFunctionBraceKernighanRitchie'); + $this->setFixture(__DIR__ . '/fixtures/generic_functions_openingfunctionbracekerninghanritchie.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 6 => 'Expected 1 space before opening brace; found 0', 9 => 1, 12 => 'Expected 1 space before opening brace; found 3', @@ -414,10 +414,10 @@ public function testGenericFunctionsOpeningFunctionBraceKernighanRitchie() { 26 => 'Expected 1 space before opening brace; found 3', 29 => 1]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -428,15 +428,15 @@ public function testGenericFunctionsOpeningFunctionBraceKernighanRitchie() { public function testGenericClassesOpeningBraceSameLine() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('Generic.Classes.OpeningBraceSameLine'); - $this->set_fixture(__DIR__ . '/fixtures/generic_classes_openingclassbrace.php'); + $this->setStandard('moodle'); + $this->setSniff('Generic.Classes.OpeningBraceSameLine'); + $this->setFixture(__DIR__ . '/fixtures/generic_classes_openingclassbrace.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 5 => 'Expected 1 space before opening brace; found 0', 8 => 'Expected 1 space before opening brace; found 0', 11 => 'Expected 1 space before opening brace; found 3', @@ -444,10 +444,10 @@ public function testGenericClassesOpeningBraceSameLine() { 19 => 'Opening brace should be on the same line as the declaration for class test05', ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -458,23 +458,23 @@ public function testGenericClassesOpeningBraceSameLine() { public function testGenericWhiteSpaceScopeIndent() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('Generic.WhiteSpace.ScopeIndent'); - $this->set_fixture(__DIR__ . '/fixtures/generic_whitespace_scopeindent.php'); + $this->setStandard('moodle'); + $this->setSniff('Generic.WhiteSpace.ScopeIndent'); + $this->setFixture(__DIR__ . '/fixtures/generic_whitespace_scopeindent.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 7 => 'indented incorrectly; expected at least 4 spaces, found 2 @Source: Generic.WhiteSpace.ScopeIndent.Incorrect', 19 => 'indented incorrectly; expected at least 4 spaces, found 2 @Source: Generic.WhiteSpace.ScopeIndent.Incorrect', 44 => 'expected at least 8 spaces', ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -485,23 +485,23 @@ public function testGenericWhiteSpaceScopeIndent() { public function testMoodlePHPDeprecatedFunctions() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.PHP.DeprecatedFunctions'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_php_deprecatedfunctions.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.PHP.DeprecatedFunctions'); + $this->setFixture(__DIR__ . '/fixtures/moodle_php_deprecatedfunctions.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([]); + $this->setErrors([]); $warnings = [7 => 'print_error() has been deprecated; use throw new moodle_exception()']; if (PHP_VERSION_ID >= 70300 && PHP_VERSION_ID < 80000) { $warnings[10] = 'mbsplit() has been deprecated'; } - $this->set_warnings($warnings); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -512,15 +512,15 @@ public function testMoodlePHPDeprecatedFunctions() { public function testMoodlePHPForbiddenFunctions() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.PHP.ForbiddenFunctions'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_php_forbiddenfunctions.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.PHP.ForbiddenFunctions'); + $this->setFixture(__DIR__ . '/fixtures/moodle_php_forbiddenfunctions.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 5 => 'function sizeof() is forbidden; use count()', 6 => 1, 8 => 1, @@ -532,10 +532,10 @@ public function testMoodlePHPForbiddenFunctions() { 16 => 0, 17 => 0, ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -545,15 +545,15 @@ public function testMoodlePHPForbiddenFunctions() { */ public function testMoodlePHPForbiddenGlobalUse() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.PHP.ForbiddenGlobalUse'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_php_forbidden_global_use.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.PHP.ForbiddenGlobalUse'); + $this->setFixture(__DIR__ . '/fixtures/moodle_php_forbidden_global_use.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 1 => 0, 2 => 0, 3 => 0, @@ -616,10 +616,10 @@ public function testMoodlePHPForbiddenGlobalUse() { 58 => 0, 59 => 0, ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -630,24 +630,24 @@ public function testMoodlePHPForbiddenGlobalUse() { public function testMoodlePHPForbiddenTokens() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.PHP.ForbiddenTokens'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_php_forbiddentokens.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.PHP.ForbiddenTokens'); + $this->setFixture(__DIR__ . '/fixtures/moodle_php_forbiddentokens.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 5 => 'The use of function eval() is forbidden', 6 => 'The use of operator goto is forbidden', 8 => 'The use of goto labels is forbidden', 11 => 1, 13 => ['backticks', 'backticks']]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -658,15 +658,15 @@ public function testMoodlePHPForbiddenTokens() { public function testMoodleStringsForbiddenStrings() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Strings.ForbiddenStrings'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_strings_forbiddenstrings.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Strings.ForbiddenStrings'); + $this->setFixture(__DIR__ . '/fixtures/moodle_strings_forbiddenstrings.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 8 => 'The use of the AS keyword to alias tables is bad for cross-db', 10 => 1, 11 => 'The use of the AS keyword to alias tables is bad for cross-db', @@ -678,7 +678,7 @@ public function testMoodleStringsForbiddenStrings() { 23 => (version_compare(PHP_VERSION, '7.3.0', '<') ? 2 : 1), 26 => 0, 27 => 0]); - $this->set_warnings([ + $this->setWarnings([ 19 => ['backticks in strings is not recommended'], 20 => 1, 23 => 1, @@ -686,7 +686,7 @@ public function testMoodleStringsForbiddenStrings() { 37 => 1]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -697,21 +697,21 @@ public function testMoodleStringsForbiddenStrings() { public function testPHPCompatibilityFunctionUseRemovedFunctions() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('PHPCompatibility.FunctionUse.RemovedFunctions'); - $this->set_fixture(__DIR__ . '/fixtures/phpcompatibility_php_deprecatedfunctions.php'); + $this->setStandard('moodle'); + $this->setSniff('PHPCompatibility.FunctionUse.RemovedFunctions'); + $this->setFixture(__DIR__ . '/fixtures/phpcompatibility_php_deprecatedfunctions.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 5 => ['Function ereg_replace', 'Use call_user_func() instead', '@Source: PHPCompat'], ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -722,21 +722,21 @@ public function testPHPCompatibilityFunctionUseRemovedFunctions() { public function testPHPCompatibilitySyntaxForbiddenCallTimePassByReference() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('PHPCompatibility.Syntax.ForbiddenCallTimePassByReference'); - $this->set_fixture(__DIR__ . '/fixtures/phpcompatibility_php_forbiddencalltimepassbyreference.php'); + $this->setStandard('moodle'); + $this->setSniff('PHPCompatibility.Syntax.ForbiddenCallTimePassByReference'); + $this->setFixture(__DIR__ . '/fixtures/phpcompatibility_php_forbiddencalltimepassbyreference.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 6 => ['call-time pass-by-reference is deprecated'], 7 => ['@Source: PHPCompat']]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -747,15 +747,15 @@ public function testPHPCompatibilitySyntaxForbiddenCallTimePassByReference() { public function testMoodleNamingConventionsValidVariableName() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.NamingConventions.ValidVariableName'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_namingconventions_variablename.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.NamingConventions.ValidVariableName'); + $this->setFixture(__DIR__ . '/fixtures/moodle_namingconventions_variablename.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 4 => 'must not contain underscores', 5 => 'must be all lower-case', 6 => 'must not contain underscores', @@ -772,10 +772,10 @@ public function testMoodleNamingConventionsValidVariableName() { 21 => 2, 22 => ['must be all lower-case', 'must not contain underscores'], ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -786,15 +786,15 @@ public function testMoodleNamingConventionsValidVariableName() { public function testSquizWhiteSpaceOperatorSpacing() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('Squiz.WhiteSpace.OperatorSpacing'); - $this->set_fixture(__DIR__ . '/fixtures/squiz_whitespace_operatorspacing.php'); + $this->setStandard('moodle'); + $this->setSniff('Squiz.WhiteSpace.OperatorSpacing'); + $this->setFixture(__DIR__ . '/fixtures/squiz_whitespace_operatorspacing.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 6 => 0, 7 => 'Expected 1 space before', 8 => 'Expected 1 space after', @@ -854,10 +854,10 @@ public function testSquizWhiteSpaceOperatorSpacing() { 62 => 0, 63 => 0, ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -868,19 +868,19 @@ public function testSquizWhiteSpaceOperatorSpacing() { public function testSquizWhiteSpaceObjectOperatorSpacing() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('Squiz.WhiteSpace.ObjectOperatorSpacing'); - $this->set_fixture(__DIR__ . '/fixtures/squiz_whitespace_objectoperatorspacing.php'); + $this->setStandard('moodle'); + $this->setSniff('Squiz.WhiteSpace.ObjectOperatorSpacing'); + $this->setFixture(__DIR__ . '/fixtures/squiz_whitespace_objectoperatorspacing.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([]); - $this->set_warnings([]); + $this->setErrors([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -891,15 +891,15 @@ public function testSquizWhiteSpaceObjectOperatorSpacing() { public function testPEARWhiteSpaceObjectOperatorIndent() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('PEAR.WhiteSpace.ObjectOperatorIndent'); - $this->set_fixture(__DIR__ . '/fixtures/pear_whitespace_objectoperatorspacing.php'); + $this->setStandard('moodle'); + $this->setSniff('PEAR.WhiteSpace.ObjectOperatorIndent'); + $this->setFixture(__DIR__ . '/fixtures/pear_whitespace_objectoperatorspacing.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 40 => 'not indented correctly; expected 4 spaces but found 2', 41 => '@Source: PEAR.WhiteSpace.ObjectOperatorIndent.Incorrect', 44 => 1, @@ -915,10 +915,10 @@ public function testPEARWhiteSpaceObjectOperatorIndent() { 69 => 1, 70 => 1, ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -929,22 +929,22 @@ public function testPEARWhiteSpaceObjectOperatorIndent() { public function testSquizPHPCommentedOutCode() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('Squiz.PHP.CommentedOutCode'); - $this->set_fixture(__DIR__ . '/fixtures/squiz_php_commentedoutcode.php'); + $this->setStandard('moodle'); + $this->setSniff('Squiz.PHP.CommentedOutCode'); + $this->setFixture(__DIR__ . '/fixtures/squiz_php_commentedoutcode.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([]); - $this->set_warnings([ + $this->setErrors([]); + $this->setWarnings([ 5 => 'This comment is 72% valid code; is this commented out code', 9 => '@Source: Squiz.PHP.CommentedOutCode.Found', ]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -953,16 +953,16 @@ public function testSquizPHPCommentedOutCode() { * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\RequireLoginSniff */ public function testMoodleFilesRequireLoginProblem() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.RequireLogin'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_requirelogin/problem.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.RequireLogin'); + $this->setFixture(__DIR__ . '/fixtures/moodle_files_requirelogin/problem.php'); - $this->set_errors([]); - $this->set_warnings([ + $this->setErrors([]); + $this->setWarnings([ 25 => ', require_course_login, require_admin, admin_externalpage_setup) following config inclusion. None found', ]); - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -971,14 +971,14 @@ public function testMoodleFilesRequireLoginProblem() { * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\RequireLoginSniff */ public function testMoodleFilesRequireLoginOk() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.RequireLogin'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_requirelogin/require_login_ok.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.RequireLogin'); + $this->setFixture(__DIR__ . '/fixtures/moodle_files_requirelogin/require_login_ok.php'); - $this->set_errors([]); - $this->set_warnings([]); + $this->setErrors([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -987,14 +987,14 @@ public function testMoodleFilesRequireLoginOk() { * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\RequireLoginSniff */ public function testMoodleFilesRequireLoginCourseOk() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.RequireLogin'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_requirelogin/require_course_login_ok.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.RequireLogin'); + $this->setFixture(__DIR__ . '/fixtures/moodle_files_requirelogin/require_course_login_ok.php'); - $this->set_errors([]); - $this->set_warnings([]); + $this->setErrors([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -1003,14 +1003,14 @@ public function testMoodleFilesRequireLoginCourseOk() { * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\RequireLoginSniff */ public function testMoodleFilesRequireLoginAdminExtenalPageOk() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.RequireLogin'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_requirelogin/admin_externalpage_setup_ok.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.RequireLogin'); + $this->setFixture(__DIR__ . '/fixtures/moodle_files_requirelogin/admin_externalpage_setup_ok.php'); - $this->set_errors([]); - $this->set_warnings([]); + $this->setErrors([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -1019,14 +1019,14 @@ public function testMoodleFilesRequireLoginAdminExtenalPageOk() { * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\RequireLoginSniff */ public function testMoodleFilesRequireLoginCLIScriptOk() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.RequireLogin'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_requirelogin/cliscript_ok.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.RequireLogin'); + $this->setFixture(__DIR__ . '/fixtures/moodle_files_requirelogin/cliscript_ok.php'); - $this->set_errors([]); - $this->set_warnings([]); + $this->setErrors([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } /** @@ -1035,13 +1035,13 @@ public function testMoodleFilesRequireLoginCLIScriptOk() { * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\RequireLoginSniff */ public function testMoodleFilesRequireLoginNoMoodlCookiesOk() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.RequireLogin'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_requirelogin/nomoodlecookies_ok.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.RequireLogin'); + $this->setFixture(__DIR__ . '/fixtures/moodle_files_requirelogin/nomoodlecookies_ok.php'); - $this->set_errors([]); - $this->set_warnings([]); + $this->setErrors([]); + $this->setWarnings([]); - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/NamingConventionsValidFunctionNameTest.php b/moodle/Tests/NamingConventionsValidFunctionNameTest.php index c0588a3..eef67e5 100644 --- a/moodle/Tests/NamingConventionsValidFunctionNameTest.php +++ b/moodle/Tests/NamingConventionsValidFunctionNameTest.php @@ -78,18 +78,18 @@ public function providerNamingConventionsValidFunctionName() { public function testNamingConventionsValidFunctionName(string $fixture, array $errors, array $warnings) { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.NamingConventions.ValidFunctionName'); - $this->set_fixture(__DIR__ . '/' . $fixture); + $this->setStandard('moodle'); + $this->setSniff('moodle.NamingConventions.ValidFunctionName'); + $this->setFixture(__DIR__ . '/' . $fixture); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors($errors); - $this->set_warnings($warnings); + $this->setErrors($errors); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/NormalizedArraysArraysCommaAfterLastTest.php b/moodle/Tests/NormalizedArraysArraysCommaAfterLastTest.php index d07a469..d0cac5e 100644 --- a/moodle/Tests/NormalizedArraysArraysCommaAfterLastTest.php +++ b/moodle/Tests/NormalizedArraysArraysCommaAfterLastTest.php @@ -33,24 +33,24 @@ class NormalizedArraysArraysCommaAfterLastTest extends MoodleCSBaseTestCase public function testNormalizedArraysArraysCommaAfterLast() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('NormalizedArrays.Arrays.CommaAfterLast'); - $this->set_fixture(__DIR__ . '/fixtures/normalizedarrays_arrays_commaafterlast.php'); + $this->setStandard('moodle'); + $this->setSniff('NormalizedArrays.Arrays.CommaAfterLast'); + $this->setFixture(__DIR__ . '/fixtures/normalizedarrays_arrays_commaafterlast.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 79 => '@Source: NormalizedArrays.Arrays.CommaAfterLast.FoundSingleLine', 82 => '@Source: NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLine', 87 => 1, 95 => 1, 97 => 1, ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/PHPIncludingFileTest.php b/moodle/Tests/PHPIncludingFileTest.php index fa5000f..b7315f4 100644 --- a/moodle/Tests/PHPIncludingFileTest.php +++ b/moodle/Tests/PHPIncludingFileTest.php @@ -29,15 +29,15 @@ class PHPIncludingFileTest extends MoodleCSBaseTestCase { public function testPHPIncludingFile() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.PHP.IncludingFile'); - $this->set_fixture(__DIR__ . '/fixtures/php/includingfile.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.PHP.IncludingFile'); + $this->setFixture(__DIR__ . '/fixtures/php/includingfile.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 9 => '@Message: "require" must be immediately followed by an open parenthesis', 10 => '@Source: moodle.PHP.IncludingFile.BracketsRequired', 13 => 1, @@ -45,9 +45,9 @@ public function testPHPIncludingFile() { 17 => '@Source: moodle.PHP.IncludingFile.UseRequire', 18 => '@Source: moodle.PHP.IncludingFile.UseRequireOnce', ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/PHPMemberVarScopeTest.php b/moodle/Tests/PHPMemberVarScopeTest.php index e946c20..32010b1 100644 --- a/moodle/Tests/PHPMemberVarScopeTest.php +++ b/moodle/Tests/PHPMemberVarScopeTest.php @@ -29,21 +29,21 @@ class PHPMemberVarScopeTest extends MoodleCSBaseTestCase { public function testPHPMemberVarScope() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.PHP.MemberVarScope'); - $this->set_fixture(__DIR__ . '/fixtures/php/membervarscope.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.PHP.MemberVarScope'); + $this->setFixture(__DIR__ . '/fixtures/php/membervarscope.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 8 => '@Message: Scope modifier not specified for member variable "$missingprop"', 9 => '@Source: moodle.PHP.MemberVarScope.Missing', ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/PHPUnitTestCaseCoversTest.php b/moodle/Tests/PHPUnitTestCaseCoversTest.php index 1da6ba5..a5732a5 100644 --- a/moodle/Tests/PHPUnitTestCaseCoversTest.php +++ b/moodle/Tests/PHPUnitTestCaseCoversTest.php @@ -126,18 +126,18 @@ public function phpunitTestCaseCoversProvider() { public function testPHPUnitTestCaseCovers(string $fixture, array $errors, array $warnings) { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.PHPUnit.TestCaseCovers'); - $this->set_fixture(__DIR__ . '/' . $fixture); + $this->setStandard('moodle'); + $this->setSniff('moodle.PHPUnit.TestCaseCovers'); + $this->setFixture(__DIR__ . '/' . $fixture); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors($errors); - $this->set_warnings($warnings); + $this->setErrors($errors); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/PHPUnitTestCaseNamesTest.php b/moodle/Tests/PHPUnitTestCaseNamesTest.php index 4c5d449..67485a8 100644 --- a/moodle/Tests/PHPUnitTestCaseNamesTest.php +++ b/moodle/Tests/PHPUnitTestCaseNamesTest.php @@ -150,10 +150,10 @@ public function phpunitTestCaseNamesProvider() { */ public function testPHPUnitTestCaseNames(string $fixture, array $errors, array $warnings) { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.PHPUnit.TestCaseNames'); - $this->set_fixture(__DIR__ . '/' . $fixture); - $this->set_component_mapping([ + $this->setStandard('moodle'); + $this->setSniff('moodle.PHPUnit.TestCaseNames'); + $this->setFixture(__DIR__ . '/' . $fixture); + $this->setComponentMapping([ 'local_codechecker' => dirname(__DIR__), ]); @@ -161,10 +161,10 @@ public function testPHPUnitTestCaseNames(string $fixture, array $errors, array $ // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors($errors); - $this->set_warnings($warnings); + $this->setErrors($errors); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/PHPUnitTestCaseProviderTest.php b/moodle/Tests/PHPUnitTestCaseProviderTest.php index 2edcde7..e2b1e88 100644 --- a/moodle/Tests/PHPUnitTestCaseProviderTest.php +++ b/moodle/Tests/PHPUnitTestCaseProviderTest.php @@ -138,18 +138,18 @@ public function testPHPUnitTestCaseProvider( array $warnings ): void { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.PHPUnit.TestCaseProvider'); - $this->set_fixture(__DIR__ . '/' . $fixture); + $this->setStandard('moodle'); + $this->setSniff('moodle.PHPUnit.TestCaseProvider'); + $this->setFixture(__DIR__ . '/' . $fixture); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors($errors); - $this->set_warnings($warnings); + $this->setErrors($errors); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/PHPUnitTestReturnTypeTest.php b/moodle/Tests/PHPUnitTestReturnTypeTest.php index eadfe69..e93bd04 100644 --- a/moodle/Tests/PHPUnitTestReturnTypeTest.php +++ b/moodle/Tests/PHPUnitTestReturnTypeTest.php @@ -60,18 +60,18 @@ public function testPHPUnitTestReturnType( array $warnings ): void { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.PHPUnit.TestReturnType'); - $this->set_fixture(__DIR__ . '/' . $fixture); + $this->setStandard('moodle'); + $this->setSniff('moodle.PHPUnit.TestReturnType'); + $this->setFixture(__DIR__ . '/' . $fixture); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors($errors); - $this->set_warnings($warnings); + $this->setErrors($errors); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/Sniffs/Commenting/CategorySniffTest.php b/moodle/Tests/Sniffs/Commenting/CategorySniffTest.php index 96b93a9..cc537a6 100644 --- a/moodle/Tests/Sniffs/Commenting/CategorySniffTest.php +++ b/moodle/Tests/Sniffs/Commenting/CategorySniffTest.php @@ -37,12 +37,12 @@ public function testCategoryCorrectness( array $errors, array $warnings ): void { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Commenting.Category'); - $this->set_fixture(sprintf("%s/fixtures/%s.php", __DIR__, $fixture)); - $this->set_warnings($warnings); - $this->set_errors($errors); - $this->set_api_mapping([ + $this->setStandard('moodle'); + $this->setSniff('moodle.Commenting.Category'); + $this->setFixture(sprintf("%s/fixtures/%s.php", __DIR__, $fixture)); + $this->setWarnings($warnings); + $this->setErrors($errors); + $this->setApiMappings([ 'test' => [ 'component' => 'core', 'allowspread' => true, @@ -50,7 +50,7 @@ public function testCategoryCorrectness( ], ]); - $this->verify_cs_results(); + $this->verifyCsResults(); } public static function provider(): array { diff --git a/moodle/Tests/Sniffs/Commenting/InlineCommentSniffTest.php b/moodle/Tests/Sniffs/Commenting/InlineCommentSniffTest.php index 8e68a54..791f477 100644 --- a/moodle/Tests/Sniffs/Commenting/InlineCommentSniffTest.php +++ b/moodle/Tests/Sniffs/Commenting/InlineCommentSniffTest.php @@ -31,9 +31,9 @@ class InlineCommentSniffTest extends MoodleCSBaseTestCase { public function testCommentBeforeAttribute(): void { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Commenting.InlineComment'); - $this->set_fixture(__DIR__ . '/../../fixtures/Commenting/InlineCommentAttributeAfter.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Commenting.InlineComment'); + $this->setFixture(__DIR__ . '/../../fixtures/Commenting/InlineCommentAttributeAfter.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or @@ -41,10 +41,10 @@ public function testCommentBeforeAttribute(): void { // - line => string of contents for message / source problem matching (only 1). $errors = []; $warnings = []; - $this->set_errors($errors); - $this->set_warnings($warnings); + $this->setErrors($errors); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/Sniffs/Commenting/PackageSniffTest.php b/moodle/Tests/Sniffs/Commenting/PackageSniffTest.php index 2e23112..9a690a7 100644 --- a/moodle/Tests/Sniffs/Commenting/PackageSniffTest.php +++ b/moodle/Tests/Sniffs/Commenting/PackageSniffTest.php @@ -37,16 +37,16 @@ public function testPackageCorrectness( array $errors, array $warnings ): void { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Commenting.Package'); - $this->set_fixture(sprintf("%s/fixtures/%s.php", __DIR__, $fixture)); - $this->set_warnings($warnings); - $this->set_errors($errors); - $this->set_component_mapping([ + $this->setStandard('moodle'); + $this->setSniff('moodle.Commenting.Package'); + $this->setFixture(sprintf("%s/fixtures/%s.php", __DIR__, $fixture)); + $this->setWarnings($warnings); + $this->setErrors($errors); + $this->setComponentMapping([ 'local_codechecker' => dirname(__DIR__), ]); - $this->verify_cs_results(); + $this->verifyCsResults(); } public static function packageCorrectnessProvider(): array { diff --git a/moodle/Tests/Sniffs/Commenting/TodoCommentSniffTest.php b/moodle/Tests/Sniffs/Commenting/TodoCommentSniffTest.php index a2dd6e7..4a03cb3 100644 --- a/moodle/Tests/Sniffs/Commenting/TodoCommentSniffTest.php +++ b/moodle/Tests/Sniffs/Commenting/TodoCommentSniffTest.php @@ -31,9 +31,9 @@ class TodoCommentSniffTest extends MoodleCSBaseTestCase { public function testComentingTodoComment(): void { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Commenting.TodoComment'); - $this->set_fixture(__DIR__ . '/../../fixtures/Commenting/TodoComment.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Commenting.TodoComment'); + $this->setFixture(__DIR__ . '/../../fixtures/Commenting/TodoComment.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or @@ -51,21 +51,21 @@ public function testComentingTodoComment(): void { 33 => 'information in inline comment', 34 => 'information in phpdoc comment', ]; - $this->set_errors($errors); - $this->set_warnings($warnings); + $this->setErrors($errors); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } public function testEmptyConfigValue(): void { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Commenting.TodoComment'); - $this->set_fixture(__DIR__ . '/../../fixtures/Commenting/TodoCommentEmptyConfig.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Commenting.TodoComment'); + $this->setFixture(__DIR__ . '/../../fixtures/Commenting/TodoCommentEmptyConfig.php'); // Try with an empty config value. - $this->add_custom_config('moodleTodoCommentRegex', ''); + $this->addCustomConfig('moodleTodoCommentRegex', ''); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or @@ -73,21 +73,21 @@ public function testEmptyConfigValue(): void { // - line => string of contents for message / source problem matching (only 1). $errors = []; $warnings = []; - $this->set_errors($errors); - $this->set_warnings($warnings); + $this->setErrors($errors); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } public function testCustomConfigValue(): void { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Commenting.TodoComment'); - $this->set_fixture(__DIR__ . '/../../fixtures/Commenting/TodoCommentCustomConfig.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Commenting.TodoComment'); + $this->setFixture(__DIR__ . '/../../fixtures/Commenting/TodoCommentCustomConfig.php'); // Try with an empty config value. - $this->add_custom_config('moodleTodoCommentRegex', 'CUSTOM-[0-9]+'); + $this->addCustomConfig('moodleTodoCommentRegex', 'CUSTOM-[0-9]+'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or @@ -98,10 +98,10 @@ public function testCustomConfigValue(): void { 8 => 'Missing required "CUSTOM-[0-9]+"', 9 => 'Missing required "CUSTOM-[0-9]+"', ]; - $this->set_errors($errors); - $this->set_warnings($warnings); + $this->setErrors($errors); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/Sniffs/Files/MoodleInternalTest.php b/moodle/Tests/Sniffs/Files/MoodleInternalTest.php index cd2842a..508cac2 100644 --- a/moodle/Tests/Sniffs/Files/MoodleInternalTest.php +++ b/moodle/Tests/Sniffs/Files/MoodleInternalTest.php @@ -36,13 +36,13 @@ public function testFromProvider( array $errors ) { // Contains class_alias, which is not a side-effect. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/moodleinternal/' . $fixture . '.php'); - $this->set_warnings($warnings); - $this->set_errors($errors); + $this->setStandard('moodle'); + $this->setSniff('moodle.Files.MoodleInternal'); + $this->setFixture(__DIR__ . '/fixtures/moodleinternal/' . $fixture . '.php'); + $this->setWarnings($warnings); + $this->setErrors($errors); - $this->verify_cs_results(); + $this->verifyCsResults(); } /** diff --git a/moodle/Tests/Sniffs/Methods/MethodDeclarationSpacingSniffTest.php b/moodle/Tests/Sniffs/Methods/MethodDeclarationSpacingSniffTest.php index 68cff74..bd681af 100644 --- a/moodle/Tests/Sniffs/Methods/MethodDeclarationSpacingSniffTest.php +++ b/moodle/Tests/Sniffs/Methods/MethodDeclarationSpacingSniffTest.php @@ -31,9 +31,9 @@ class MethodDeclarationSpacingSniffTest extends MoodleCSBaseTestCase { public function testMethodDeclarationSpacing(): void { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Methods.MethodDeclarationSpacing'); - $this->set_fixture(__DIR__ . '/../../fixtures/Methods/MethodDeclarationSpacing.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.Methods.MethodDeclarationSpacing'); + $this->setFixture(__DIR__ . '/../../fixtures/Methods/MethodDeclarationSpacing.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or @@ -56,10 +56,10 @@ public function testMethodDeclarationSpacing(): void { 61 => 3, ]; $warnings = []; - $this->set_errors($errors); - $this->set_warnings($warnings); + $this->setErrors($errors); + $this->setWarnings($warnings); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/Sniffs/Namespaces/NamespaceStatementSniffTest.php b/moodle/Tests/Sniffs/Namespaces/NamespaceStatementSniffTest.php index c0233c9..f30d751 100644 --- a/moodle/Tests/Sniffs/Namespaces/NamespaceStatementSniffTest.php +++ b/moodle/Tests/Sniffs/Namespaces/NamespaceStatementSniffTest.php @@ -61,12 +61,12 @@ public function testLeadingSlash( array $warnings, array $errors ): void { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Namespaces.NamespaceStatement'); - $this->set_fixture(sprintf("%s/fixtures/%s.php", __DIR__, $fixture)); - $this->set_warnings($warnings); - $this->set_errors($errors); + $this->setStandard('moodle'); + $this->setSniff('moodle.Namespaces.NamespaceStatement'); + $this->setFixture(sprintf("%s/fixtures/%s.php", __DIR__, $fixture)); + $this->setWarnings($warnings); + $this->setErrors($errors); - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/Sniffs/PHPUnit/TestCasesAbstractSniffTest.php b/moodle/Tests/Sniffs/PHPUnit/TestCasesAbstractSniffTest.php index f70fca4..ca2b002 100644 --- a/moodle/Tests/Sniffs/PHPUnit/TestCasesAbstractSniffTest.php +++ b/moodle/Tests/Sniffs/PHPUnit/TestCasesAbstractSniffTest.php @@ -53,12 +53,12 @@ public function testPHPUnitTestCasesAbstract( array $errors, array $warnings ): void { - $this->set_standard('moodle'); - $this->set_sniff('moodle.PHPUnit.TestCasesAbstract'); - $this->set_fixture(sprintf("%s/fixtures/%s.php", __DIR__, $fixture)); - $this->set_warnings($warnings); - $this->set_errors($errors); + $this->setStandard('moodle'); + $this->setSniff('moodle.PHPUnit.TestCasesAbstract'); + $this->setFixture(sprintf("%s/fixtures/%s.php", __DIR__, $fixture)); + $this->setWarnings($warnings); + $this->setErrors($errors); - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/Sniffs/PHPUnit/TestClassesFinalSniffTest.php b/moodle/Tests/Sniffs/PHPUnit/TestClassesFinalSniffTest.php index 8d16ffd..8979f82 100644 --- a/moodle/Tests/Sniffs/PHPUnit/TestClassesFinalSniffTest.php +++ b/moodle/Tests/Sniffs/PHPUnit/TestClassesFinalSniffTest.php @@ -55,12 +55,12 @@ public function testPHPUnitClassesFinal( array $errors, array $warnings ): void { - $this->set_standard('moodle'); - $this->set_sniff('moodle.PHPUnit.TestClassesFinal'); - $this->set_fixture(sprintf("%s/fixtures/%s.php", __DIR__, $fixture)); - $this->set_warnings($warnings); - $this->set_errors($errors); + $this->setStandard('moodle'); + $this->setSniff('moodle.PHPUnit.TestClassesFinal'); + $this->setFixture(sprintf("%s/fixtures/%s.php", __DIR__, $fixture)); + $this->setWarnings($warnings); + $this->setErrors($errors); - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/SquizArraysArrayBrackerSpacingTest.php b/moodle/Tests/SquizArraysArrayBrackerSpacingTest.php index 43ff79a..d0fd4c0 100644 --- a/moodle/Tests/SquizArraysArrayBrackerSpacingTest.php +++ b/moodle/Tests/SquizArraysArrayBrackerSpacingTest.php @@ -33,15 +33,15 @@ class SquizArraysArrayBrackerSpacingTest extends MoodleCSBaseTestCase public function testSquizArrayaArrayBracketSpacing() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('Squiz.Arrays.ArrayBracketSpacing'); - $this->set_fixture(__DIR__ . '/fixtures/squiz_arrays_arraybracketspacing.php'); + $this->setStandard('moodle'); + $this->setSniff('Squiz.Arrays.ArrayBracketSpacing'); + $this->setFixture(__DIR__ . '/fixtures/squiz_arrays_arraybracketspacing.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 4 => "expected \"\$arr[\" but found \"\$arr [\"", 5 => ["expected \"['wrong'\" but found \"[ 'wrong'\"", "expected \"'wrong']\" but found \"'wrong' ]\""], 17 => 3, @@ -51,9 +51,9 @@ public function testSquizArrayaArrayBracketSpacing() { 31 => 2, 34 => 2, ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/SquizOperatorsValidLogicalOperatorsTest.php b/moodle/Tests/SquizOperatorsValidLogicalOperatorsTest.php index df27269..919966d 100644 --- a/moodle/Tests/SquizOperatorsValidLogicalOperatorsTest.php +++ b/moodle/Tests/SquizOperatorsValidLogicalOperatorsTest.php @@ -33,23 +33,23 @@ class SquizOperatorsValidLogicalOperatorsTest extends MoodleCSBaseTestCase public function testSquizOperatorsValidLogicalOperators() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('Squiz.Operators.ValidLogicalOperators'); - $this->set_fixture(__DIR__ . '/fixtures/squiz_operators_validlogicaloperators.php'); + $this->setStandard('moodle'); + $this->setSniff('Squiz.Operators.ValidLogicalOperators'); + $this->setFixture(__DIR__ . '/fixtures/squiz_operators_validlogicaloperators.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 21 => 'Logical operator "or" is prohibited; use "||" instead', 25 => 'Squiz.Operators.ValidLogicalOperators.NotAllowed', 29 => 2, 33 => 4, ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/Util/MoodleUtilTest.php b/moodle/Tests/Util/MoodleUtilTest.php index e3877bb..c8e8844 100644 --- a/moodle/Tests/Util/MoodleUtilTest.php +++ b/moodle/Tests/Util/MoodleUtilTest.php @@ -941,7 +941,7 @@ public function testGetMoodleApisMocked(): void { $vfs ); - $this->set_api_mapping($apis); + $this->setApiMappings($apis); // We are passing a real File, prepare it. $phpcsConfig = new Config(); diff --git a/moodle/Tests/WhiteSpaceSpaceAfterCommaTest.php b/moodle/Tests/WhiteSpaceSpaceAfterCommaTest.php index 3a8f873..11d9e74 100644 --- a/moodle/Tests/WhiteSpaceSpaceAfterCommaTest.php +++ b/moodle/Tests/WhiteSpaceSpaceAfterCommaTest.php @@ -29,20 +29,20 @@ class WhiteSpaceSpaceAfterCommaTest extends MoodleCSBaseTestCase { public function testWhitespaceSpaceAfterComma() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.WhiteSpace.SpaceAfterComma'); - $this->set_fixture(__DIR__ . '/fixtures/whitespace/spaceaftercomma.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.WhiteSpace.SpaceAfterComma'); + $this->setFixture(__DIR__ . '/fixtures/whitespace/spaceaftercomma.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 5 => 2, ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } } diff --git a/moodle/Tests/WhiteSpaceWhiteSpaceInStringsTest.php b/moodle/Tests/WhiteSpaceWhiteSpaceInStringsTest.php index b7ab990..aa5c22f 100644 --- a/moodle/Tests/WhiteSpaceWhiteSpaceInStringsTest.php +++ b/moodle/Tests/WhiteSpaceWhiteSpaceInStringsTest.php @@ -29,21 +29,21 @@ class WhiteSpaceWhiteSpaceInStringsTest extends MoodleCSBaseTestCase { public function testWhiteSpaceWhiteSpaceInStrings() { // Define the standard, sniff and fixture to use. - $this->set_standard('moodle'); - $this->set_sniff('moodle.WhiteSpace.WhiteSpaceInStrings'); - $this->set_fixture(__DIR__ . '/fixtures/whitespace/whitespaceinstrings.php'); + $this->setStandard('moodle'); + $this->setSniff('moodle.WhiteSpace.WhiteSpaceInStrings'); + $this->setFixture(__DIR__ . '/fixtures/whitespace/whitespaceinstrings.php'); // Define expected results (errors and warnings). Format, array of: // - line => number of problems, or // - line => array of contents for message / source problem matching. // - line => string of contents for message / source problem matching (only 1). - $this->set_errors([ + $this->setErrors([ 5 => '@Message: Whitespace found at end of line within string', 7 => '@Message: Tab found within whitespace', ]); - $this->set_warnings([]); + $this->setWarnings([]); // Let's do all the hard work! - $this->verify_cs_results(); + $this->verifyCsResults(); } }