$line) { if (preg_match('/ORM::factory\\(\"user\"/', $line)) { $errors[] = "$file($l) => $line"; } } } $file_as_string = null; } if ($errors) { $this->assert_false(true, "Direct access to the users table found:\n" . join("\n", $errors)); } } public function no_access_to_groups_table_test() { $dir = new UserModuleFilterIterator( new PhpCodeFilterIterator( new GalleryCodeFilterIterator( new RecursiveIteratorIterator( new RecursiveDirectoryIterator(DOCROOT))))); $errors = array(); foreach ($dir as $file) { $file_as_string = file_get_contents($file); if (preg_match("/ORM::factory\\(\"group\"/", $file_as_string)) { foreach (explode("\n", $file_as_string) as $l => $line) { if (preg_match('/ORM::factory\\(\"group\"/', $line)) { $errors[] = "$file($l) => $line"; } } } $file_as_string = null; } if ($errors) { $this->assert_false(true, "Direct access to the groups table found:\n" . join("\n", $errors)); } } } class UserModuleFilterIterator extends FilterIterator { public function accept() { $path_name = $this->getInnerIterator()->getPathName(); return strpos($path_name, "/modules/user") === false; } }