From 25f176bfc0b26f44d12c3653058285473b6f183c Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sun, 24 Sep 2023 11:56:26 +0200 Subject: [PATCH] Manually remove moodle-cs tests This step will be needed until this PR: https://github.com/moodlehq/moodle-cs/pull/69 is merged and released. Then we can get rid of it. Note the reason is that phpunit finds the tests under vendor and tries to execute them. As far as moodle-cs is now just a dependency we don't want it to contain any developing code (ci, tests, docs...) in its distribution form. --- readme_moodle.txt | 9 +- .../Tests/FilesBoilerPlateCommentTest.php | 135 -- .../moodle/Tests/FilesMoodleInternalTest.php | 232 --- .../moodle/Tests/MoodleCSBaseTestCase.php | 342 ----- .../moodle/Tests/MoodleStandardTest.php | 986 ------------- .../moodle-cs/moodle/Tests/MoodleUtilTest.php | 677 --------- ...NamingConventionsValidFunctionNameTest.php | 98 -- .../moodle/Tests/PHPIncludingFileTest.php | 56 - .../moodle/Tests/PHPMemberVarScopeTest.php | 52 - .../Tests/PHPUnitTestCaseCoversTest.php | 146 -- .../moodle/Tests/PHPUnitTestCaseNamesTest.php | 175 --- .../Tests/PHPUnitTestCaseProviderTest.php | 160 --- .../NamespaceStatementSniffTest.php | 76 - .../Namespaces/fixtures/correct_namespace.php | 8 - .../Namespaces/fixtures/curly_namespace.php | 5 - .../fixtures/curly_namespace.php.fixed | 5 - .../fixtures/curly_namespace_correct.php | 5 - .../Namespaces/fixtures/leading_backslash.php | 8 - .../fixtures/leading_backslash.php.fixed | 8 - .../SquizArraysArrayBrackerSpacingTest.php | 62 - ...quizOperatorsValidLogicalOperatorsTest.php | 58 - .../Tests/WhiteSpaceSpaceAfterCommaTest.php | 51 - .../WhiteSpaceWhiteSpaceInStringsTest.php | 52 - .../moodle-cs/moodle/Tests/bootstrap.php | 22 - .../files/boilerplatecomment/blank.php | 18 - .../files/boilerplatecomment/gnu_http.php | 15 - .../files/boilerplatecomment/gnu_https.php | 15 - .../files/boilerplatecomment/nophp.php | 18 - .../fixtures/files/boilerplatecomment/ok.php | 17 - .../fixtures/files/boilerplatecomment/ok2.php | 17 - .../files/boilerplatecomment/short.php | 14 - .../files/boilerplatecomment/wrongline.php | 17 - .../files/moodleinternal/class_alias.php | 26 - .../moodleinternal/class_alias_defined.php | 28 - .../moodleinternal/class_alias_extra.php | 28 - .../files/moodleinternal/declare_ok.php | 32 - .../lang/en/repository_dropbox.php | 25 - .../lib/behat/behat_mod_workshop.php | 40 - .../files/moodleinternal/namespace_ok.php | 37 - .../moodleinternal/namespace_with_use_ok.php | 38 - .../moodleinternal/no_moodle_cookie_ok.php | 40 - .../files/moodleinternal/no_relevant_ok.php | 32 - .../files/moodleinternal/nowarning.php | 32 - .../moodleinternal/old_style_if_die_ok.php | 33 - .../fixtures/files/moodleinternal/problem.php | 21 - .../tests/behat/behat_mod_workshop.php | 40 - .../files/moodleinternal/unexpected.php | 26 - .../fixtures/files/moodleinternal/warning.php | 34 - .../generic_array_longarraysyntax.php | 14 - .../generic_array_longarraysyntax.php.fixed | 14 - .../generic_classes_openingclassbrace.php | 31 - .../fixtures/generic_files_endfilenewline.php | 4 - .../fixtures/generic_files_lineendings.php | 4 - ..._openingfunctionbracekerninghanritchie.php | 96 -- .../generic_whitespace_disallowtabindent.php | 11 - .../generic_whitespace_scopeindent.php | 177 --- .../Tests/fixtures/integration_test_ci.php | 4 - .../moodle_comenting_inlinecomment.js | 50 - .../moodle_comenting_inlinecomment.php | 148 -- ...dle_controlstructures_controlsignature.php | 8 - .../fixtures/moodle_files_linelength.php | 22 - .../admin_externalpage_setup_ok.php | 31 - .../cliscript_ok.php | 28 - .../nomoodlecookies_ok.php | 30 - .../moodle_files_requirelogin/problem.php | 29 - .../require_course_login_ok.php | 32 - .../require_login_ok.php | 30 - .../moodle_namingconventions_variablename.php | 23 - ...e_namingconventions_variablename.php.fixed | 23 - .../moodle_php_deprecatedfunctions.php | 10 - .../moodle_php_forbidden_global_use.php | 63 - .../moodle_php_forbiddenfunctions.php | 20 - .../fixtures/moodle_php_forbiddentokens.php | 14 - .../moodle_strings_forbiddenstrings.php | 39 - .../fixtures/moodleutil/bad/config-dist.php | 1 - .../Tests/fixtures/moodleutil/bad/lib/lib.php | 1 - .../Tests/fixtures/moodleutil/bad/version.php | 37 - .../moodleutil/complete/config-dist.php | 1 - .../complete/lib/classes/component.php | 1277 ----------------- .../moodleutil/complete/lib/components.json | 116 -- .../fixtures/moodleutil/complete/lib/lib.php | 1 - .../complete/local/invented/lib.php | 1 - .../fixtures/moodleutil/complete/version.php | 37 - .../fixtures/moodleutil/good/config-dist.php | 1 - .../fixtures/moodleutil/good/lib/lib.php | 1 - .../fixtures/moodleutil/good/version.php | 37 - .../moodleutil/test_with_methods_to_find.php | 23 - .../validfunctionname_correct.php | 66 - .../validfunctionname_global.php | 10 - .../validfunctionname_lower.php | 22 - .../validfunctionname_scoped.php | 14 - .../pear_whitespace_objectoperatorspacing.php | 70 - .../Tests/fixtures/php/includingfile.php | 26 - .../Tests/fixtures/php/membervarscope.php | 15 - ...pcompatibility_php_deprecatedfunctions.php | 7 - ...y_php_forbiddencalltimepassbyreference.php | 7 - .../provider/complex_provider_test.php | 43 - .../provider/complex_provider_test.php.fixed | 43 - .../phpunit/provider/correct_test.php | 22 - .../phpunit/provider/provider_casing_test.php | 15 - .../provider/provider_casing_test.php.fixed | 15 - .../provider/provider_not_found_test.php | 18 - .../provider/provider_parents_test.php | 15 - .../provider/provider_parents_test.php.fixed | 15 - .../phpunit/provider/provider_prefix_test.php | 15 - .../provider/provider_returntype_test.php | 53 - .../provider/provider_visibility_test.php | 37 - .../provider_visibility_test.php.fixed | 37 - .../provider/static_providers_fix_test.php | 49 - .../static_providers_fix_test.php.fixed | 49 - .../provider/static_providers_test.php | 46 - .../provider/static_providers_test.php.fixed | 46 - .../phpunit/testcasecovers_contradiction.php | 18 - .../phpunit/testcasecovers_correct.php | 32 - .../phpunit/testcasecovers_covers.php | 23 - .../testcasecovers_coversdefaultclass.php | 22 - .../phpunit/testcasecovers_coversnothing.php | 16 - .../phpunit/testcasecovers_missing.php | 11 - .../fixtures/phpunit/testcasecovers_mixed.php | 16 - .../phpunit/testcasecovers_redundant.php | 16 - .../phpunit/testcasecovers_skipped.php | 32 - .../testcasenames_correct_level2ns.php | 11 - .../testcasenames_duplicate_exists.php | 11 - .../testcasenames_duplicate_proposed.php | 10 - .../phpunit/testcasenames_exists_proposed.php | 10 - .../phpunit/testcasenames_missing.php | 21 - .../phpunit/testcasenames_missing_ns.php | 10 - .../phpunit/testcasenames_nomatch.php | 11 - .../phpunit/testcasenames_nomatch.php.fixed | 11 - .../phpunit/testcasenames_proposed_exists.php | 11 - .../testcasenames_test_testcase_irregular.php | 11 - .../testcasenames_unexpected_level2ns.php | 11 - .../phpunit/testcasenames_unexpected_ns.php | 11 - .../testcasenames_with_abstract_test.php | 17 - .../psr2_methods_methoddeclaration.php | 50 - .../squiz_arrays_arraybracketspacing.php | 37 - ...squiz_arrays_arraybracketspacing.php.fixed | 37 - .../squiz_operators_validlogicaloperators.php | 33 - .../fixtures/squiz_php_commentedoutcode.php | 13 - ...squiz_whitespace_objectoperatorspacing.php | 71 - .../squiz_whitespace_operatorspacing.php | 63 - .../fixtures/whitespace/spaceaftercomma.php | 5 - .../whitespace/spaceaftercomma.php.fixed | 5 - .../whitespace/whitespaceinstrings.php | 8 - 144 files changed, 6 insertions(+), 7973 deletions(-) delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/FilesBoilerPlateCommentTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/FilesMoodleInternalTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/MoodleCSBaseTestCase.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/MoodleStandardTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/MoodleUtilTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/NamingConventionsValidFunctionNameTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/PHPIncludingFileTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/PHPMemberVarScopeTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/PHPUnitTestCaseCoversTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/PHPUnitTestCaseNamesTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/PHPUnitTestCaseProviderTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/NamespaceStatementSniffTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/fixtures/correct_namespace.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/fixtures/curly_namespace.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/fixtures/curly_namespace.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/fixtures/curly_namespace_correct.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/fixtures/leading_backslash.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/fixtures/leading_backslash.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/SquizArraysArrayBrackerSpacingTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/SquizOperatorsValidLogicalOperatorsTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/WhiteSpaceSpaceAfterCommaTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/WhiteSpaceWhiteSpaceInStringsTest.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/bootstrap.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/blank.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/gnu_http.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/gnu_https.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/nophp.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/ok.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/ok2.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/short.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/wrongline.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/class_alias.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/class_alias_defined.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/class_alias_extra.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/declare_ok.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/lang/en/repository_dropbox.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/lib/behat/behat_mod_workshop.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/namespace_ok.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/namespace_with_use_ok.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/no_moodle_cookie_ok.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/no_relevant_ok.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/nowarning.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/old_style_if_die_ok.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/problem.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/tests/behat/behat_mod_workshop.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/unexpected.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/warning.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/generic_array_longarraysyntax.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/generic_array_longarraysyntax.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/generic_classes_openingclassbrace.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/generic_files_endfilenewline.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/generic_files_lineendings.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/generic_functions_openingfunctionbracekerninghanritchie.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/generic_whitespace_disallowtabindent.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/generic_whitespace_scopeindent.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/integration_test_ci.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_comenting_inlinecomment.js delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_comenting_inlinecomment.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_controlstructures_controlsignature.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_linelength.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/admin_externalpage_setup_ok.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/cliscript_ok.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/nomoodlecookies_ok.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/problem.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/require_course_login_ok.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/require_login_ok.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_namingconventions_variablename.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_namingconventions_variablename.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_php_deprecatedfunctions.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_php_forbidden_global_use.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_php_forbiddenfunctions.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_php_forbiddentokens.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_strings_forbiddenstrings.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/bad/config-dist.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/bad/lib/lib.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/bad/version.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/complete/config-dist.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/complete/lib/classes/component.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/complete/lib/components.json delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/complete/lib/lib.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/complete/local/invented/lib.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/complete/version.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/good/config-dist.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/good/lib/lib.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/good/version.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodleutil/test_with_methods_to_find.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/namingconventions/validfunctionname_correct.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/namingconventions/validfunctionname_global.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/namingconventions/validfunctionname_lower.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/namingconventions/validfunctionname_scoped.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/pear_whitespace_objectoperatorspacing.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/php/includingfile.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/php/membervarscope.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpcompatibility_php_deprecatedfunctions.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpcompatibility_php_forbiddencalltimepassbyreference.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/complex_provider_test.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/complex_provider_test.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/correct_test.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/provider_casing_test.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/provider_casing_test.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/provider_not_found_test.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/provider_parents_test.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/provider_parents_test.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/provider_prefix_test.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/provider_returntype_test.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/provider_visibility_test.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/provider_visibility_test.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/static_providers_fix_test.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/static_providers_fix_test.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/static_providers_test.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/provider/static_providers_test.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasecovers_contradiction.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasecovers_correct.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasecovers_covers.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasecovers_coversdefaultclass.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasecovers_coversnothing.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasecovers_missing.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasecovers_mixed.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasecovers_redundant.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasecovers_skipped.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_correct_level2ns.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_duplicate_exists.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_duplicate_proposed.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_exists_proposed.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_missing.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_missing_ns.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_nomatch.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_nomatch.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_proposed_exists.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_test_testcase_irregular.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_unexpected_level2ns.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_unexpected_ns.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/phpunit/testcasenames_with_abstract_test.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/psr2_methods_methoddeclaration.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/squiz_arrays_arraybracketspacing.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/squiz_arrays_arraybracketspacing.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/squiz_operators_validlogicaloperators.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/squiz_php_commentedoutcode.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/squiz_whitespace_objectoperatorspacing.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/squiz_whitespace_operatorspacing.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/whitespace/spaceaftercomma.php delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/whitespace/spaceaftercomma.php.fixed delete mode 100644 vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/whitespace/whitespaceinstrings.php diff --git a/readme_moodle.txt b/readme_moodle.txt index 39f8ac0c..117c1043 100644 --- a/readme_moodle.txt +++ b/readme_moodle.txt @@ -32,9 +32,12 @@ To update any component: 3. Switch to the lowest PHP version supported by the Moodle version required. 4. Run `composer install` (to install everything).a 5. Update `thirdpartylibs.xml` to annotate the new versions of the tools. -6. Commit changes with details about the tools updated. -7. Test, test, test. -8. Optionally, release. +6. Remove `vendor/moodlehq/moodle-cs/moodle/Tests`. Note that this step + will be removed once https://github.com/moodlehq/moodle-cs/pull/69 + is released and we update to that version. +7. Commit changes with details about the tools updated. +8. Test, test, test. +9. Optionally, release. At some point we may want to make the process above automated, so every time that a new moodle-cs package is released, everything above (1-8) happens automatically. diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/FilesBoilerPlateCommentTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/FilesBoilerPlateCommentTest.php deleted file mode 100644 index 1c4c981e..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/FilesBoilerPlateCommentTest.php +++ /dev/null @@ -1,135 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the BoilerplateCommentSniff sniff. - * - * @package local_codechecker - * @category test - * @copyright 2022 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\BoilerplateCommentSniff - */ -class FilesBoilerPlateCommentTest extends MoodleCSBaseTestCase { - - public function test_moodle_files_boilerplatecomment_ok() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__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->verify_cs_results(); - - // Also try with the set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/ok2.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_boilerplatecomment_nophp() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/nophp.php'); - - $this->set_errors([ - 1 => 'moodle.Files.BoilerplateComment.NoPHP', - ]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_boilerplatecomment_blank() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/blank.php'); - - $this->set_errors([ - 2 => 'followed by exactly one newline', - ]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_boilerplatecomment_short() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/short.php'); - - $this->set_errors([ - 14 => 'FileTooShort', - ]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_boilerplatecomment_wrongline() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/wrongline.php'); - - $this->set_errors([ - 6 => 'version 3', - 11 => 'FITNESS', - ]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_boilerplatecomment_gnu_http() { - - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/gnu_http.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - /** - * Assert that www.gnu.org can be referred to via https URL in the boilerplate. - */ - public function test_moodle_files_boilerplatecomment_gnu_https() { - - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.BoilerplateComment'); - $this->set_fixture(__DIR__ . '/fixtures/files/boilerplatecomment/gnu_https.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/FilesMoodleInternalTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/FilesMoodleInternalTest.php deleted file mode 100644 index 561540a4..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/FilesMoodleInternalTest.php +++ /dev/null @@ -1,232 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the MoodleInternalSniff sniff. - * - * @package local_codechecker - * @category test - * @copyright 2013 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\MoodleInternalSniff - */ -class FilesMoodleInternalTest extends MoodleCSBaseTestCase { - - public function test_moodle_files_moodleinternal_problem() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/problem.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([ - 19 => 'Expected MOODLE_INTERNAL check or config.php inclusion' - ]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_warning() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/warning.php'); - - $this->set_errors([]); - $this->set_warnings([ - 32 => 'Expected MOODLE_INTERNAL check or config.php inclusion. Multiple artifacts' - ]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_nowarning() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/nowarning.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_declare_ok() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/declare_ok.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_namespace_ok() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/namespace_ok.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_no_moodle_cookie_ok() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/no_moodle_cookie_ok.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_behat_skipped() { - // Files in /tests/behat/ dirs are ignored. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/tests/behat/behat_mod_workshop.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - - // Files in /lib/behat/ dirs are ignored. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/lib/behat/behat_mod_workshop.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_lang_skipped() { - // Files in lang dirs are ignored. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/lang/en/repository_dropbox.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_namespace_with_use_ok() { - // An edge case which allows use statements before defined(). - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/namespace_with_use_ok.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_old_style_if_die() { - // Old style if statement MOODLE_INTERNAL check. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/old_style_if_die_ok.php'); - - $this->set_errors([]); - $this->set_warnings([ - 24 => 'Old MOODLE_INTERNAL check detected. Replace it by', - ]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_no_relevant_ok() { - // Files that only contain non-relevant (and no side-effects) code. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/no_relevant_ok.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_unexpected() { - // Unexpected (not needed) check. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/unexpected.php'); - - $this->set_errors([]); - $this->set_warnings([ - 17 => 'MoodleInternalNotNeeded' - ]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_class_alias() { - // Contains class_alias, which is not a side-effect. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/class_alias.php'); - - $this->set_errors([]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_class_alias_with_additional_sideeffect() { - // Contains class_alias, which is not a side-effect. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/class_alias_extra.php'); - - $this->set_errors([ - 25 => 'Expected MOODLE_INTERNAL check or config.php inclusion', - ]); - $this->set_warnings([]); - - $this->verify_cs_results(); - } - - public function test_moodle_files_moodleinternal_class_alias_with_errant_define() { - // Contains class_alias, which is not a side-effect. - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.MoodleInternal'); - $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/class_alias_defined.php'); - - $this->set_errors([]); - $this->set_warnings([ - 17 => 'MoodleInternalNotNeeded', - ]); - - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/MoodleCSBaseTestCase.php b/vendor/moodlehq/moodle-cs/moodle/Tests/MoodleCSBaseTestCase.php deleted file mode 100644 index f052a56e..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/MoodleCSBaseTestCase.php +++ /dev/null @@ -1,342 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -/** - * Specialized test case for easy testing of "moodle" standard sniffs. - * - * If you want to run the tests for the Moodle sniffs, you need to - * use the specific command-line: - * vendor/bin/phpunit local/codechecker/moodle/tests/moodlestandard_test.php - * no tests for this plugin are run as part of a full Moodle PHPunit run. - * (This may be a bug?) - * - * This class mimics {@see AbstractSniffUnitTest} way to test Sniffs - * allowing easy process of examples and assertion of result expectations. - * - * Should work for any Sniff part of a given standard (custom or core). - * - * Note extension & overriding was impossible because of some "final" stuff. - * - * This file contains helper testcase for testing "moodle" CS Sniffs. - * - * @category test - * @package MoodleHq\Moodle-Cs - * @copyright 2013 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -abstract class MoodleCSBaseTestCase extends \PHPUnit\Framework\TestCase { - - /** - * @var string name of the standard to be tested. - */ - protected $standard = null; - - /** - * @var string code of the sniff to be tested. Must be part of the standard definition. - * See {@see ::set_sniff()} for more information. - */ - protected $sniff = null; - - /** - * @var string full path to the file used as input (fixture). - */ - protected $fixture = null; - - /** - * @var array error expectations to ve verified against execution results. - */ - protected $errors = null; - - /** - * @var array warning expectations to ve verified against execution results. - */ - protected $warnings = null; - - public function tearDown(): void { - \MoodleHQ\MoodleCS\moodle\Util\MoodleUtil::setMockedComponentMappings([]); - } - - public function set_component_mapping(array $mapping): void { - \MoodleHQ\MoodleCS\moodle\Util\MoodleUtil::setMockedComponentMappings($mapping); - } - - /** - * Set the name of the standard to be tested. - * - * @param string $standard name of the standard to be tested. - */ - protected function set_standard(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. - $error = "ERROR: the '{$standard}' coding standard is not installed.\n"; - ob_start(); - \PHP_CodeSniffer\Util\Standards::printInstalledStandards(); - $error .= ob_get_contents(); - ob_end_clean(); - throw new \PHP_CodeSniffer\Exceptions\DeepExitException($error, 3); - } - $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. - * - * @param string $sniff code of the sniff to be tested. Must be part of the standard definition. - * Since CodeSniffer 1.5 they are not the Sniff (class) names anymore but - * the called Sniff "code" that is a 3 elements, dot separated, structure - * with format: standard.group.name. Examples: - * - Generic.PHP.LowerCaseConstant - * - moodle.Commenting.InlineComment - * - PEAR.WhiteSpace.ScopeIndent - */ - protected function set_sniff($sniff) { - $this->sniff = $sniff; - } - - /** - * Set the full path to the file used as input. - * - * @param string $fixture full path to the file used as input (fixture). - */ - protected function set_fixture($fixture) { - if (!is_readable($fixture)) { - $this->fail('Unreadable fixture passed: '. $fixture); - } - $this->fixture = $fixture; - } - - /** - * Set the error expectations to ve verified against execution results. - * - * @param array $errors error expectations to ve verified against execution results. - */ - protected function set_errors(array $errors) { - $this->errors = $errors; - // Let's normalize numeric, empty and string errors. - foreach ($this->errors as $line => $errordef) { - if (is_int($errordef) and $errordef > 0) { - $this->errors[$line] = array_fill(0, $errordef, $errordef); - } else if (empty($errordef)) { - $this->errors[$line] = array(); - } else if (is_string($errordef)) { - $this->errors[$line] = array($errordef); - } - } - } - - /** - * 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) { - $this->warnings = $warnings; - // Let's normalize numeric, empty and string warnings. - foreach ($this->warnings as $line => $warningdef) { - if (is_int($warningdef) and $warningdef > 0) { - $this->warnings[$line] = array_fill(0, $warningdef, $warningdef); - } else if (empty($warningdef)) { - $this->warnings[$line] = array(); - } else if (is_string($warningdef)) { - $this->warnings[$line] = array($warningdef); - } - } - } - - /** - * 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. - * - * This method must be called after defining everything (the standard, - * the sniff, the fixture and the error and warning expectations). Then, - * the CS is called and finally its results are tested against the - * defined expectations. - */ - protected function verify_cs_results() { - $config = new \PHP_CodeSniffer\Config(); - $config->cache = false; - $config->standards = array($this->standard); - $config->sniffs = array($this->sniff); - $config->ignored = array(); - $ruleset = new \PHP_CodeSniffer\Ruleset($config); - - // We don't accept undefined errors and warnings. - if (is_null($this->errors) and is_null($this->warnings)) { - $this->fail('Error and warning expectations undefined. You must define at least one.'); - } - - // Let's process the fixture. - try { - $phpcsfile = new \PHP_CodeSniffer\Files\LocalFile($this->fixture, $ruleset, $config); - $phpcsfile->process(); - } catch (Exception $e) { - $this->fail('An unexpected exception has been caught: '. $e->getMessage()); - } - - // Capture results. - if (empty($phpcsfile) === true) { - $this->markTestSkipped(); - } - - // Let's compare expected errors with returned ones. - $this->verify_errors($phpcsfile->getErrors()); - $this->verify_warnings($phpcsfile->getWarnings()); - - $fixerrors = []; - // Let's see if the file has fixable problems and if they become really fixed. - if ($phpcsfile->getFixableCount() > 0) { - $phpcsfile->fixer->fixFile(); - // If there are remaining fixable cases, this is a fix problem. - $tofix = $phpcsfile->getFixableCount(); - if ($tofix > 0) { - $fixerrors[] = "Failed to fix $tofix fixable problems in $this->fixture"; - } - } - - // Now, if there is a file, with the same name than the - // fixture + .fix, use it to verify that the fixed does its job too. - if (is_readable($this->fixture . '.fixed')) { - $diff = $phpcsfile->fixer->generateDiff($this->fixture . '.fixed'); - if (trim($diff) !== '') { - $filename = basename($this->fixture); - $fixedfilename = basename($this->fixture . '.fixed'); - $fixerrors[] = "Fixed version of $filename does not match expected version in $fixedfilename; the diff is\n$diff"; - } - } - - // Any fix problem detected, report it. - if (empty($fixerrors) === false) { - $this->fail(implode(PHP_EOL, $fixerrors)); - } - } - - /** - * Normalize result errors and verify them against error expectations. - * - * @param array $errors error results produced by the CS execution. - */ - private function verify_errors($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'); - } - - /** - * Normalize result warnings and verify them against warning expectations. - * - * @param array $warnings warning results produced by the CS execution - */ - private function verify_warnings($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'); - } - - /** - * Perform all the assertions needed to verify results math expectations. - * - * @param array $expectations error|warning defined expectations - * @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) { - foreach ($expectations as $line => $expectation) { - // Build some information to be shown in case of problems. - $info = ''; - if (count($expectation)) { - $info .= PHP_EOL . 'Expected: ' . json_encode($expectation); - } - $countresults = isset($results[$line]) ? count($results[$line]) : 0; - if ($countresults) { - $info .= PHP_EOL . 'Actual: ' . json_encode($results[$line]); - } - // Verify counts for a line are the same. - $this->assertSame(count($expectation), $countresults, - 'Failed number of ' . $type . ' for line ' . $line . '.' . $info); - // Now verify every expectation requiring matching. - foreach ($expectation as $key => $expectedcontent) { - if (is_string($expectedcontent)) { - $this->assertStringContainsString($expectedcontent, $results[$line][$key], - 'Failed contents matching of ' . $type . ' for element ' . ($key + 1) . ' of line ' . $line . '.'); - } - } - // Delete this line from results. - unset($results[$line]); - } - // Ended looping, verify there aren't remaining results (errors, warnings). - $this->assertSame(array(), $results, - 'Failed to verify that all the ' . $type . ' have been defined by expectations.'); - } - - /** - * Transforms the raw results from CS into a simpler array structure. - * - * The raw results are a more complex structure of nested arrays, with - * information that we don't need. This method transforms that structure - * into a simpler alternative, for easier asserts against the expectations. - * - * @param array $results raw CS results (errors or warnings), - * @return array normalized array. - */ - private function normalize_cs_results($results) { - $normalized = array(); - foreach ($results as $line => $lineerrors) { - foreach ($lineerrors as $errors) { - foreach ($errors as $error) { - if (isset($normalized[$line])) { - $normalized[$line][] = '@Message: ' . $error['message'] . ' @Source: ' . $error['source']; - } else { - $normalized[$line] = array('@Message: ' . $error['message'] . ' @Source: ' . $error['source']); - } - } - } - } - return $normalized; - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/MoodleStandardTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/MoodleStandardTest.php deleted file mode 100644 index 074ec67d..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/MoodleStandardTest.php +++ /dev/null @@ -1,986 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -// phpcs:disable moodle.NamingConventions - -/** - * Test various "moodle" phpcs standard sniffs. - * - * Each case covers one sniff. Self-explanatory - * - * @package local_codechecker - * @category test - * @copyright 2013 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @todo Complete coverage of all Sniffs. - */ -class MoodleStandardTest extends MoodleCSBaseTestCase { - - /** - * Test the PSR2.Methods.MethodDeclaration sniff. - * - * @covers \PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\MethodDeclarationSniff - */ - public function test_psr2_methods_methoddeclaration() { - - // 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'); - - // 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(array( - 33 => 'The static declaration must come after the visibility', - 34 => 1, - 35 => 1, - 37 => 'The final declaration must precede the visibility', - 38 => 1, - 39 => 1, - 41 => array('FinalAfterVisibility', 'StaticBeforeVisibility'), - 42 => 2, - 43 => 2, - 45 => 'The abstract declaration must precede the visibility', - 46 => 1, - 48 => array('AbstractAfterVisibility', 'StaticBeforeVisibility'), - 49 => 2)); - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the moodle.Commenting.InlineComment sniff. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Commenting\InlineCommentSniff - */ - public function test_moodle_commenting_inlinecomment() { - - // 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'); - - // 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([ - 4 => array('3 slashes comments are not allowed'), - 6 => 1, - 8 => 'No space found before comment text', - 28 => 'Inline doc block comments are not allowed; use "// Comment." instead', - 44 => 1, - 73 => 'Perl-style comments are not allowed; use "// Comment." instead', - 78 => '3 slashes comments are not allowed', - 91 => '\'$variable\' does not match next code line \'lets_execute_it...\'', - 94 => 1, - 102 => '\'$cm\' does not match next list() variables @Source: moodle.Commenting.InlineComment.TypeHintingList', - 112 => '\'$cm\' does not match next foreach() as variable @Source: moodle.Commenting.InlineComment.TypeHintingFor', - 118 => 0, - 122 => 1, - 124 => 1, - 126 => 1, - 128 => 1, - 130 => 1, - 134 => 0, - 135 => 0, - 136 => 0, - 137 => 0, - 143 => '@Message: Tab found before comment', - 144 => '@Source: moodle.Commenting.InlineComment.SpacingBefore', - 146 => '@Message: Blank comments are not allowed', - ]); - $this->set_warnings([ - 4 => 0, - 6 => array(null, 'Commenting.InlineComment.InvalidEndChar'), - 55 => array('19 found'), - 57 => array('121 found'), - 59 => array('Found: (no)'), - 61 => 1, - 63 => 1, - 65 => 1, - 67 => 1, - 69 => array('WrongCommentCodeFoundBefore'), - 71 => 3, - 75 => 2, - 77 => 1, - 79 => 1, - 118 => 0, - 122 => 0, - ]); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the moodle.Commenting.InlineComment sniff. - * - * Note that, while this test continues passing, because - * we load the .js file manually, now the moodle standard - * by default enforces --extensions=php, so no .js file - * will be inspected by default ever. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Commenting\InlineCommentSniff - */ - public function test_moodle_commenting_inlinecomment_js() { - - // 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'); - - // 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(array( - 1 => array('3 slashes comments are not allowed'), - 3 => 1, - 5 => 'No space found before comment text', - )); - $this->set_warnings(array( - 3 => array(null, 'Commenting.InlineComment.InvalidEndChar'), - )); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the moodle.ControlStructures.ControlSignature sniff. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\ControlStructures\ControlSignatureSniff - */ - public function test_moodle_controlstructures_controlsignature() { - - // 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'); - - // 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(array( - 3 => 0, - 4 => array('found "if(...) {'), - 5 => 0, - 6 => '@Message: Expected "} else {\n"')); - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the moodle.Files.LineLength sniff. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\LineLengthSniff - */ - public function test_moodle_files_linelength() { - - // 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'); - - // 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(array( - 21 => 'maximum limit of 180 characters; contains 181 characters', - 22 => 'maximum limit of 180 characters; contains 181 characters')); - $this->set_warnings(array( - 13 => 'exceeds 132 characters; contains 133 characters', - 14 => 'exceeds 132 characters; contains 133 characters', - 17 => 'exceeds 132 characters; contains 180 characters', - 18 => 'exceeds 132 characters; contains 180 characters')); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the Generic.Arrays.DisallowLongArraySyntax sniff. - * - * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff - */ - public function test_generic_array_disallowlongarraysyntax(): 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'); - - // 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([ - 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(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the Generic.Files.LineEndings sniff. - * - * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineEndingsSniff - */ - public function test_generic_files_lineendings() { - - // 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'); - - // 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(array( - 1 => 'line character is invalid; expected "\n" but found "\r\n" @Source: Generic.Files.LineEndings.InvalidEOLChar')); - - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the Generic.Files.EndFileNewline sniff. - * - * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Files\EndFileNewlineSniff - */ - public function test_generic_files_endfilenewline() { - - // 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'); - - // 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(array( - 4 => 'File must end with a newline character @Source: Generic.Files.EndFileNewline.NotFound')); - - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the Generic.WhiteSpace.DisallowTabIndent sniff. - * - * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Whitespace\DisallowTabIndentSniff - */ - public function test_generic_whitespace_disalowtabindent() { - - // 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'); - - // 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(array( - 9 => 'Spaces must be used to indent lines; tabs are not allowed', - 10 => 1, - 11 => 1)); - - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the Generic.Functions.OpeningFunctionBraceKernighanRitchie sniff. - * - * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\OpeningFunctionBraceKernighanRitchieSniff - */ - public function test_generic_functions_openingfunctionbracekerninghanritchie() { - - // 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'); - - // 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(array( - 6 => 'Expected 1 space before opening brace; found 0', - 9 => 1, - 12 => 'Expected 1 space before opening brace; found 3', - 15 => 1, - 20 => 'Expected 1 space before opening brace; found 0', - 23 => 1, - 26 => 'Expected 1 space before opening brace; found 3', - 29 => 1)); - - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the Generic.Classes.OpeningBraceSameLine sniff. - * - * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\Classes\OpeningBraceSameLineSniff - */ - public function test_generic_classes_openingclassbrace() { - - // 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'); - - // 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([ - 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', - 14 => 'Expected 1 space before opening brace; found 3', - 19 => 'Opening brace should be on the same line as the declaration for class test05', - ]); - - $this->set_warnings([]); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the Generic.WhiteSpace.ScopeIndent sniff. - * - * @covers \PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ScopeIndentSniff - */ - public function test_generic_whitespace_scopeindent() { - - // 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'); - - // 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(array( - 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(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the moodle.PHP.DeprecatedFunctions sniff. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\PHP\DeprecatedFunctionsSniff - */ - public function test_moodle_php_deprecatedfunctions() { - - // 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'); - - // 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(array()); - $warnings = array(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); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the moodle.PHP.ForbiddenFunctions sniff. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\PHP\ForbiddenFunctionsSniff - */ - public function test_moodle_php_forbiddenfunctions() { - - // 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'); - - // 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(array( - 5 => 'function sizeof() is forbidden; use count()', - 6 => 1, - 8 => 1, - 9 => 1, - 10 => 1, - 13 => 'function extract() is forbidden', - 14 => 0, // These are eval, goto and got labels handled by {@see moodle_Sniffs_PHP_ForbiddenTokensSniff}. - 15 => 0, - 16 => 0, - 17 => 0, - )); - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the moodle.PHP.ForbiddenGlobalUse snifff. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\PHP\ForbiddenGlobalUseSniff - */ - public function test_moodle_php_forbidden_global_use() { - // 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'); - - // 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([ - 1 => 0, - 2 => 0, - 3 => 0, - 4 => 0, - 5 => 0, - 6 => 0, - 7 => 0, - 8 => 0, - 9 => 0, - 10 => 0, - 11 => 0, - 12 => 0, - 13 => 0, - 14 => 0, - 15 => 0, - 16 => 'global $OUTPUT cannot be used in renderers. Use $this->output.', - 17 => 'global $OUTPUT cannot be used in renderers. Use $this->output.', - 18 => 0, - 19 => 0, - 20 => 0, - 21 => 'global $PAGE cannot be used in renderers. Use $this->page.', - 22 => 'global $PAGE cannot be used in renderers. Use $this->page.', - 23 => 0, - 24 => 0, - 25 => 0, - 26 => ['global $OUTPUT cannot be used in renderers. Use $this->output.', - 'global $PAGE cannot be used in renderers. Use $this->page.'], - 27 => ['global $OUTPUT cannot be used in renderers. Use $this->output.', - 'global $PAGE cannot be used in renderers. Use $this->page.'], - 28 => 0, - 29 => 0, - 30 => 0, - 31 => 'global $PAGE cannot be used in renderers. Use $this->page.', - 32 => 'global $PAGE cannot be used in renderers. Use $this->page.', - 33 => 0, - 34 => 0, - 35 => 0, - 36 => 0, - 37 => 0, - 38 => 'global $OUTPUT cannot be used in renderers. Use $this->output.', - 39 => 'global $OUTPUT cannot be used in renderers. Use $this->output.', - 40 => 0, - 41 => 0, - 42 => 0, - 43 => 0, - 44 => 0, - 45 => 0, - 46 => 0, - 47 => 0, - 48 => 0, - 49 => 0, - 50 => 0, - 51 => 0, - 52 => 0, - 53 => 0, - 54 => 0, - 55 => 0, - 56 => 'global $PAGE cannot be used in block classes. Use $this->page.', - 57 => 'global $PAGE cannot be used in block classes. Use $this->page.', - 58 => 0, - 59 => 0, - ]); - $this->set_warnings([]); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the moodle.PHP.ForbiddenTokens sniff. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\PHP\ForbiddenTokensSniff - */ - public function test_moodle_php_forbiddentokens() { - - // 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'); - - // 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(array( - 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 => array('backticks', 'backticks'))); - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test the moodle.Strings.ForbiddenStrings sniff. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Strings\ForbiddenStringsSniff - */ - public function test_moodle_strings_forbiddenstrings() { - - // 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'); - - // 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(array( - 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', - 12 => 0, - // Only if the engine supported /e. Completely removed in PHP 7.3. - 15 => (version_compare(PHP_VERSION, '7.3.0', '<') ? - 'The use of the /e modifier in regular expressions is forbidden' : 0), - 16 => (version_compare(PHP_VERSION, '7.3.0', '<') ? 1 : 0), - 23 => (version_compare(PHP_VERSION, '7.3.0', '<') ? 2 : 1), - 26 => 0, - 27 => 0)); - $this->set_warnings(array( - 19 => array('backticks in strings is not recommended'), - 20 => 1, - 23 => 1, - 36 => 'backticks in strings', - 37 => 1)); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test external sniff incorporated to moodle standard. - * - * @covers \PHPCompatibility\Sniffs\FunctionUse\RemovedFunctionsSniff - */ - public function test_phpcompatibility_php_deprecatedfunctions() { - - // 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'); - - // 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(array( - 5 => array('Function ereg_replace', 'Use call_user_func() instead', '@Source: PHPCompat') - )); - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test call time pass by reference. - * - * @covers \PHPCompatibility\Sniffs\Syntax\ForbiddenCallTimePassByReferenceSniff - */ - public function test_phpcompatibility_php_forbiddencalltimepassbyreference() { - - // 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'); - - // 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(array( - 6 => array('call-time pass-by-reference is deprecated'), - 7 => array('@Source: PHPCompat'))); - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test variable naming standards - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\NamingConventions\ValidVariableNameSniff - */ - public function test_moodle_namingconventions_variablename() { - - // 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'); - - // 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(array( - 4 => 'must not contain underscores', - 5 => 'must be all lower-case', - 6 => 'must not contain underscores', - 7 => array('must be all lower-case', 'must not contain underscores'), - 8 => 0, - 9 => 0, - 12 => 'must not contain underscores', - 13 => 'must be all lower-case', - 14 => array('must be all lower-case', 'must not contain underscores'), - 15 => 0, - 16 => 0, - 17 => 'The \'var\' keyword is not permitted', - 20 => 'must be all lower-case', - 21 => 'must not contain underscores', - 22 => array('must be all lower-case', 'must not contain underscores'), - )); - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test operator spacing standards - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\OperatorSpacingSniff - */ - public function test_squiz_operator_spacing() { - - // 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'); - - // 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(array( - 6 => 0, - 7 => 'Expected 1 space before', - 8 => 'Expected 1 space after', - 9 => array('Expected 1 space before', 'Expected 1 space after'), - 10 => 0, - 11 => 'Expected 1 space after "=>"; 3 found', - 12 => 0, - 13 => 0, - 14 => 'Expected 1 space before', - 15 => 'Expected 1 space after', - 16 => array('Expected 1 space before', 'Expected 1 space after'), - 17 => 0, - 18 => 'Expected 1 space after "="; 2 found', - 19 => 0, - 20 => 0, - 21 => 0, - 22 => 'Expected 1 space before', - 23 => 'Expected 1 space after', - 24 => array('Expected 1 space before', 'Expected 1 space after'), - 25 => 0, - 26 => 'Expected 1 space after "+"; 2 found', - 27 => 'Expected 1 space before "+"; 2 found', - 28 => 0, - 29 => 'Expected 1 space before', - 30 => 'Expected 1 space after', - 31 => array('Expected 1 space before', 'Expected 1 space after'), - 32 => 0, - 33 => 'Expected 1 space after "-"; 2 found', - 34 => 'Expected 1 space before "-"; 2 found', - 35 => 0, - 36 => 'Expected 1 space before', - 37 => 'Expected 1 space after', - 38 => array('Expected 1 space before', 'Expected 1 space after'), - 39 => 0, - 40 => 'Expected 1 space after "*"; 2 found', - 41 => 'Expected 1 space before "*"; 2 found', - 42 => 0, - 43 => 'Expected 1 space before', - 44 => 'Expected 1 space after', - 45 => array('Expected 1 space before', 'Expected 1 space after'), - 46 => 0, - 47 => 'Expected 1 space after "/"; 2 found', - 48 => 'Expected 1 space before "/"; 2 found', - 49 => 0, - 50 => 0, - 51 => 0, - 52 => 0, - 53 => 0, - 54 => 0, - 55 => 0, - 56 => 0, - 57 => 0, - 58 => 0, - 59 => 0, - 60 => 0, - 61 => 0, - 62 => 0, - 63 => 0 - )); - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test object operator spacing standards - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ObjectOperatorSpacingSniff - */ - public function test_squiz_object_operator_spacing() { - - // 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'); - - // 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(array()); - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test object operator indentation standards - * - * @covers \PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ObjectOperatorIndentSniff - */ - public function test_pear_object_operator_indent() { - - // 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'); - - // 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(array( - 40 => 'not indented correctly; expected 4 spaces but found 2', - 41 => '@Source: PEAR.WhiteSpace.ObjectOperatorIndent.Incorrect', - 44 => 1, - 45 => 1, - 49 => 'not indented correctly; expected 4 spaces but found 6', - 50 => '@Source: PEAR.WhiteSpace.ObjectOperatorIndent.Incorrect', - 53 => 1, - 54 => 1, - 61 => 1, - 62 => 1, - 65 => 1, - 66 => 1, - 69 => 1, - 70 => 1, - )); - $this->set_warnings(array()); - - // Let's do all the hard work! - $this->verify_cs_results(); - } - - /** - * Test variable naming standards - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\CommentedOutCodeSniff - */ - public function test_squid_php_commentedoutcode() { - - // 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'); - - // 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(array()); - $this->set_warnings(array( - 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(); - } - - /** - * Test the moodle.Files.RequireLogin sniff detects problems. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\RequireLoginSniff - */ - public function test_moodle_files_requirelogin_problem() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.RequireLogin'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_requirelogin/problem.php'); - - $this->set_errors(array()); - $this->set_warnings(array( - 25 => ', require_course_login, require_admin, admin_externalpage_setup) following config inclusion. None found' - )); - - $this->verify_cs_results(); - } - - /** - * Test the moodle.Files.RequireLogin sniff with login. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\RequireLoginSniff - */ - public function test_moodle_files_requirelogin_require_login_ok() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.RequireLogin'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_requirelogin/require_login_ok.php'); - - $this->set_errors(array()); - $this->set_warnings(array()); - - $this->verify_cs_results(); - } - - /** - * Test the moodle.Files.RequireLogin sniff with require_course_login(). - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\RequireLoginSniff - */ - public function test_moodle_files_requirelogin_require_course_login_ok() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.RequireLogin'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_requirelogin/require_course_login_ok.php'); - - $this->set_errors(array()); - $this->set_warnings(array()); - - $this->verify_cs_results(); - } - - /** - * Test the moodle.Files.RequireLogin sniff with external page setup. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\RequireLoginSniff - */ - public function test_moodle_files_requirelogin_admin_externalpage_setup_ok() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.RequireLogin'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_requirelogin/admin_externalpage_setup_ok.php'); - - $this->set_errors(array()); - $this->set_warnings(array()); - - $this->verify_cs_results(); - } - - /** - * Test the moodle.Files.RequireLogin in a CLI script. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\RequireLoginSniff - */ - public function test_moodle_files_requirelogin_cliscript_ok() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.RequireLogin'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_requirelogin/cliscript_ok.php'); - - $this->set_errors(array()); - $this->set_warnings(array()); - - $this->verify_cs_results(); - } - - /** - * Test the moodle.Files.RequireLogin sniff in a no moodle cookies script. - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Files\RequireLoginSniff - */ - public function test_moodle_files_requirelogin_nomoodlecookies_ok() { - $this->set_standard('moodle'); - $this->set_sniff('moodle.Files.RequireLogin'); - $this->set_fixture(__DIR__ . '/fixtures/moodle_files_requirelogin/nomoodlecookies_ok.php'); - - $this->set_errors(array()); - $this->set_warnings(array()); - - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/MoodleUtilTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/MoodleUtilTest.php deleted file mode 100644 index 4b39de13..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/MoodleUtilTest.php +++ /dev/null @@ -1,677 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; -use PHP_CodeSniffer\Config; -use PHP_CodeSniffer\Exceptions\DeepExitException; -use PHP_CodeSniffer\Files\File; -use PHP_CodeSniffer\Ruleset; -use org\bovigo\vfs\vfsStream; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the MoodleUtil specific moodle utilities class - * - * @package local_codechecker - * @category test - * @copyright 2021 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \MoodleHQ\MoodleCS\moodle\Util\MoodleUtil - */ -class MoodleUtilTest extends MoodleCSBaseTestCase { - - /** - * Unit test for calculateAllComponents. - * - * Not 100% orthodox because {@see calculateAllComponents()} is protected, - * and it's already indirectly tested by {@see test_getMoodleComponent()} - * but it has some feature that we need to test individually here. - */ - public function test_calculateAllComponents() { - // Let's calculate moodleRoot. - $vfs = vfsStream::setup('root', null, []); - $moodleRoot = $vfs->url(); - - // Let's prepare a components file, with some correct and incorrect entries. - $components = - "nonono,mod_forum,{$moodleRoot}/mod_forum\n" . // Wrong type. - "plugin,mod__nono,{$moodleRoot}/mod_forum\n" . // Wrong component. - "plugin,mod_forum,/no/no/no/no//mod_forum\n" . // Wrong path. - "plugin,local_codechecker,{$moodleRoot}/local/codechecker\n" .// All ok. - "plugin,mod_forum,{$moodleRoot}/mod/forum\n"; // All ok. - - vfsStream::create( - ['components.txt' => $components,], - $vfs - ); - - // Set codechecker config to point to it. - Config::setConfigData('moodleComponentsListPath', $vfs->url() . '/components.txt', true); - - // Let's run calculateAllComponents() and evaluate results. - $method = new \ReflectionMethod(MoodleUtil::class, 'calculateAllComponents'); - $method->setAccessible(true); - $method->invokeArgs(null, [$moodleRoot]); - - // Let's inspect which components have been loaded. - $property = new \ReflectionProperty(MoodleUtil::class, 'moodleComponents'); - $property->setAccessible(true); - $loadedComponents = $property->getValue(); - - $this->assertCount(2, $loadedComponents); - $this->assertSame(['mod_forum', 'local_codechecker'], - array_keys($loadedComponents)); // Verify they are ordered in ascending order. - $this->assertSame(["{$moodleRoot}/mod/forum", "{$moodleRoot}/local/codechecker"], - array_values($loadedComponents)); // Verify component paths are also the expected ones. - - // Now be evil and try with an unreadable file, it must throw an exception. - - $this->cleanMoodleUtilCaches(); // Need to clean previous cached values. - Config::setConfigData('moodleComponentsListPath', '/path/to/non/readable/file', true); - - // We cannot use expectException() here, because we need to clean caches at the end. - try { - $method->invokeArgs(null, [$moodleRoot]); - $this->fail('\PHP_CodeSniffer\Exceptions\DeepExitException was expected, got none'); - } catch (\Exception $e) { - $this->assertInstanceOf(\PHP_CodeSniffer\Exceptions\DeepExitException::class, $e); - } - - // Ensure cached information doesn't affect other tests. - $this->cleanMoodleUtilCaches(); - Config::setConfigData('moodleComponentsListPath', null, true); - } - - /** - * Provider for test_getMoodleComponent. - */ - public function getMoodleComponentProvider() { - return [ - 'moodleComponent_file_without_moodleroot' => [ - 'config' => ['file' => sys_get_temp_dir() . '/notexists.php'], - 'return' => ['value' => null], - 'reset' => true, - 'selfPath' => false, - 'requireMockMoodle' => false, - ], - 'moodleComponent_file_without_component_class' => [ - 'config' => ['file' => dirname(__FILE__) . '/fixtures/moodleutil/good/lib/lib.php'], - 'return' => ['value' => null], - 'reset' => true, - 'selfPath' => false, - 'requireMockMoodle' => false, - ], - 'moodleComponent_file_valid' => [ - 'config' => ['file' => 'local/invented/lib.php'], - 'return' => ['value' => 'local_invented'], - 'reset' => false, // Prevent resetting cached information to verify next works. - 'selfPath' => false, - 'requireMockMoodle' => true, - ], - 'moodleComponent_file_already_cached' => [ - 'config' => ['file' => 'lib/lib.php'], - 'return' => ['value' => 'core'], - 'reset' => true, - 'selfPath' => false, - 'requireMockMoodle' => true, - ], - 'moodleComponent_file_cache_cleaned' => [ - 'config' => ['file' => dirname(__FILE__) . '/fixtures/moodleutil/good/lib/lib.php'], - 'return' => ['value' => null], - 'reset' => true, - 'selfPath' => false, - 'requireMockMoodle' => false, - ], - 'moodleComponent_file_without_component' => [ - 'config' => ['file' => dirname(__FILE__, 5) . '/userpix/index.php'], - 'return' => ['value' => null], - 'reset' => true, - 'selfPath' => false, - 'requireMockMoodle' => false, - ], - ]; - } - - /** - * Unit test for getMoodleComponent. - * - * @param array $config get the Config from provider. - * @param array $return expected result of the test. - * @param bool $reset to decide if static caches should be reset before the test. - * @param bool $selfPath to decide if codechecker own path is good to find a valid moodle root. - * @param bool $requireMockMoodle Whether a mock Moodle root is required for this test. - * - * @dataProvider getMoodleComponentProvider - */ - public function test_getMoodleComponent( - array $config, - array $return, - bool $reset = true, - bool $selfPath = true, - bool $requireMockMoodle = false - ) { - if ($requireMockMoodle) { - // We have to mock the passed moodleRoot. - $vfs = vfsStream::setup('mocksite', null, []); - vfsStream::copyFromFileSystem(__DIR__ . '/fixtures/moodleutil/complete', $vfs); - $config['moodleRoot'] = $vfs->url(); // Let's add it to the standard config and immediately use it. - Config::setConfigData('moodleRoot', $config['moodleRoot'], true); - $this->requireRealMoodleRoot(); - - // Also, we need to set the config['file'] to point to the vfs one. - $config['file'] = $vfs->url() . '/' . $config['file']; - } - - $file = null; - // Set config options when passed. - if ($config) { - foreach ($config as $key => $value) { - if ($key === 'file') { - // We are passing a real File, prepare it. - $phpcsConfig = new Config(); - $phpcsRuleset = new Ruleset($phpcsConfig); - $file = new File($value, $phpcsRuleset, $phpcsConfig); - } else { - // Normal config. - Config::setConfigData($key, $value, true); - } - } - } - - // Exception is coming, let's verify it happens. - if (isset($return['exception'])) { - try { - MoodleUtil::getMoodleComponent($file, $selfPath); - } catch (\Exception $e) { - $this->assertInstanceOf($return['exception'], $e); - $this->assertStringContainsString($return['message'], $e->getMessage()); - } - - } else if (array_key_exists('value', $return)) { - // Normal asserting result. - $this->assertSame($return['value'], MoodleUtil::getMoodleComponent($file, $selfPath)); - } - - // Do we want to reset any information cached (by default we do). - if ($reset) { - $this->cleanMoodleUtilCaches(); - } - - // We need to unset all config options when passed. - if ($config) { - foreach ($config as $key => $value) { - Config::setConfigData($key, null, true); - } - } - } - - /** - * Provider for test_getMoodleBranch. - */ - public function getMoodleBranchProvider() { - return [ - // Setting up moodleBranch config/runtime option. - 'moodleBranch_not_integer' => [ - 'config' => ['moodleBranch' => 'noint'], - 'return' => ['exception' => DeepExitException::class, 'message' => 'Value in not an integer'], - ], - 'moodleBranch_big' => [ - 'config' => ['moodleBranch' => '10000'], - 'return' => ['exception' => DeepExitException::class, 'message' => 'Value must be 4 digit max'], - ], - 'moodleBranch_valid' => [ - 'config' => ['moodleBranch' => 999], - 'return' => ['value' => 999], - 'reset' => false, // Prevent resetting cached information to verify next works. - ], - 'moodleBranch_already_cached' => [ - 'config' => ['moodleBranch' => 'noint'], - 'return' => ['value' => 999], - ], - 'moodleBranch_cache_cleaned' => [ // Verify that previous has cleaned cached information. - 'config' => ['moodleBranch' => 'noint'], - 'return' => ['exception' => DeepExitException::class, 'message' => 'Value in not an integer'], - ], - - // Passing a file to check with correct $branch information at moodle root. - 'moodleBranch_pass_file_good' => [ - 'config' => ['file' => dirname(__FILE__) . '/fixtures/moodleutil/good/lib/lib.php'], - 'return' => ['value' => 9876], - ], - - // Passing a file to check with incorrect $branch information at moodle root. - 'moodleBranch_pass_file_bad' => [ - 'config' => ['file' => dirname(__FILE__) . '/fixtures/moodleutil/bad/lib/lib.php'], - 'return' => ['value' => null], - ], - ]; - } - - /** - * Unit test for getMoodleBranch. - * - * @param array $config get the Config from provider. - * @param array $return expected result of the test. - * @param bool $reset to decide if static caches should be reset before the test. - * @param bool $selfPath to decide if codechecker own path is good to find a valid moodle root. - * - * @dataProvider getMoodleBranchProvider - */ - public function test_getMoodleBranch(array $config, array $return, bool $reset = true, bool $selfPath = true) { - $file = null; - // Set config options when passed. - if ($config) { - foreach ($config as $key => $value) { - if ($key === 'file') { - // We are passing a real File, prepare it. - $phpcsConfig = new Config(); - $phpcsRuleset = new Ruleset($phpcsConfig); - $file = new File($value, $phpcsRuleset, $phpcsConfig); - } else { - // Normal config. - Config::setConfigData($key, $value, true); - } - } - } - - // Exception is coming, let's verify it happens. - if (isset($return['exception'])) { - try { - MoodleUtil::getMoodleBranch($file, $selfPath); - } catch (\Exception $e) { - $this->assertInstanceOf($return['exception'], $e); - $this->assertStringContainsString($return['message'], $e->getMessage()); - } - - } else if (array_key_exists('value', $return)) { - // Normal asserting result. - $this->assertSame($return['value'], MoodleUtil::getMoodleBranch($file, $selfPath)); - } - - // Do we want to reset any information cached (by default we do). - if ($reset) { - $this->cleanMoodleUtilCaches(); - } - - // We need to unset all config options when passed. - if ($config) { - foreach ($config as $key => $value) { - Config::setConfigData($key, null, true); - } - } - } - - /** - * Provider for test_getMoodleRoot. - */ - public function getMoodleRootProvider() { - return [ - // Setting up moodleRoot config/runtime option. - 'moodleRoot_not_exists' => [ - 'config' => ['moodleRoot' => '/does/not/exist'], - 'return' => ['exception' => DeepExitException::class, 'message' => 'does not exist or is not readable'], - 'requireRealMoodle' => false, - ], - 'moodleRoot_not_moodle' => [ - 'config' => ['moodleRoot' => sys_get_temp_dir()], - 'return' => ['exception' => DeepExitException::class, 'message' => 'not a valid moodle root'], - 'requireRealMoodle' => false, - ], - 'moodleRoot_valid' => [ - 'config' => ['moodleRoot' => 'some_valid_moodle_root'], - 'return' => ['value' => 'some_valid_moodle_root'], - 'requireRealMoodle' => true, - 'reset' => false, // Prevent resetting cached information to verify next works. - ], - 'moodleRoot_already_cached' => [ - 'config' => ['moodleRoot' => '/does/not/exist'], - 'return' => ['value' => 'some_valid_moodle_root'], - 'requireRealMoodle' => true, - ], - 'moodleRoot_cache_cleaned' => [ // Verify that previous has cleaned cached information. - 'config' => ['moodleRoot' => '/does/not/exist'], - 'return' => ['exception' => DeepExitException::class, 'message' => 'does not exist or is not readable'], - 'requireRealMoodle' => false, - ], - 'moodleRoot_from_fixtures' => [ - 'config' => ['moodleRoot' => dirname(__FILE__) . '/fixtures/moodleutil/good'], - 'return' => ['value' => dirname(__FILE__) . '/fixtures/moodleutil/good'], - 'requireRealMoodle' => false, - ], - - // Passing a file to check. - 'moodleRoot_pass_file' => [ - 'config' => ['file' => dirname(__FILE__) . '/fixtures/moodleutil/good/lib/lib.php'], - 'return' => ['value' => dirname(__FILE__) . '/fixtures/moodleutil/good'], - 'requireRealMoodle' => false, - ], - - // Passing nothing, defaults to this file, that leads to not valid moodle root. - 'moodleRoot_pass_nothing' => [ - 'config' => [], - 'return' => ['value' => null], - 'requireRealMoodle' => false, - ], - ]; - } - - /** - * Unit test for getMoodleRoot. - * - * @param array $config get the Config from provider. - * @param array $return expected result of the test. - * @param bool $reset to decide if static caches should be reset before the test. - * @param bool $selfPath to decide if moodle-cs own path is good to find a valid moodle root. - * @param bool $requireMockMoodle Whether a mock Moodle root is required for this test. - * - * @dataProvider getMoodleRootProvider - */ - public function test_getMoodleRoot( - array $config, - array $return, - bool $requireMockMoodle = false, - bool $reset = true, - bool $selfPath = true - ) { - if ($requireMockMoodle) { - if (isset($config['moodleRoot']) && isset($return['value'])) { - // We have to mock the passed moodleRoot. - $vfs = vfsStream::setup($config['moodleRoot'], null, [ - 'version.php' => 'some version contents, not important for this test', - 'config-dist.php' => 'come config contents, not important for this test', - ]); - $config['moodleRoot'] = $vfs->url(); // Let's add it to the standard config and immediately use it. - Config::setConfigData('moodleRoot', $config['moodleRoot'], true); - $this->requireRealMoodleRoot(); - - // We also have to mock the passed expectation for the test. - $returnVfs = vfsStream::setup($return['value'], null, []); - $return['value'] = $returnVfs->url(); - } - } - - $file = null; - // Set config options when passed. - if ($config) { - foreach ($config as $key => $value) { - if ($key === 'file') { - // We are passing a real File, prepare it. - $phpcsConfig = new Config(); - $phpcsRuleset = new Ruleset($phpcsConfig); - $file = new File($value, $phpcsRuleset, $phpcsConfig); - } else { - // Normal config. - Config::setConfigData($key, $value, true); - } - } - } - - // Exception is coming, let's verify it happens. - if (isset($return['exception'])) { - try { - MoodleUtil::getMoodleRoot($file, $selfPath); - } catch (\Exception $e) { - $this->assertInstanceOf($return['exception'], $e); - $this->assertStringContainsString($return['message'], $e->getMessage()); - } - - } else if (array_key_exists('value', $return)) { - // Normal asserting result. - $this->assertSame($return['value'], MoodleUtil::getMoodleRoot($file), $selfPath); - } - - // Do we want to reset any information cached (by default we do). - if ($reset) { - $this->cleanMoodleUtilCaches(); - } - - // We need to unset all config options when passed. - if ($config) { - foreach ($config as $key => $value) { - Config::setConfigData($key, null, true); - } - } - } - - /** - * Utility method to clean MoodleUtil own "caches" (class properties). - */ - protected function cleanMoodleUtilCaches() { - $moodleRoot = new \ReflectionProperty(MoodleUtil::class, 'moodleRoot'); - $moodleRoot->setAccessible(true); - $moodleRoot->setValue(false); - - $moodleBranch = new \ReflectionProperty(MoodleUtil::class, 'moodleBranch'); - $moodleBranch->setAccessible(true); - $moodleBranch->setValue(false); - - $moodleComponents = new \ReflectionProperty(MoodleUtil::class, 'moodleComponents'); - $moodleComponents->setAccessible(true); - $moodleComponents->setValue([]); - } - - /** - * Data provider for testIsUnitTest. - * - * @return array - */ - public static function isUnitTestProvider(): array - { - return [ - 'Not in tests directory' => [ - 'value' => '/path/to/standard/file_test.php', - 'return' => false, - ], - 'In tests directory' => [ - 'value' => '/path/to/standard/tests/file_test.php', - 'return' => true, - ], - 'In tests directory but missing _test suffix' => [ - 'value' => '/path/to/standard/tests/file.php', - 'return' => false, - ], - 'In tests directory but some idiot put a _test.php suffix on a directory' => [ - 'value' => '/path/to/standard/tests/some_test.php/file.php', - 'return' => false, - ], - 'In test sub-directory' => [ - 'value' => '/path/to/standard/tests/sub/file_test.php', - 'return' => true, - ], - 'In test sub-directory but missing _test suffix' => [ - 'value' => '/path/to/standard/tests/sub/file.php', - 'return' => false, - ], - 'Generator' => [ - 'value' => '/path/to/standard/tests/generator/file_test.php', - 'return' => false, - ], - 'Fixture' => [ - 'value' => '/path/to/standard/tests/fixtures/file_test.php', - 'return' => false, - ], - 'Behat' => [ - 'value' => '/path/to/standard/tests/behat/behat_test_file_test.php', - 'return' => false, - ], - ]; - } - - /** - * @dataProvider isUnitTestProvider - */ - public function testIsUnitTest( - string $filepath, - bool $expected - ): void - { - $phpcsConfig = new Config(); - $phpcsRuleset = new Ruleset($phpcsConfig); - $file = new File($filepath, $phpcsRuleset, $phpcsConfig); - - $this->assertEquals($expected, MoodleUtil::isUnitTest($file)); - } - - /** - * Data provider for testMeetsMinimumMoodleVersion. - * - * @return array - */ - public static function meetsMinimumMoodleVersionProvider(): array - { - return [ - // Setting up moodleBranch config/runtime option. - 'moodleBranch_not_integer' => [ - 'moodleVersion' => 'noint', - 'minVersion' => 311, - 'return' => ['exception' => DeepExitException::class, 'message' => 'Value in not an integer'], - ], - 'moodleBranch_big' => [ - 'moodleVersion' => '10000', - 'minVersion' => 311, - 'return' => ['exception' => DeepExitException::class, 'message' => 'Value must be 4 digit max'], - ], - 'moodleBranch_valid_meets_minimum' => [ - 'moodleVersion' => 999, - 'minVersion' => 311, - 'return' => ['value' => true], - ], - 'moodleBranch_valid_equals_minimum' => [ - 'moodleVersion' => 311, - 'minVersion' => 311, - 'return' => ['value' => true], - ], - 'moodleBranch_valid_does_not_meet_minimum' => [ - 'moodleVersion' => 311, - 'minVersion' => 402, - 'return' => ['value' => false], - ], - 'moodleBranch_valid_but_empty' => [ - 'moodleVersion' => 0, - 'minVersion' => 311, - 'return' => ['value' => null], - ], - ]; - } - - /** - * @dataProvider meetsMinimumMoodleVersionProvider - * @param string|int $moodleVersion - * @param int $minversion - * @param array $return - */ - public function testMeetsMinimumMoodleVersion( - $moodleVersion, - int $minVersion, - array $return - ): void - { - Config::setConfigData('moodleBranch', $moodleVersion, true); - - $phpcsConfig = new Config(); - $phpcsRuleset = new Ruleset($phpcsConfig); - $file = new File('/path/to/tests/file.php', $phpcsRuleset, $phpcsConfig); - - // Exception is coming, let's verify it happens. - if (isset($return['exception'])) { - try { - MoodleUtil::getMoodleBranch($file); - } catch (\Exception $e) { - $this->assertInstanceOf($return['exception'], $e); - $this->assertStringContainsString($return['message'], $e->getMessage()); - } - } else if (array_key_exists('value', $return)) { - // Normal asserting result. - $this->assertSame($return['value'], MoodleUtil::meetsMinimumMoodleVersion($file, $minVersion)); - } - - // Do we want to reset any information cached (by default we do). - $this->cleanMoodleUtilCaches(); - - // We need to unset all config options when passed. - Config::setConfigData('moodleBranch', null, true); - } - - public static function findClassMethodPointerProvider(): array - { - return [ - [ - 'instance_method', - true, - ], - [ - 'protected_method', - true, - ], - [ - 'private_method', - true, - ], - [ - 'static_method', - true, - ], - [ - 'protected_static_method', - true, - ], - [ - 'private_static_method', - true, - ], - [ - 'not_found_method', - false, - ], - ]; - } - - /** - * @dataProvider findClassMethodPointerProvider - */ - public function testFindClassMethodPointer( - string $methodName, - bool $found - ): void - { - $phpcsConfig = new Config(); - $phpcsRuleset = new Ruleset($phpcsConfig); - $phpcsFile = new \PHP_CodeSniffer\Files\LocalFile( - __DIR__ . '/fixtures/moodleutil/test_with_methods_to_find.php', - $phpcsRuleset, - $phpcsConfig - ); - - $phpcsFile->process(); - $classPointer = $phpcsFile->findNext(T_CLASS, 0); - - $pointer = MoodleUtil::findClassMethodPointer( - $phpcsFile, - $classPointer, - $methodName - ); - - if ($found) { - $this->assertGreaterThan(0, $pointer); - } else { - $this->assertNull($pointer); - } - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/NamingConventionsValidFunctionNameTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/NamingConventionsValidFunctionNameTest.php deleted file mode 100644 index 501830c6..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/NamingConventionsValidFunctionNameTest.php +++ /dev/null @@ -1,98 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the ValidFunctionName sniff. - * - * @package local_codechecker - * @category test - * @copyright 2022 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\NamingConventions\ValidFunctionNameSniff - */ -class NamingConventionsValidFunctionNameTest extends MoodleCSBaseTestCase { - - /** - * Data provider for self::test_namingconventions_validfunctionname - */ - public function provider_namingconventions_validfunctionname() { - return [ - 'Correct' => [ - 'fixture' => 'fixtures/namingconventions/validfunctionname_correct.php', - 'errors' => [], - 'warnings' => [], - ], - 'Lower' => [ - 'fixture' => 'fixtures/namingconventions/validfunctionname_lower.php', - 'errors' => [ - 5 => 'Public method name "class_with_correct_function_names::notUpperPlease" must be in lower-case', - 11 => 'moodle.NamingConventions.ValidFunctionName.LowercaseMethod', - 15 => '@Message: method name "interface_with_correct_function_names::withoutScope"', - 20 => 'moodle.NamingConventions.ValidFunctionName.LowercaseFunction', - ], - 'warnings' => [], - ], - 'Global' => [ - 'fixture' => 'fixtures/namingconventions/validfunctionname_global.php', - 'errors' => [ - 4 => 'moodle.NamingConventions.ValidFunctionName.MagicLikeFunction', - 8 => '"jsonSerialize" must be lower-case letters only', - ], - 'warnings' => [], - ], - 'Scoped' => [ - 'fixture' => 'fixtures/namingconventions/validfunctionname_scoped.php', - 'errors' => [ - '5' => '__magiclike" is invalid; only PHP magic methods should be prefixed with a double underscore', - ], - 'warnings' => [], - ], - ]; - } - - /** - * Test the moodle.NamingConventions.ValidFunctionName sniff - * - * @param string $fixture relative path to fixture to use. - * @param array $errors array of errors expected. - * @param array $warnings array of warnings expected. - * @dataProvider provider_namingconventions_validfunctionname - */ - public function test_namingconventions_validfunctionname(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); - - // 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); - - // Let's do all the hard work! - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/PHPIncludingFileTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/PHPIncludingFileTest.php deleted file mode 100644 index 641f1a96..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/PHPIncludingFileTest.php +++ /dev/null @@ -1,56 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the IncludingFile sniff. - * - * @package local_codechecker - * @category test - * @copyright 2021 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\PHP\IncludingFileSniff - */ -class PHPIncludingFileTest extends MoodleCSBaseTestCase { - - public function test_php_includingfile() { - // 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'); - - // 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([ - 9 => '@Message: "require" must be immediately followed by an open parenthesis', - 10 => '@Source: moodle.PHP.IncludingFile.BracketsRequired', - 13 => 1, - 14 => 1, - 17 => '@Source: moodle.PHP.IncludingFile.UseRequire', - 18 => '@Source: moodle.PHP.IncludingFile.UseRequireOnce', - ]); - $this->set_warnings([]); - - // Let's do all the hard work! - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/PHPMemberVarScopeTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/PHPMemberVarScopeTest.php deleted file mode 100644 index 9becd599..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/PHPMemberVarScopeTest.php +++ /dev/null @@ -1,52 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the IncludingFile sniff. - * - * @package local_codechecker - * @category test - * @copyright 2021 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\PHP\MemberVarScopeSniff - */ -class PHPMemberVarScopeTest extends MoodleCSBaseTestCase { - - public function test_php_membervarscope() { - // 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'); - - // 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([ - 8 => '@Message: Scope modifier not specified for member variable "$missingprop"', - 9 => '@Source: moodle.PHP.MemberVarScope.Missing', - ]); - $this->set_warnings([]); - - // Let's do all the hard work! - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/PHPUnitTestCaseCoversTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/PHPUnitTestCaseCoversTest.php deleted file mode 100644 index 67434b10..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/PHPUnitTestCaseCoversTest.php +++ /dev/null @@ -1,146 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the TestCaseCoversSniff sniff. - * - * @package local_codechecker - * @category test - * @copyright 2022 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\PHPUnit\TestCaseCoversSniff - */ -class PHPUnitTestCaseCoversTest extends MoodleCSBaseTestCase { - - /** - * Data provider for self::test_phpunit_testcasecovers - */ - public function provider_phpunit_testcasecovers() { - return [ - 'Correct' => [ - 'fixture' => 'fixtures/phpunit/testcasecovers_correct.php', - 'errors' => [], - 'warnings' => [], - ], - 'Contradiction' => [ - 'fixture' => 'fixtures/phpunit/testcasecovers_contradiction.php', - 'errors' => [ - 7 => 'contradiction_test has both', - 8 => 'TestCaseCovers.ContradictoryClass', - 12 => 'test_something() has both', - 13 => 'TestCaseCovers.ContradictoryMethod', - ], - 'warnings' => [ - 8 => 1, - 12 => 1, - 13 => 1, - ], - ], - 'Missing' => [ - 'fixture' => 'fixtures/phpunit/testcasecovers_missing.php', - 'errors' => [], - 'warnings' => [ - 8 => 'test_something() is missing any coverage information', - ], - ], - 'Mixed' => [ - 'fixture' => 'fixtures/phpunit/testcasecovers_mixed.php', - 'errors' => [], - 'warnings' => [ - 7 => 'contradictionmixed_test has @coversNothing, but there are methods covering stuff', - 11 => 'TestCaseCovers.ContradictoryMixed', - ], - ], - 'Redundant' => [ - 'fixture' => 'fixtures/phpunit/testcasecovers_redundant.php', - 'errors' => [], - 'warnings' => [ - 11 => 'has @coversNothing, but class also has it, redundant', - ], - ], - 'Skipped' => [ - 'fixture' => 'fixtures/phpunit/testcasecovers_skipped.php', - 'errors' => [], - 'warnings' => [], - ], - 'Covers' => [ - 'fixture' => 'fixtures/phpunit/testcasecovers_covers.php', - 'errors' => [ - 9 => 'it must be FQCN (\\ prefixed) or point to method (:: prefixed)', - 10 => 'it must contain some value', - 17 => 'TestCaseCovers.NoFQCNOrMethod', - 18 => 'TestCaseCovers.Empty', - ], - 'warnings' => [], - ], - 'CoversDefaultClass' => [ - 'fixture' => 'fixtures/phpunit/testcasecovers_coversdefaultclass.php', - 'errors' => [ - 8 => 'Wrong @coversDefaultClass annotation, it must be FQCN (\\ prefixed)', - 9 => 'TestCaseCovers.WrongMethod', - 10 => '@coversDefaultClass annotation, it must contain some value', - 14 => 'test_something() has @coversDefaultClass tag', - 15 => 'TestCaseCovers.DefaultClassNotAllowed', - 16 => 'TestCaseCovers.DefaultClassNotAllowed', - ], - 'warnings' => [], - ], - 'CoversNothing' => [ - 'fixture' => 'fixtures/phpunit/testcasecovers_coversnothing.php', - 'errors' => [ - 7 => '@coversNothing annotation, it must be empty', - 11 => 'TestCaseCovers.NotEmpty', - ], - 'warnings' => [ - 11 => 'has @coversNothing, but class also has it, redundant', - ], - ], - ]; - } - - /** - * Test the moodle.PHPUnit.TestCaseCovers sniff - * - * @param string $fixture relative path to fixture to use. - * @param array $errors array of errors expected. - * @param array $warnings array of warnings expected. - * @dataProvider provider_phpunit_testcasecovers - */ - public function test_phpunit_testcasecovers(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); - - // 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); - - // Let's do all the hard work! - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/PHPUnitTestCaseNamesTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/PHPUnitTestCaseNamesTest.php deleted file mode 100644 index 191519e4..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/PHPUnitTestCaseNamesTest.php +++ /dev/null @@ -1,175 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the TestCaseNamesSniff sniff. - * - * @package local_codechecker - * @category test - * @copyright 2021 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\PHPUnit\TestCaseNamesSniff - */ -class PHPUnitTestCaseNamesTest extends MoodleCSBaseTestCase { - - /** - * Data provider for self::test_phpunit_testcasenames - */ - public function provider_phpunit_testcasenames() { - return [ - 'Missing' => [ - 'fixture' => 'fixtures/phpunit/testcasenames_missing.php', - 'errors' => [ - 7 => '@Message: PHPUnit test file missing any valid testcase class', - 14 => 'Missing', - ], - 'warnings' => [], - ], - 'Irregular' => [ - 'fixture' => 'fixtures/phpunit/testcasenames_test_testcase_irregular.php', - 'errors' => [ - 8 => '@Message: PHPUnit irregular testcase name found: testcasenames_test_testcase_irregular', - ], - 'warnings' => [], - ], - 'Abstract methods in a testcase' => [ - 'fixture' => 'fixtures/phpunit/testcasenames_with_abstract_test.php', - 'errors' => [], - 'warnings' => [], - ], - 'NoMatch' => [ - 'fixture' => 'fixtures/phpunit/testcasenames_nomatch.php', - 'errors' => [], - 'warnings' => [ - 8 => '"testcasenames_nomatch_test" does not match file name "testcasenames_nomatch"', - ], - ], - 'UnexpectedNS' => [ - 'fixture' => 'fixtures/phpunit/testcasenames_unexpected_ns.php', - 'errors' => [ - 2 => 'namespace "local_wrong" does not match expected file namespace "local_codechecker"', - 8 => 1, - ], - 'warnings' => [], - ], - 'UnexpectedLevel2NS' => [ - 'fixture' => 'fixtures/phpunit/testcasenames_unexpected_level2ns.php', - 'errors' => [ - 8 => 1, - ], - 'warnings' => [ - 2 => 'does not match its expected location at "tests/level2/level3"' - ], - ], - 'CorrectLevel2NS' => [ - 'fixture' => 'fixtures/phpunit/testcasenames_correct_level2ns.php', - 'errors' => [ - 8 => 1, - ], - 'warnings' => [], - ], - 'MissingNS' => [ - 'fixture' => 'fixtures/phpunit/testcasenames_missing_ns.php', - 'errors' => [ - 7 => 1, - ], - 'warnings' => [ - 7 => 'add it to the "local_codechecker" namespace, using more levels', - ], - ], - 'DuplicateExists' => [ - 'fixture' => 'fixtures/phpunit/testcasenames_duplicate_exists.php', - 'errors' => [ - 8 => [ - 'irregular testcase name found', - 'testcasenames_duplicate_exists" already exists at "phpunit_fake_exists"', - ], - ], - 'warnings' => [], - ], - 'ProposedExists' => [ - 'fixture' => 'fixtures/phpunit/testcasenames_proposed_exists.php', - 'errors' => [ - 8 => [ - 'irregular testcase name found', - 'testcasenames_proposed_exists" already proposed for "phpunit_fake_proposed"', - ], - ], - 'warnings' => [], - ], - 'DuplicateProposed' => [ - 'fixture' => 'fixtures/phpunit/testcasenames_duplicate_proposed.php', - 'errors' => [ - 7 => [ - 'irregular testcase name found', - 'testcasenames_duplicate_proposed" already proposed for "phpunit_fake_proposed"', - ], - ], - 'warnings' => [ - 7 => 1 - ], - ], - 'ExistsProposed' => [ - 'fixture' => 'fixtures/phpunit/testcasenames_exists_proposed.php', - 'errors' => [ - 7 => [ - 'irregular testcase name found', - 'testcasenames_exists_proposed" already exists at "phpunit_fake_exists"', - ], - ], - 'warnings' => [ - 7 => 1 - ], - ], - ]; - } - - /** - * Test the moodle.PHPUnit.TestCaseNames sniff - * - * @param string $fixture relative path to fixture to use. - * @param array $errors array of errors expected. - * @param array $warnings array of warnings expected. - * @dataProvider provider_phpunit_testcasenames - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\PHPUnit\TestCaseNamesSniff - */ - public function test_phpunit_testcasenames(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([ - 'local_codechecker' => dirname(__DIR__), - ]); - - // 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); - - // Let's do all the hard work! - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/PHPUnitTestCaseProviderTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/PHPUnitTestCaseProviderTest.php deleted file mode 100644 index 374d7165..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/PHPUnitTestCaseProviderTest.php +++ /dev/null @@ -1,160 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -use MoodleHQ\MoodleCS\moodle\Util\MoodleUtil; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the TestCaseCoversSniff sniff. - * - * @package local_codechecker - * @category test - * @copyright 2022 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\PHPUnit\TestCaseProviderSniff - */ -class PHPUnitTestCaseProviderTest extends MoodleCSBaseTestCase { - - /** - * Data provider for self::test_phpunit_test_providers - */ - public function provider_phpunit_data_providers() { - return [ - 'Correct' => [ - 'fixture' => 'fixtures/phpunit/provider/correct_test.php', - 'errors' => [], - 'warnings' => [], - ], - 'Provider Casing' => [ - 'fixture' => 'fixtures/phpunit/provider/provider_casing_test.php', - 'errors' => [ - 6 => 'Wrong @dataProvider tag: @dataprovider provided, @dataProvider expected', - ], - 'warnings' => [ - ], - ], - 'Provider has Parenthesis' => [ - 'fixture' => 'fixtures/phpunit/provider/provider_parents_test.php', - 'errors' => [ - ], - 'warnings' => [ - 6 => 'Data provider should not end with "()". "provider()" provided.', - ], - ], - 'Provider Visibility' => [ - 'fixture' => 'fixtures/phpunit/provider/provider_visibility_test.php', - 'errors' => [ - 12 => 'Data provider method "provider" must be public.', - 23 => 'Data provider method "provider_without_visibility" visibility should be specified.', - 34 => 'Data provider method "static_provider_without_visibility" visibility should be specified.', - ], - 'warnings' => [ - 17 => 'Data provider method "provider_without_visibility" will need to be converted to static in future.', - ], - ], - 'Provider Naming conflicts with test names' => [ - 'fixture' => 'fixtures/phpunit/provider/provider_prefix_test.php', - 'errors' => [ - 6 => 'Data provider must not start with "test_". "test_provider" provided.', - ], - 'warnings' => [ - ], - ], - 'Static Providers' => [ - 'fixture' => 'fixtures/phpunit/provider/static_providers_test.php', - 'errors' => [ - ], - 'warnings' => [ - 12 => 'Data provider method "fixable_provider" will need to be converted to static in future.', - 23 => 'Data provider method "unfixable_provider" will need to be converted to static in future.', - 34 => 'Data provider method "partially_fixable_provider" will need to be converted to static in future.', - ], - ], - 'Static Providers Applying fixes' => [ - 'fixture' => 'fixtures/phpunit/provider/static_providers_fix_test.php', - 'errors' => [ - ], - 'warnings' => [ - 13 => 'Data provider method "fixable_provider" will need to be converted to static in future.', - 24 => 'Data provider method "unfixable_provider" will need to be converted to static in future.', - 35 => 'Data provider method "partially_fixable_provider" will need to be converted to static in future.', - ], - ], - 'Provider Return Type checks' => [ - 'fixture' => 'fixtures/phpunit/provider/provider_returntype_test.php', - 'errors' => [ - 6 => 'Data provider method "provider_no_return" must return an array, a Generator or an Iterable.', - 17 => 'Data provider method "provider_wrong_return" must return an array, a Generator or an Iterable.', - 28 => 'Data provider method "provider_returns_generator" must return an array, a Generator or an Iterable.', - 41 => 'Data provider method "provider_returns_iterator" must return an array, a Generator or an Iterable.', - ], - 'warnings' => [ - ], - ], - 'Provider not found' => [ - 'fixture' => 'fixtures/phpunit/provider/provider_not_found_test.php', - 'errors' => [ - 6 => 'Data provider method "provider" not found.', - 14 => 'Wrong @dataProvider tag specified for test test_two, it must be followed by a space and a method name.', - ], - 'warnings' => [ - ], - ], - 'Complex test with multiple classes' => [ - 'fixture' => 'fixtures/phpunit/provider/complex_provider_test.php', - 'errors' => [ - 7 => 'Data provider method "provider" not found.', - ], - 'warnings' => [ - 14 => 'Data provider method "second_provider" will need to be converted to static in future.', - ], - ], - ]; - } - - /** - * Test the moodle.PHPUnit.TestCaseCovers sniff - * - * @param string $fixture relative path to fixture to use. - * @param array $errors array of errors expected. - * @param array $warnings array of warnings expected. - * @dataProvider provider_phpunit_data_providers - */ - public function test_phpunit_test_providers( - string $fixture, - array $errors, - 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); - - // 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); - - // Let's do all the hard work! - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/NamespaceStatementSniffTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/NamespaceStatementSniffTest.php deleted file mode 100644 index d2a0d98c..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/NamespaceStatementSniffTest.php +++ /dev/null @@ -1,76 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests\Sniffs\Namespaces; - -use MoodleHQ\MoodleCS\moodle\Tests\MoodleCSBaseTestCase; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the NoLeadingSlash sniff. - * - * @package moodle-cs - * @category test - * @copyright 2023 Andrew Lyons - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\Namespaces\NoLeadingSlashSniff - */ -class NamespaceStatementSniffTest extends MoodleCSBaseTestCase -{ - public static function leading_slash_provider(): array - { - return [ - [ - 'fixture' => 'correct_namespace', - 'warnings' => [], - 'errors' => [], - ], - [ - 'fixture' => 'leading_backslash', - 'warnings' => [], - 'errors' => [ - 3 => 'Namespace should not start with a slash: \MoodleHQ\MoodleCS\moodle\Tests\Sniffs\Namespaces', - ], - ], - [ - 'fixture' => 'curly_namespace', - 'warnings' => [], - 'errors' => [ - 3 => 'Namespace should not start with a slash: \MoodleHQ\MoodleCS\moodle\Tests\Sniffs\Namespaces', - ], - ], - ]; - } - /** - * @dataProvider leading_slash_provider - */ - public function test_leading_slash( - string $fixture, - 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->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/fixtures/correct_namespace.php b/vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/fixtures/correct_namespace.php deleted file mode 100644 index 26c49310..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/Sniffs/Namespaces/fixtures/correct_namespace.php +++ /dev/null @@ -1,8 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayBracketSpacingSniff sniff. - * - * @package local_codechecker - * @category test - * @copyright 2022 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays\ArrayBracketSpacingSniff - */ -class SquizArraysArrayBrackerSpacingTest extends MoodleCSBaseTestCase { - - /** - * Test the Squid.Arrays.ArrayBracketSpacing sniff - */ - public function test_squiz_arrays_arraybracketspacing() { - - // 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'); - - // 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([ - 4 => "expected \"\$arr[\" but found \"\$arr [\"", - 5 => ["expected \"['wrong'\" but found \"[ 'wrong'\"", "expected \"'wrong']\" but found \"'wrong' ]\""], - 17 => 3, - 22 => 2, - 25 => 2, - 28 => 2, - 31 => 2, - 34 => 2, - ]); - $this->set_warnings([]); - - // Let's do all the hard work! - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/SquizOperatorsValidLogicalOperatorsTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/SquizOperatorsValidLogicalOperatorsTest.php deleted file mode 100644 index 82d2c46a..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/SquizOperatorsValidLogicalOperatorsTest.php +++ /dev/null @@ -1,58 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators\ValidLogicalOperatorsSniff sniff. - * - * @package local_codechecker - * @category test - * @copyright 2022 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \PHP_CodeSniffer\Standards\Squiz\Sniffs\Operators\ValidLogicalOperatorsSniff - */ -class SquizOperatorsValidLogicalOperatorsTest extends MoodleCSBaseTestCase { - - /** - * Test the Squid.Arrays.ValidLogicalOperators sniff - */ - public function test_squiz_operators_validlogicaloperators() { - - // 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'); - - // 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([ - 21 => 'Logical operator "or" is prohibited; use "||" instead', - 25 => 'Squiz.Operators.ValidLogicalOperators.NotAllowed', - 29 => 2, - 33 => 4, - ]); - $this->set_warnings([]); - - // Let's do all the hard work! - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/WhiteSpaceSpaceAfterCommaTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/WhiteSpaceSpaceAfterCommaTest.php deleted file mode 100644 index 83fee627..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/WhiteSpaceSpaceAfterCommaTest.php +++ /dev/null @@ -1,51 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the SpaceAfterComma sniff. - * - * @package local_codechecker - * @category test - * @copyright 2021 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\WhiteSpace\SpaceAfterCommaSniff - */ -class WhiteSpaceSpaceAfterCommaTest extends MoodleCSBaseTestCase { - - public function test_whitespace_spaceaftercomma() { - // 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'); - - // 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([ - 5 => 2, - ]); - $this->set_warnings([]); - - // Let's do all the hard work! - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/WhiteSpaceWhiteSpaceInStringsTest.php b/vendor/moodlehq/moodle-cs/moodle/Tests/WhiteSpaceWhiteSpaceInStringsTest.php deleted file mode 100644 index 7c0fb691..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/WhiteSpaceWhiteSpaceInStringsTest.php +++ /dev/null @@ -1,52 +0,0 @@ -. - -namespace MoodleHQ\MoodleCS\moodle\Tests; - -// phpcs:disable moodle.NamingConventions - -/** - * Test the WhiteSpaceInStrings sniff. - * - * @package local_codechecker - * @category test - * @copyright 2021 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * - * @covers \MoodleHQ\MoodleCS\moodle\Sniffs\WhiteSpace\WhiteSpaceInStringsSniff - */ -class WhiteSpaceWhiteSpaceInStringsTest extends MoodleCSBaseTestCase { - - public function test_whitespace_whitespaceinstrings() { - // 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'); - - // 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([ - 5 => '@Message: Whitespace found at end of line within string', - 7 => '@Message: Tab found within whitespace', - ]); - $this->set_warnings([]); - - // Let's do all the hard work! - $this->verify_cs_results(); - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/bootstrap.php b/vendor/moodlehq/moodle-cs/moodle/Tests/bootstrap.php deleted file mode 100644 index 85081c23..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/bootstrap.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ - -if (!defined('PHPUNIT_TEST')) { - define('PHPUNIT_TEST', true); -} - -$ds = DIRECTORY_SEPARATOR; -$root = dirname(dirname(__DIR__)); - -require_once("{$root}/vendor/autoload.php"); -require_once("{$root}/vendor/squizlabs/php_codesniffer/tests/bootstrap.php"); -require_once("{$root}/vendor/phpcompatibility/php-compatibility/PHPCSAliases.php"); diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/blank.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/blank.php deleted file mode 100644 index b5ecb3ff..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/blank.php +++ /dev/null @@ -1,18 +0,0 @@ -. - -class someclass { } diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/gnu_http.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/gnu_http.php deleted file mode 100644 index b8c36577..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/gnu_http.php +++ /dev/null @@ -1,15 +0,0 @@ -. diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/gnu_https.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/gnu_https.php deleted file mode 100644 index 5b044541..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/gnu_https.php +++ /dev/null @@ -1,15 +0,0 @@ -. diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/nophp.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/nophp.php deleted file mode 100644 index 560f6f13..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/nophp.php +++ /dev/null @@ -1,18 +0,0 @@ -//something -. - -class someclass { } diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/ok.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/ok.php deleted file mode 100644 index 925b3cc6..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/ok.php +++ /dev/null @@ -1,17 +0,0 @@ -. - -class someclass { } diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/ok2.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/ok2.php deleted file mode 100644 index 61f4f1b9..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/ok2.php +++ /dev/null @@ -1,17 +0,0 @@ -. - -class someclass { } diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/short.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/short.php deleted file mode 100644 index a4a05709..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/boilerplatecomment/short.php +++ /dev/null @@ -1,14 +0,0 @@ -. - -class someclass { } diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/class_alias.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/class_alias.php deleted file mode 100644 index bad7be35..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/class_alias.php +++ /dev/null @@ -1,26 +0,0 @@ -. - -/** - * File containing a class alias and nothing else. - * - * @package mod_example - * @copyright 2022 Andrew Lyons - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -class_alias(\mod_example\some\class_name::class, 'mod_example_some_legacy_class_name'); -class_alias(\mod_example\some\other_class::class, 'mod_example_some_legacy_other_class'); diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/class_alias_defined.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/class_alias_defined.php deleted file mode 100644 index d8cb1a6b..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/class_alias_defined.php +++ /dev/null @@ -1,28 +0,0 @@ -. - -defined('MOODLE_INTERNAL') || die(); - -/** - * File containing a class alias and nothing else. - * - * @package mod_example - * @copyright 2022 Andrew Lyons - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -class_alias(\mod_example\some\class_name::class, 'mod_example_some_legacy_class_name'); -class_alias(\mod_example\some\other_class::class, 'mod_example_some_legacy_other_class'); diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/class_alias_extra.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/class_alias_extra.php deleted file mode 100644 index 1e9ac12d..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/class_alias_extra.php +++ /dev/null @@ -1,28 +0,0 @@ -. - -/** - * File containing a class alias and nothing else. - * - * @package mod_example - * @copyright 2022 Andrew Lyons - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -class_alias(\mod_example\some\class_name::class, 'mod_example_some_legacy_class_name'); -class_alias(\mod_example\some\other_class::class, 'mod_example_some_legacy_other_class'); - -var_dump(class_exists('mod_example_some_legacy_class_name')); diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/declare_ok.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/declare_ok.php deleted file mode 100644 index c9df22ca..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/declare_ok.php +++ /dev/null @@ -1,32 +0,0 @@ -. - -/** - * Chart line. - * - * @package core - * @copyright 2016 Frédéric Massart - FMCorz.net - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -declare(strict_types=1); - -declare(ticks=1); - -namespace core; -use this\is\that; - -class something { } diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/lang/en/repository_dropbox.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/lang/en/repository_dropbox.php deleted file mode 100644 index 8b2ad400..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/lang/en/repository_dropbox.php +++ /dev/null @@ -1,25 +0,0 @@ -. - -/** - * Strings for component 'repository_dropbox', language 'en', branch 'MOODLE_20_STABLE' - * - * @package repository_dropbox - * @copyright 2010 Dongsheng Cai - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$string['pluginname'] = 'Dropbox'; diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/lib/behat/behat_mod_workshop.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/lib/behat/behat_mod_workshop.php deleted file mode 100644 index 09bf2a75..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/lib/behat/behat_mod_workshop.php +++ /dev/null @@ -1,40 +0,0 @@ -. - -/** - * Steps definitions related to mod_workshop. - * - * @package mod_workshop - * @category test - * @copyright 2014 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. - -require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); - -use Behat\Gherkin\Node\TableNode as TableNode; - -/** - * Steps definitions related to mod_workshop. - * - * @package mod_workshop - * @category test - * @copyright 2014 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class behat_mod_workshop extends behat_base {} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/namespace_ok.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/namespace_ok.php deleted file mode 100644 index e828cefd..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/namespace_ok.php +++ /dev/null @@ -1,37 +0,0 @@ -. - -/** - * Chart line. - * - * @package core - * @copyright 2016 Frédéric Massart - FMCorz.net - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace core; -defined('MOODLE_INTERNAL') || die(); - -require_once('something.php'); - -/** - * Chart line class. - * - * @package core - * @copyright 2016 Frédéric Massart - FMCorz.net - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class chart_line { } diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/namespace_with_use_ok.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/namespace_with_use_ok.php deleted file mode 100644 index 901a858e..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/namespace_with_use_ok.php +++ /dev/null @@ -1,38 +0,0 @@ -. - -/** - * Subplugin info class. - * - * @package mod_workshop - * @copyright 2013 Petr Skoda {@link http://skodak.org} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -namespace mod_workshop\plugininfo; - -use core\plugininfo\base; -use core\plugininfo\this, - core\plugininfo\that; -use core\plugininfo\one, core\plugininfo\two,core\plugininfo\three; - -class workshopallocation extends base { - public function is_uninstall_allowed() { - if ($this->is_standard()) { - return false; - } - return true; - } -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/no_moodle_cookie_ok.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/no_moodle_cookie_ok.php deleted file mode 100644 index 1fb4dbb1..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/no_moodle_cookie_ok.php +++ /dev/null @@ -1,40 +0,0 @@ -. - -/** - * Displays help via AJAX call - * - * @copyright 2013 onwards Andrew Nicols - * @package core - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -define('NO_MOODLE_COOKIES', true); -define('AJAX_SCRIPT', true); -require_once(__DIR__ . '/config.php'); - -$identifier = required_param('identifier', PARAM_STRINGID); -$component = required_param('component', PARAM_COMPONENT); -$lang = optional_param('lang', 'en', PARAM_LANG); - -// We don't actually modify the session here as we have NO_MOODLE_COOKIES set. -$SESSION->lang = $lang; -$PAGE->set_url('/help_ajax.php'); -$PAGE->set_context(context_system::instance()); - -$data = get_formatted_help_string($identifier, $component, true); -echo json_encode($data); diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/no_relevant_ok.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/no_relevant_ok.php deleted file mode 100644 index 1effd6ce..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/no_relevant_ok.php +++ /dev/null @@ -1,32 +0,0 @@ -. - -/** - * A file that only contains non-relevant (and no side effects) code. - */ - -declare(strict_types=1); -declare(encoding='UTF-8'); -declare(ticks=1); - -namespace local_codechecker;; - -use something; -use various, things; -use something as elsething; - -define('ONE', 1); -define('TWO', 2); diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/nowarning.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/nowarning.php deleted file mode 100644 index aa8c556d..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/nowarning.php +++ /dev/null @@ -1,32 +0,0 @@ -. - -/** - * Chart line. - * - * @package core - * @copyright 2016 Frédéric Massart - FMCorz.net - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -/** - * Chart line class. - * - * @package core - * @copyright 2016 Frédéric Massart - FMCorz.net - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -interface chart { } diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/old_style_if_die_ok.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/old_style_if_die_ok.php deleted file mode 100644 index d9986128..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/old_style_if_die_ok.php +++ /dev/null @@ -1,33 +0,0 @@ -. - -/** - * Testing fixure for old-skool if die MOODLE_INTERNAL check. - * - * @package core - * @copyright 2016 Dan Poltawski - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -if (!defined('MOODLE_INTERNAL')) { - die('Direct access to this script is forbidden.'); -} - -require_once($CFG->libdir.'/formslib.php'); - -/** - * A form for a user to request a course. - */ -class course_request_form extends moodleform {} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/problem.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/problem.php deleted file mode 100644 index b0e5ea84..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/problem.php +++ /dev/null @@ -1,21 +0,0 @@ -. - -// This next line will be a problem, because its code before inclusion/MOODLE_INTERNAL -$problem = required_param('isproblem', PARAM_BOOL); - -echo $problem; diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/tests/behat/behat_mod_workshop.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/tests/behat/behat_mod_workshop.php deleted file mode 100644 index 09bf2a75..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/tests/behat/behat_mod_workshop.php +++ /dev/null @@ -1,40 +0,0 @@ -. - -/** - * Steps definitions related to mod_workshop. - * - * @package mod_workshop - * @category test - * @copyright 2014 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. - -require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); - -use Behat\Gherkin\Node\TableNode as TableNode; - -/** - * Steps definitions related to mod_workshop. - * - * @package mod_workshop - * @category test - * @copyright 2014 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class behat_mod_workshop extends behat_base {} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/unexpected.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/unexpected.php deleted file mode 100644 index 697dce0e..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/unexpected.php +++ /dev/null @@ -1,26 +0,0 @@ -. - -defined('MOODLE_INTERNAL') || die(); - -/** - * Chart line class. - * - * @package core - * @copyright 2016 Frédéric Massart - FMCorz.net - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -interface chart { } diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/warning.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/warning.php deleted file mode 100644 index 132a7b56..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/files/moodleinternal/warning.php +++ /dev/null @@ -1,34 +0,0 @@ -. - -/** - * Chart line. - * - * @package core - * @copyright 2016 Frédéric Massart - FMCorz.net - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -/** - * Chart line class. - * - * @package core - * @copyright 2016 Frédéric Massart - FMCorz.net - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class chart_line { } - -trait chart_pie { } diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/generic_array_longarraysyntax.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/generic_array_longarraysyntax.php deleted file mode 100644 index 1c1693df..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/generic_array_longarraysyntax.php +++ /dev/null @@ -1,14 +0,0 @@ - -
-

