mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-08-14 19:05:01 -04:00
#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.
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user