From 38e1eef5474dbe1768938fdd3882cf0627d7e70e Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Wed, 26 Nov 2008 20:21:39 +0000 Subject: Some code audit fixes and adding some directory separator normalization code to make it work on Windows as well. --- core/tests/File_Structure_Test.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'core/tests/File_Structure_Test.php') diff --git a/core/tests/File_Structure_Test.php b/core/tests/File_Structure_Test.php index 0ffa0f9f..861a764c 100644 --- a/core/tests/File_Structure_Test.php +++ b/core/tests/File_Structure_Test.php @@ -41,7 +41,8 @@ class File_Structure_Test extends Unit_Test_Case { } if (strpos($file, "views")) { $this->assert_true( - preg_match("#/views/.*?(\.html|mrss)\.php$#", $file->getPathname()), + preg_match("#/views/.*?(\.html|mrss)\.php$#", + strtr($file->getPathname(), DIRECTORY_SEPARATOR, '/')), "{$file->getPathname()} should end in .html.php or mrss.php"); } } @@ -65,7 +66,7 @@ class File_Structure_Test extends Unit_Test_Case { $expected = $this->_get_preamble(__FILE__); foreach ($dir as $file) { - if (preg_match("/views/", $file->getPathname())) { + if (preg_match("/views/", strtr($file->getPathname(), DIRECTORY_SEPARATOR, '/'))) { // The preamble for views is a single line that prevents direct script access $lines = file($file->getPathname()); $this->assert_equal( @@ -74,7 +75,7 @@ class File_Structure_Test extends Unit_Test_Case { "in file: {$file->getPathname()}"); } else if (preg_match("|\.php$|", $file->getPathname())) { $actual = $this->_get_preamble($file->getPathname()); - if ($file->getPathName() == DOCROOT . "index.php") { + if (strtr($file->getPathName(), DIRECTORY_SEPARATOR, '/') == DOCROOT . "index.php") { // index.php allows direct access, so modify our expectations for the first line $index_expected = $expected; $index_expected[0] = "getInnerIterator()->getPathName(); + $path_name = strtr($path_name, DIRECTORY_SEPARATOR, '/'); return !(strpos($path_name, ".svn") || substr($path_name, -1, 1) == "~" || strpos($path_name, SYSPATH) !== false || -- cgit v1.2.3