- some page content -

-
- - -Let's try with a number of one-liners, any indentation accepted, reset on open/close allows it - - - - - - -

and, with some html in the middle, in a new php block

- -// Adding some known content that caused problems. See CONTRIB-6146. -// Source: https://github.com/roelmann/moodle-theme_flexibase/blob/d99ca95f0b77c4cd2f877cf8b1d0715acb392cf4/layout/secure.php -theme->settings->frontpagelayout)) { - $layoutoption = $PAGE->theme->settings->frontpagelayout; -} else { - $layoutoption = 'preandpost'; -} - -$hasmarketing = (empty($PAGE->theme->settings->togglemarketing)) ? false : $PAGE->theme->settings->togglemarketing; - -require('includes/preheaderlogic.php'); -require('includes/header.php'); -?> - -
- - - - -
-// Adding some known content that caused problems. See CONTRIB-6146. -// Source: https://github.com/gjb2048/moodle-theme_essential/blob/a85a228057a3e8e62b2966e4bfe09177a40a361e/layout/report.php - - -
- -
- -
-
-
-
-id > 1) && (essential_report_page_has_title() == true)) { - echo $OUTPUT->heading(format_string($COURSE->fullname), 1, 'coursetitle'); - echo '
'; -} -echo $OUTPUT->course_content_header(); -echo $OUTPUT->main_content(); -if (empty($PAGE->layout_options['nocoursefooter'])) { - echo $OUTPUT->course_content_footer(); -} -?> -
-
-essential_blocks('side-pre', 'row-fluid', 'aside', 4); -?> -
-
- -
-
- - - - - - $id, - )); - - $framework = api::read_framework($params['id']); -} - -if ($showcompleted) { - $feedbackcompleted = $DB->get_record('feedback_completed', - array('feedback' => $feedback->id, 'id' => $showcompleted, - 'anonymous_response' => FEEDBACK_ANONYMOUS_YES), '*', MUST_EXIST); - $responsetitle = get_string('response_nr', 'feedback') . ': ' . - $feedbackcompleted->random_response . ' (' . get_string('anonymous', 'feedback') . ')'; -} - -// End of function/array fixtures (CONTRIB-6206). diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/integration_test_ci.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/integration_test_ci.php deleted file mode 100644 index fdd4434d..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/integration_test_ci.php +++ /dev/null @@ -1,4 +0,0 @@ -some_class(); - -foreach ($somearray as $variable) { - /** @var some_class $variable */ - $variable->do_something(); -} - -// Don't accept type hinting if it does not match the begin of next line. -/** @var some_class $variable */ -lets_execute_it($variable->do_something()); - -/** @var some_class $variable */ -$variables = $giveme->some_class(); - -// And also, CONTRIB-6105, consider assignments via list() like a viable use. -/** @var cm_info $cm */ -list($course, $cm) = get_course_and_cm_from_cmid($cmid); - -// But not this (non matching within the list(). -/** @var cm_info $cm */ -list($course, $something) = $cm->whatever($cmid); - -// And also, CONTRIB-7165, consider assignments via foreach() like a viable use. -/** @var cm_info $cm */ -foreach ($cms as $cm) { - echo 'This is a test'; -} - -// But not this (non matching within the foreach(). -/** @var cm_info $cm */ -foreach ($cms as $something) { - echo 'This is a test'; -} - -// Allow phpdoc before "return new class extends" expressions. -/** This is a phpdoc block */ -return new class extends xxxx {} - -// But don't allow it before other expressions. -/** This is a phpdoc block */ -return new stdClass(); -/** This is a phpdoc block */ -return new class {} -/** This is a phpdoc block */ -return class extends xxxx {} -/** This is a phpdoc block */ -new class testphpdoc {} -/** This is a phpdoc block */ -return new class implements something {} - -// Allow @codeCoverageIgnore inline comments. -$something = 1; // @codeCoverageIgnore -$something = 1;// @codeCoverageIgnoreStart -$something = 1; // @codeCoverageIgnoreEnd -$something = 1; // @codeCoverageIgnoreAnythingInvented - -function blah() { -} // End of code block comments. - -function dah() { - // A tab in the comment is not nice. - // Neither 2 spaces in the comment are. - $something = 1; - // - - // Blank comments, like previous one, are ugly too. diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_controlstructures_controlsignature.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_controlstructures_controlsignature.php deleted file mode 100644 index a9b500dc..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_controlstructures_controlsignature.php +++ /dev/null @@ -1,8 +0,0 @@ -. - -/** - * Fixture for require login sniff - * - * @package local_codechecker - * @copyright 2016 Dan Poltawski - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -require_once(__DIR__ . '/../../../config.php'); - -$id = required_param('id', PARAM_INT); - -admin_externalpage_setup('testpage'); - -echo "Do something with $id"; diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/cliscript_ok.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/cliscript_ok.php deleted file mode 100644 index 982b2fd9..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/cliscript_ok.php +++ /dev/null @@ -1,28 +0,0 @@ -. - -/** - * Fixture for require login sniff - * - * @package local_codechecker - * @copyright 2016 Dan Poltawski - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -define('CLI_SCRIPT', true); -require_once(__DIR__ . '/../../../config.php'); - -echo "Do something with on cli."; diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/nomoodlecookies_ok.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/nomoodlecookies_ok.php deleted file mode 100644 index af3672b8..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/nomoodlecookies_ok.php +++ /dev/null @@ -1,30 +0,0 @@ -. - -/** - * Fixture for require login sniff - * - * @package local_codechecker - * @copyright 2016 Dan Poltawski - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -define('NO_MOODLE_COOKIES', true); -require_once(__DIR__ . '/../../../config.php'); - -$id = required_param('id', PARAM_INT); - -echo "Do something with $id"; diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/problem.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/problem.php deleted file mode 100644 index 82846d30..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/problem.php +++ /dev/null @@ -1,29 +0,0 @@ -. - -/** - * Fixture for require login sniff - * - * @package local_codechecker - * @copyright 2016 Dan Poltawski - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -require_once(__DIR__ . '/../../../config.php'); - -$id = required_param('id', PARAM_INT); - -echo "Do something with $id"; diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/require_course_login_ok.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/require_course_login_ok.php deleted file mode 100644 index c47b59ac..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/require_course_login_ok.php +++ /dev/null @@ -1,32 +0,0 @@ -. - -/** - * Fixture for require login sniff - * - * @package local_codechecker - * @copyright 2016 Dan Poltawski - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -require_once(__DIR__ . '/../../../config.php'); - -$id = required_param('id', PARAM_INT); -$course = get_course($id); - -require_course_login($course); - -echo "Do something with $course->name"; diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/require_login_ok.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/require_login_ok.php deleted file mode 100644 index 27900eb5..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_files_requirelogin/require_login_ok.php +++ /dev/null @@ -1,30 +0,0 @@ -. - -/** - * Fixture for require login sniff - * - * @package local_codechecker - * @copyright 2016 Dan Poltawski - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -require_once(__DIR__ . '/../../../config.php'); - -require_login(null, false); -$id = required_param('id', PARAM_INT); - -echo "Do something with $id"; diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_namingconventions_variablename.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_namingconventions_variablename.php deleted file mode 100644 index debb3331..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_namingconventions_variablename.php +++ /dev/null @@ -1,23 +0,0 @@ -single_button($PAGE->url, 'Click me'); -} - -class test_renderer extends plugin_renderer_base { - public function ok() { - return $this->output->single_button($this->page->url, 'Click me'); - } - - public function bad1() { - global $OUTPUT; - return $OUTPUT->single_button($this->page->url, 'Click me'); - } - - public function bad2() { - global $PAGE; - return $this->output->single_button($PAGE->url, 'Click me'); - } - - public function bad3() { - global $OUTPUT, $PAGE; - return $OUTPUT->single_button($PAGE->url, 'Click me'); - } - - public function bad4() { - global $PAGE; - return "You are on $PAGE->url."; - } -} - -class test_renderer_htmlemail extends plugin_renderer_base { - public function bad() { - global $OUTPUT; - return $OUTPUT->single_button($this->page->url, 'Click me'); - } -} - -class other_class { - public function no_worries() { - global $OUTPUT, $PAGE; - return $OUTPUT->single_button($PAGE->url, 'Click me'); - } -} - -class block_html extends block_base { - public function ok() { - return $this->page->url; - } - - public function bad() { - global $PAGE; - return $PAGE->url; - } -} - -class block_another extends block_base { - public $something; -} diff --git a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_php_forbiddenfunctions.php b/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_php_forbiddenfunctions.php deleted file mode 100644 index 9a643adc..00000000 --- a/vendor/moodlehq/moodle-cs/moodle/Tests/fixtures/moodle_php_forbiddenfunctions.php +++ /dev/null @@ -1,20 +0,0 @@ -pix_url('