summaryrefslogtreecommitdiff
path: root/_test/tests/general/general_languagelint.test.php
diff options
context:
space:
mode:
authorGuy Brand <gb@unistra.fr>2015-08-23 15:54:03 +0200
committerGuy Brand <gb@unistra.fr>2015-08-23 15:54:03 +0200
commitd1c5a21205ecdf83c4cbdcd9245556121688e798 (patch)
treef99aacf8e4e2aad00b106d9b905a14c3536ba935 /_test/tests/general/general_languagelint.test.php
parent2beabe635c6b98fcf412ba42d137a5de33543109 (diff)
parent0f0d29909c63f9897c9c003e6d3e3b8381a6f36d (diff)
downloadrpg-d1c5a21205ecdf83c4cbdcd9245556121688e798.tar.gz
rpg-d1c5a21205ecdf83c4cbdcd9245556121688e798.tar.bz2
Merge branch 'master' into stable
Diffstat (limited to '_test/tests/general/general_languagelint.test.php')
-rw-r--r--_test/tests/general/general_languagelint.test.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/_test/tests/general/general_languagelint.test.php b/_test/tests/general/general_languagelint.test.php
new file mode 100644
index 000000000..c11462640
--- /dev/null
+++ b/_test/tests/general/general_languagelint.test.php
@@ -0,0 +1,47 @@
+<?php
+
+class general_languagelint_test extends DokuWikiTest {
+
+
+ function test_core() {
+ $this->checkFiles(glob(DOKU_INC.'inc/lang/*/*.php'));
+ }
+
+ function test_plugins() {
+ $this->checkFiles(glob(DOKU_INC.'lib/plugins/*/lang/*/*.php'));
+ }
+
+ /**
+ * Run checks over the given PHP language files
+ *
+ * @param $files
+ */
+ private function checkFiles($files){
+ foreach($files as $file){
+ // try to load the file
+ include $file;
+ // check it defines an array
+ $this->assertTrue(is_array($lang), $file);
+ unset($lang);
+
+ $this->checkUgly($file);
+ }
+ }
+
+ /**
+ * Checks if the file contains any ugly things like leading whitespace, BOM or trailing
+ * PHP closing mark
+ *
+ * @param $file
+ * @throws Exception
+ */
+ private function checkUgly($file){
+ $content = rtrim(file_get_contents($file));
+ if(substr($content,0,5) != '<?php')
+ throw new Exception("$file does not start with '<?php' - check for BOM");
+
+ if(substr($content,-2) == '?>')
+ throw new Exception("$file ends with '?>' - remove it!");
+ }
+
+}