From 539cb8df8d0ec28a6e5bd5e40e1a6321420a64e8 Mon Sep 17 00:00:00 2001 From: mattab Date: Fri, 21 Feb 2014 14:33:23 +1300 Subject: Add unit test check PHP files start with prevent human error when IDE does not show white spaces --- tests/PHPUnit/Core/ReleaseCheckListTest.php | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'tests') diff --git a/tests/PHPUnit/Core/ReleaseCheckListTest.php b/tests/PHPUnit/Core/ReleaseCheckListTest.php index 9f756a0a6c..3b722c8e59 100644 --- a/tests/PHPUnit/Core/ReleaseCheckListTest.php +++ b/tests/PHPUnit/Core/ReleaseCheckListTest.php @@ -164,6 +164,35 @@ class ReleaseCheckListTest extends PHPUnit_Framework_TestCase } + /** + * This tests that all PHP files start with isSkipPhpFileStartWithPhpBlock($file, $isIniFile); + + if($skipStartFileTest) { + continue; + } + + $start = fgets($handle, strlen($expectedStart) + 1 ); + $this->assertEquals($start, $expectedStart, "File $file does not start with $expectedStart"); + } + } + /** * Check that directories in plugins/ folder are specifically either enabled or disabled. * @@ -304,5 +333,22 @@ class ReleaseCheckListTest extends PHPUnit_Framework_TestCase } } + /** + * @param $file + * @param $isIniFile + * @return bool + */ + protected function isSkipPhpFileStartWithPhpBlock($file, $isIniFile) + { + $isIniFileInTests = strpos($file, "/tests/") !== false; + $isTestResultFile = strpos($file, "/Integration/expected") !== false + || strpos($file, "/Integration/processed") !== false + || strpos($file, "tests/resources/Updater/") !== false + || strpos($file, "Twig/Tests/") !== false; + $isLib = strpos($file, "lib/xhprof") !== false; + + return ($isIniFile && $isIniFileInTests) || $isTestResultFile || $isLib; + } + } -- cgit v1.2.3