diff options
author | Bharat Mediratta <bharat@menalto.com> | 2013-01-23 18:58:37 -0500 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2013-01-23 18:58:37 -0500 |
commit | cc926cb9e165399971356e0a63587fbf611da47c (patch) | |
tree | fb6eaafe5d02ae52d7e4f2e4a8a4d041487ef196 /modules/gallery/tests | |
parent | bc5dbd812a349ac1d4cb0c517b36c05b60c8cb26 (diff) |
After finding a test in Item_Model_Test that didn't end in the string "_test" and
fixing it in 9ba9f3953132c5c5de9efb0a4724c7b9300dc9ea I decided to write a test to make
sure that we don't have any other overlooked tests. We don't.
Diffstat (limited to 'modules/gallery/tests')
-rw-r--r-- | modules/gallery/tests/File_Structure_Test.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php index 8f6e480c..7ad865e0 100644 --- a/modules/gallery/tests/File_Structure_Test.php +++ b/modules/gallery/tests/File_Structure_Test.php @@ -283,4 +283,36 @@ class File_Structure_Test extends Gallery_Unit_Test_Case { $this->assert_true(false, $errors); } } + + public function all_public_functions_in_test_files_end_in_test() { + // Who tests the tests? :-) + $dir = new PhpCodeFilterIterator( + new GalleryCodeFilterIterator( + new RecursiveIteratorIterator( + new RecursiveDirectoryIterator(DOCROOT)))); + foreach ($dir as $file) { + $scan = 0; + if (basename(dirname($file)) == "tests") { + foreach (file($file) as $line) { + if (!substr($file, -9, 9) == "_Test.php") { + continue; + } + + if (preg_match("/class.*extends.*Gallery_Unit_Test_Case/", $line)) { + $scan = 1; + } else if (preg_match("/class.*extends/", $line)) { + $scan = 0; + } + + if ($scan) { + if (preg_match("/^\s*public\s+function/", $line)) { + $this->assert_true( + preg_match("/^\s*public\s+function (setup|teardown|.*_test)\(\) {/", $line), + "public functions must end in _test:\n$file\n$line\n"); + } + } + } + } + } + } } |