@@ -480,6 +480,55 @@ protected function cleanMoodleUtilCaches() {
480480 $ apiCache ->setValue (null , []);
481481 }
482482
483+ /**
484+ * Data provider for testIsLangFile.
485+ *
486+ * @return array
487+ */
488+ public static function isLangFileProvider (): array
489+ {
490+ return [
491+ 'Not in lang directory ' => [
492+ 'value ' => '/path/to/standard/file.php ' ,
493+ 'return ' => false ,
494+ ],
495+ 'In lang/en directory ' => [
496+ 'value ' => '/path/to/standard/lang/en/file.php ' ,
497+ 'return ' => true ,
498+ ],
499+ 'In lang directory but missing en ' => [
500+ 'value ' => '/path/to/standard/lang/file.php ' ,
501+ 'return ' => false ,
502+ ],
503+ 'In lang/en directory but missing .php ' => [
504+ 'value ' => '/path/to/standard/lang/en/file ' ,
505+ 'return ' => false ,
506+ ],
507+ 'In lang/en directory but another extension ' => [
508+ 'value ' => '/path/to/standard/lang/en/file.md ' ,
509+ 'return ' => false ,
510+ ],
511+ 'In lang sub-directory with not allowed chars ' => [
512+ 'value ' => '/path/to/standard/lang/@@@/file.php ' ,
513+ 'return ' => false ,
514+ ],
515+ ];
516+ }
517+
518+ /**
519+ * @dataProvider isLangFileProvider
520+ */
521+ public function testIsLangFile (
522+ string $ filepath ,
523+ bool $ expected
524+ ): void {
525+ $ phpcsConfig = new Config ();
526+ $ phpcsRuleset = new Ruleset ($ phpcsConfig );
527+ $ file = new File ($ filepath , $ phpcsRuleset , $ phpcsConfig );
528+
529+ $ this ->assertEquals ($ expected , MoodleUtil::isLangFile ($ file ));
530+ }
531+
483532 /**
484533 * Data provider for testIsUnitTest.
485534 *
0 commit comments