diff options
| author | Andreas Fischer <bantu@phpbb.com> | 2012-12-05 01:20:01 +0100 | 
|---|---|---|
| committer | Andreas Fischer <bantu@phpbb.com> | 2012-12-05 01:20:01 +0100 | 
| commit | d9f554fe0349b3b476813c393c93e6da650e10c2 (patch) | |
| tree | 2b532ee51c31e0bf44ed55fa5515c2c151174a0e | |
| parent | 2fdd039e5223b7acea3795811326945bd649bf49 (diff) | |
| parent | 58a7050fac0f9a2b3f9deea717c01cba98fdb38f (diff) | |
| download | forums-d9f554fe0349b3b476813c393c93e6da650e10c2.tar forums-d9f554fe0349b3b476813c393c93e6da650e10c2.tar.gz forums-d9f554fe0349b3b476813c393c93e6da650e10c2.tar.bz2 forums-d9f554fe0349b3b476813c393c93e6da650e10c2.tar.xz forums-d9f554fe0349b3b476813c393c93e6da650e10c2.zip  | |
Merge branch 'develop-olympus' into develop
* develop-olympus:
  [ticket/10716] Collect standard error from executed php process.
  [ticket/10716] Skip test if php is not in PATH.
  [ticket/10716] Exclude our dependencies from linting.
  [ticket/10716] Only lint on php 5.3+.
  [ticket/10716] php parse all php files as part of the test suite.
| -rw-r--r-- | tests/lint_test.php | 74 | 
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/lint_test.php b/tests/lint_test.php new file mode 100644 index 0000000000..905067072d --- /dev/null +++ b/tests/lint_test.php @@ -0,0 +1,74 @@ +<?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 +{ +	static protected $exclude; + +	static public function setUpBeforeClass() +	{ +		$output = array(); +		$status = 1; +		exec('(php -v) 2>&1', $output, $status); +		if ($status) +		{ +			$output = implode("\n", $output); +			self::markTestSkipped("php is not in PATH or broken: $output"); +		} + +		self::$exclude = array( +			// PHP Fatal error:  Cannot declare class Container because the name is already in use in /var/www/projects/phpbb3/tests/../phpBB/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php on line 20 +			// https://gist.github.com/e003913ffd493da63cbc +			dirname(__FILE__) . '/../phpBB/vendor', +		); +	} + +	public function test_lint() +	{ +		if (version_compare(PHP_VERSION, '5.3.0', '<')) +		{ +			$this->markTestSkipped('phpBB uses PHP 5.3 syntax in some files, linting on PHP < 5.3 will fail'); +		} + +		$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) && !in_array($path, self::$exclude)) +			{ +				$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) . ') 2>&1'; +				$output = array(); +				$status = 1; +				exec($cmd, $output, $status); +				$output = implode("\n", $output); +				$this->assertEquals(0, $status, "php -l failed for $path:\n$output"); +			} +		} +	} +}  | 
