From cc926cb9e165399971356e0a63587fbf611da47c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 23 Jan 2013 18:58:37 -0500 Subject: 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. --- modules/gallery/tests/File_Structure_Test.php | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'modules') 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"); + } + } + } + } + } + } } -- cgit v1.2.3