From 031dd3bd6f279b5ddec6f08ff11e0acee521a5fe Mon Sep 17 00:00:00 2001 From: shadlaws Date: Thu, 24 Jan 2013 12:03:05 +0100 Subject: #1960 - Add unit test to look for extra spaces at end of line - Added no_extra_spaces_at_end_of_line_test to File_Structure_Test. - Updated Gallery_Filters to exclude testing code that isn't ours. - Removed existing extra spaces. New test now passes. --- modules/gallery/tests/File_Structure_Test.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'modules/gallery/tests/File_Structure_Test.php') diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php index 7ad865e0..ce75ea13 100644 --- a/modules/gallery/tests/File_Structure_Test.php +++ b/modules/gallery/tests/File_Structure_Test.php @@ -285,7 +285,7 @@ class File_Structure_Test extends Gallery_Unit_Test_Case { } public function all_public_functions_in_test_files_end_in_test() { - // Who tests the tests? :-) + // Who tests the tests? :-) (ref: http://www.xkcd.com/1163) $dir = new PhpCodeFilterIterator( new GalleryCodeFilterIterator( new RecursiveIteratorIterator( @@ -315,4 +315,20 @@ class File_Structure_Test extends Gallery_Unit_Test_Case { } } } + + public function no_extra_spaces_at_end_of_line_test() { + $dir = new GalleryCodeFilterIterator( + new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT))); + $errors = ""; + foreach ($dir as $file) { + if (preg_match("/\.(php|css|html|js)$/", $file)) { + foreach (file($file) as $line_num => $line) { + if ((substr($line, -2) == " \n") || (substr($line, -1) == " ")) { + $errors .= "$file at line " . ($line_num + 1) . "\n"; + } + } + } + } + $this->assert_true(empty($errors), "Extra spaces at end of line found at:\n$errors"); + } } -- cgit v1.2.3