diff options
author | shadlaws <shad@shadlaws.com> | 2013-01-24 12:03:05 +0100 |
---|---|---|
committer | shadlaws <shad@shadlaws.com> | 2013-01-24 12:03:05 +0100 |
commit | 031dd3bd6f279b5ddec6f08ff11e0acee521a5fe (patch) | |
tree | 6e8988e28d0eff76214834d644c8438db5a11cba /modules/gallery/tests | |
parent | 3e451d6edc6ab3586ef730e4458ca0b2d55f5170 (diff) |
#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.
Diffstat (limited to 'modules/gallery/tests')
-rw-r--r-- | modules/gallery/tests/File_Structure_Test.php | 18 | ||||
-rw-r--r-- | modules/gallery/tests/Gallery_Filters.php | 4 |
2 files changed, 21 insertions, 1 deletions
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"); + } } diff --git a/modules/gallery/tests/Gallery_Filters.php b/modules/gallery/tests/Gallery_Filters.php index 83dbd53f..6c2a6aa3 100644 --- a/modules/gallery/tests/Gallery_Filters.php +++ b/modules/gallery/tests/Gallery_Filters.php @@ -47,6 +47,10 @@ class GalleryCodeFilterIterator extends FilterIterator { strpos($path_name, SYSPATH) !== false || strpos($path_name, MODPATH . "gallery/libraries/HTMLPurifier") !== false || strpos($path_name, MODPATH . "gallery/vendor/joomla") !== false || + strpos($path_name, MODPATH . "organize/vendor/ext") !== false || + strpos($path_name, DOCROOT . "lib") !== false || + strpos($path_name, DOCROOT . "themes/admin_wind/css/themeroller") !== false || + strpos($path_name, DOCROOT . "themes/wind/css/themeroller") !== false || substr($path_name, -1, 1) == "~"); } } |