assert_false( preg_match('/\?\>\s*$/', file_get_contents($file)), "{$file->getPathname()} ends in ?>"); } } public function view_files_end_in_html_dot_php_test() { $dir = new GalleryCodeFilterIterator( new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT))); foreach ($dir as $file) { if ($file->getFilename() == 'kohana_unit_test.php') { // Exception: this file must be named accordingly for the test framework continue; } $this->assert_false( preg_match("|/views/.*?(?getPathname()), "{$file->getPathname()} should end in .html.php"); } } } class GalleryCodeFilterIterator extends FilterIterator { public function accept() { // Skip anything that we didn't write $path_name = $this->getInnerIterator()->getPathName(); return !(strstr($path_name, ".svn") || substr($path_name, -1, 1) == "~" || strstr($path_name, SYSPATH) !== false || strstr($path_name, MODPATH . 'forge') !== false || strstr($path_name, MODPATH . 'unit_test') !== false || strstr($path_name, MODPATH . 'mptt') !== false || strstr($path_name, DOCROOT . 'var') !== false || strstr($path_name, DOCROOT . 'test') !== false); } }