aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lint_test.php
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2012-12-04 03:34:51 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2012-12-04 03:34:51 -0500
commitaf2887f3a7f27b33c2ecd14d4baab846b71ddb62 (patch)
treea2c5ea01ad984e2e9f86e19aedc78d3fb9583ee0 /tests/lint_test.php
parente64c5117b9748208a87df80aff6012f3aae573ad (diff)
downloadforums-af2887f3a7f27b33c2ecd14d4baab846b71ddb62.tar
forums-af2887f3a7f27b33c2ecd14d4baab846b71ddb62.tar.gz
forums-af2887f3a7f27b33c2ecd14d4baab846b71ddb62.tar.bz2
forums-af2887f3a7f27b33c2ecd14d4baab846b71ddb62.tar.xz
forums-af2887f3a7f27b33c2ecd14d4baab846b71ddb62.zip
[ticket/10716] php parse all php files as part of the test suite.
PHPBB3-10716
Diffstat (limited to 'tests/lint_test.php')
-rw-r--r--tests/lint_test.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/lint_test.php b/tests/lint_test.php
new file mode 100644
index 0000000000..57c78ae809
--- /dev/null
+++ b/tests/lint_test.php
@@ -0,0 +1,49 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_lint_test extends phpbb_test_case
+{
+ public function test_lint()
+ {
+ $root = dirname(__FILE__) . '/..';
+ $this->check($root);
+ }
+
+ protected function check($root)
+ {
+ $dh = opendir($root);
+ while (($filename = readdir($dh)) !== false)
+ {
+ if ($filename == '.' || $filename == '..' || $filename == 'git')
+ {
+ continue;
+ }
+ $path = $root . '/' . $filename;
+ // skip symlinks to avoid infinite loops
+ if (is_link($path))
+ {
+ continue;
+ }
+ if (is_dir($path))
+ {
+ $this->check($path);
+ }
+ else if (substr($filename, strlen($filename)-4) == '.php')
+ {
+ // assume php binary is called php and it is in PATH
+ $cmd = 'php -l ' . escapeshellarg($path);
+ $output = array();
+ $status = 1;
+ exec($cmd, $output, $status);
+ $output = implode("\n", $output);
+ $this->assertEquals(0, $status, "php -l failed for $path:\n$output");
+ }
+ }
+ }
+}