From 534b8525ce95f9d11875cde7a31c93d9c0557475 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 28 May 2009 01:55:42 -0700 Subject: Rename Core_Installer_Test -> Gallery_Installer_Test to match the change from application -> modules/gallery. --- modules/gallery/tests/Core_Installer_Test.php | 50 ------------------------ modules/gallery/tests/Gallery_Installer_Test.php | 50 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 50 deletions(-) delete mode 100644 modules/gallery/tests/Core_Installer_Test.php create mode 100644 modules/gallery/tests/Gallery_Installer_Test.php (limited to 'modules') diff --git a/modules/gallery/tests/Core_Installer_Test.php b/modules/gallery/tests/Core_Installer_Test.php deleted file mode 100644 index 24d24b38..00000000 --- a/modules/gallery/tests/Core_Installer_Test.php +++ /dev/null @@ -1,50 +0,0 @@ -assert_true(file_exists(VARPATH . "albums")); - $this->assert_true(file_exists(VARPATH . "resizes")); - } - - public function install_registers_gallery_module_test() { - $gallery = ORM::factory("module")->where("name", "gallery")->find(); - $this->assert_equal("gallery", $gallery->name); - - // This is probably too volatile to keep for long - $this->assert_equal(1, $gallery->version); - } - - public function install_creates_root_item_test() { - $max_right = ORM::factory("item") - ->select("MAX(`right`) AS `right`") - ->find()->right; - $root = ORM::factory('item')->find(1); - $this->assert_equal("Gallery", $root->title); - $this->assert_equal(1, $root->left); - $this->assert_equal($max_right, $root->right); - $this->assert_equal(null, $root->parent_id); - $this->assert_equal(1, $root->level); - } -} diff --git a/modules/gallery/tests/Gallery_Installer_Test.php b/modules/gallery/tests/Gallery_Installer_Test.php new file mode 100644 index 00000000..24d24b38 --- /dev/null +++ b/modules/gallery/tests/Gallery_Installer_Test.php @@ -0,0 +1,50 @@ +assert_true(file_exists(VARPATH . "albums")); + $this->assert_true(file_exists(VARPATH . "resizes")); + } + + public function install_registers_gallery_module_test() { + $gallery = ORM::factory("module")->where("name", "gallery")->find(); + $this->assert_equal("gallery", $gallery->name); + + // This is probably too volatile to keep for long + $this->assert_equal(1, $gallery->version); + } + + public function install_creates_root_item_test() { + $max_right = ORM::factory("item") + ->select("MAX(`right`) AS `right`") + ->find()->right; + $root = ORM::factory('item')->find(1); + $this->assert_equal("Gallery", $root->title); + $this->assert_equal(1, $root->left); + $this->assert_equal($max_right, $root->right); + $this->assert_equal(null, $root->parent_id); + $this->assert_equal(1, $root->level); + } +} -- cgit v1.2.3 From c8aa9ed440f698bc725b21b2808af88001aaacee Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 28 May 2009 01:58:41 -0700 Subject: Update tests to reflect cache-buster param on thumbnail urls. --- modules/gallery/tests/Album_Helper_Test.php | 3 ++- modules/gallery/tests/Photo_Helper_Test.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/gallery/tests/Album_Helper_Test.php b/modules/gallery/tests/Album_Helper_Test.php index 80afa8d1..2080ef30 100644 --- a/modules/gallery/tests/Album_Helper_Test.php +++ b/modules/gallery/tests/Album_Helper_Test.php @@ -49,7 +49,8 @@ class Album_Helper_Test extends Unit_Test_Case { $rand = rand(); $root = ORM::factory("item", 1); $album = album::create($root, $rand, $rand, $rand); - $this->assert_equal("http://./var/thumbs/$rand/.album.jpg", $album->thumb_url()); + $this->assert_equal( + "http://./var/thumbs/$rand/.album.jpg?m={$album->updated}", $album->thumb_url()); } public function resize_url_test() { diff --git a/modules/gallery/tests/Photo_Helper_Test.php b/modules/gallery/tests/Photo_Helper_Test.php index 2a6693e1..cc1f20da 100644 --- a/modules/gallery/tests/Photo_Helper_Test.php +++ b/modules/gallery/tests/Photo_Helper_Test.php @@ -69,7 +69,7 @@ class Photo_Helper_Test extends Unit_Test_Case { $rand = rand(); $root = ORM::factory("item", 1); $photo = photo::create($root, MODPATH . "gallery/tests/test.jpg", "$rand.jpg", $rand, $rand); - $this->assert_equal("http://./var/thumbs/{$rand}.jpg", $photo->thumb_url()); + $this->assert_equal("http://./var/thumbs/{$rand}.jpg?m={$photo->updated}", $photo->thumb_url()); } public function resize_url_test() { -- cgit v1.2.3 From 1a095fffe50437dbe7814c52886a58b6309ce8eb Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 28 May 2009 02:19:53 -0700 Subject: Prepend all code files we copy from Gallery2 and put into var with our code preamble for security. Update File_Structure_Test::code_files_start_with_preamble_test to check all the php files in var, too. --- modules/g2_import/helpers/g2_import.php | 12 ++++++++---- modules/gallery/tests/File_Structure_Test.php | 21 +++++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) (limited to 'modules') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 60dd593f..51dc8705 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -79,7 +79,8 @@ class g2_import_Core { array( "require_once('$base_dir/modules/core/classes/GalleryDataCache.class');", "require('$base_dir/modules/core/classes/GalleryEmbed.class');"), - file("$base_dir/embed.php"))); + array_merge(array("\n"), + file("$base_dir/embed.php")))); file_put_contents( "$mod_path/main.php", @@ -90,7 +91,8 @@ class g2_import_Core { array( "include(dirname(__FILE__) . '/bootstrap.inc');", "require_once('$base_dir/init.inc');"), - file("$base_dir/main.php"))); + array_merge(array("\n"), + file("$base_dir/main.php")))); file_put_contents( "$mod_path/bootstrap.inc", @@ -103,7 +105,8 @@ class g2_import_Core { "require_once('$base_dir/modules/core/classes/GalleryDataCache.class');", "define('GALLERY_CONFIG_DIR', '$base_dir');", "\$gallery =& new G2_Gallery();"), - file("$base_dir/bootstrap.inc"))); + array_merge(array("\n"), + file("$base_dir/bootstrap.inc")))); file_put_contents( "$mod_path/Gallery.class", @@ -112,7 +115,8 @@ class g2_import_Core { "function Gallery"), array("class G2_Gallery", "function G2_Gallery"), - file("$base_dir/modules/core/classes/Gallery.class"))); + array_merge(array("\n"), + file("$base_dir/modules/core/classes/Gallery.class")))); } require("$mod_path/embed.php"); diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php index 017b1950..c517bd72 100644 --- a/modules/gallery/tests/File_Structure_Test.php +++ b/modules/gallery/tests/File_Structure_Test.php @@ -91,6 +91,18 @@ class File_Structure_Test extends Unit_Test_Case { $fp = fopen($path, "r"); $actual = array(fgets($fp)); fclose($fp); + } else if (strpos($path, DOCROOT . "var/logs") === 0) { + // var/logs has the kohana one-liner preamble + $expected = array("\n"); + $fp = fopen($path, "r"); + $actual = array(fgets($fp)); + fclose($fp); + } else if (strpos($path, DOCROOT . "var") === 0) { + // Anything else under var has the Gallery one-liner + $expected = array("\n"); + $fp = fopen($path, "r"); + $actual = array(fgets($fp)); + fclose($fp); } else { // Gallery: we care about the entire copyright $actual = $this->_get_preamble($path); @@ -141,14 +153,12 @@ class File_Structure_Test extends Unit_Test_Case { // Front controllers break; - case DOCROOT . "index.local.php": + case DOCROOT . "local.php": // Special case optional file, not part of the codebase break; default: - if (strpos($path, DOCROOT . "var/logs") === 0) { - continue; - } else if (preg_match("/views/", $path)) { + if (preg_match("/views/", $path)) { $this->_check_view_preamble($path, $errors); } else { $this->_check_php_preamble($path, $errors); @@ -207,8 +217,7 @@ class File_Structure_Test extends Unit_Test_Case { class PhpCodeFilterIterator extends FilterIterator { public function accept() { $path_name = $this->getInnerIterator()->getPathName(); - return (substr($path_name, -4) == ".php" && - !(strpos($path_name, VARPATH) === 0)); + return substr($path_name, -4) == ".php"; } } -- cgit v1.2.3