summaryrefslogtreecommitdiff
path: root/core/tests
diff options
context:
space:
mode:
Diffstat (limited to 'core/tests')
-rw-r--r--core/tests/Access_Helper_Test.php323
-rw-r--r--core/tests/Album_Helper_Test.php87
-rw-r--r--core/tests/Albums_Controller_Test.php76
-rw-r--r--core/tests/Core_Installer_Test.php50
-rw-r--r--core/tests/Database_Test.php134
-rw-r--r--core/tests/Dir_Helper_Test.php32
-rw-r--r--core/tests/DrawForm_Test.php84
-rw-r--r--core/tests/File_Structure_Test.php235
-rw-r--r--core/tests/I18n_Test.php108
-rw-r--r--core/tests/Item_Model_Test.php143
-rw-r--r--core/tests/Menu_Test.php32
-rw-r--r--core/tests/Movie_Helper_Test.php46
-rw-r--r--core/tests/ORM_MPTT_Test.php221
-rw-r--r--core/tests/Photo_Helper_Test.php109
-rw-r--r--core/tests/Photos_Controller_Test.php74
-rw-r--r--core/tests/REST_Controller_Test.php197
-rw-r--r--core/tests/REST_Helper_Test.php45
-rw-r--r--core/tests/Sendmail_Test.php115
-rw-r--r--core/tests/Var_Test.php49
-rw-r--r--core/tests/images/DSC_0003.jpgbin735609 -> 0 bytes
-rw-r--r--core/tests/images/DSC_0005.jpgbin687555 -> 0 bytes
-rw-r--r--core/tests/images/DSC_0017.jpgbin1246655 -> 0 bytes
-rw-r--r--core/tests/images/DSC_0019.jpgbin649556 -> 0 bytes
-rw-r--r--core/tests/images/DSC_0067.jpgbin1245526 -> 0 bytes
-rw-r--r--core/tests/images/DSC_0072.jpgbin1014511 -> 0 bytes
-rw-r--r--core/tests/images/P4050088.jpgbin1774906 -> 0 bytes
-rw-r--r--core/tests/selenium/Add_Album.html52
-rw-r--r--core/tests/selenium/Add_Comment.html52
-rw-r--r--core/tests/selenium/Add_Item.html62
-rw-r--r--core/tests/selenium/Login.html47
-rw-r--r--core/tests/test.jpgbin6232 -> 0 bytes
31 files changed, 0 insertions, 2373 deletions
diff --git a/core/tests/Access_Helper_Test.php b/core/tests/Access_Helper_Test.php
deleted file mode 100644
index 7012a487..00000000
--- a/core/tests/Access_Helper_Test.php
+++ /dev/null
@@ -1,323 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Access_Helper_Test extends Unit_Test_Case {
- private $_group;
-
- public function teardown() {
- try {
- $group = ORM::factory("group")->where("name", "access_test")->find();
- if ($group->loaded) {
- $group->delete();
- }
- } catch (Exception $e) { }
-
- try {
- access::delete_permission("access_test");
- } catch (Exception $e) { }
-
- try {
- $user = ORM::factory("user")->where("name", "access_test")->find();
- if ($user->loaded) {
- $user->delete();
- }
- } catch (Exception $e) { }
- }
-
- public function setup() {
- user::set_active(user::guest());
- }
-
- public function groups_and_permissions_are_bound_to_columns_test() {
- access::register_permission("access_test", "Access Test");
- $group = group::create("access_test");
-
- // We have a new column for this perm / group combo
- $fields = Database::instance()->list_fields("access_caches");
- $this->assert_true(array_key_exists("access_test_{$group->id}", $fields));
-
- access::delete_permission("access_test");
- $group->delete();
-
- // Now the column has gone away
- $fields = Database::instance()->list_fields("access_caches");
- $this->assert_false(array_key_exists("access_test_{$group->id}", $fields));
- }
-
- public function adding_and_removing_items_adds_ands_removes_rows_test() {
- $root = ORM::factory("item", 1);
- $item = album::create($root, rand(), "test album");
-
- // New rows exist
- $this->assert_true(ORM::factory("access_cache")->where("item_id", $item->id)->find()->loaded);
- $this->assert_true(ORM::factory("access_intent")->where("item_id", $item->id)->find()->loaded);
-
- // Delete the item
- $item->delete();
-
- // Rows are gone
- $this->assert_false(ORM::factory("access_cache")->where("item_id", $item->id)->find()->loaded);
- $this->assert_false(ORM::factory("access_intent")->where("item_id", $item->id)->find()->loaded);
- }
-
- public function new_photos_inherit_parent_permissions_test() {
- $root = ORM::factory("item", 1);
-
- $album = album::create($root, rand(), "test album");
- access::allow(group::everybody(), "view", $album);
-
- $photo = ORM::factory("item");
- $photo->type = "photo";
- $photo->add_to_parent($album);
- access::add_item($photo);
-
- $this->assert_true($photo->__get("view_" . group::everybody()->id));
- }
-
- public function can_allow_deny_and_reset_intent_test() {
- $root = ORM::factory("item", 1);
- $album = album::create($root, rand(), "test album");
- $intent = ORM::factory("access_intent")->where("item_id", $album)->find();
-
- // Allow
- access::allow(group::everybody(), "view", $album);
- $this->assert_same(access::ALLOW, $intent->reload()->view_1);
-
- // Deny
- access::deny(group::everybody(), "view", $album);
- $this->assert_same(
- access::DENY,
- ORM::factory("access_intent")->where("item_id", $album)->find()->view_1);
-
- // Allow again. If the initial value was allow, then the first Allow clause above may not
- // have actually changed any values.
- access::allow(group::everybody(), "view", $album);
- $this->assert_same(
- access::ALLOW,
- ORM::factory("access_intent")->where("item_id", $album)->find()->view_1);
-
- access::reset(group::everybody(), "view", $album);
- $this->assert_same(
- null,
- ORM::factory("access_intent")->where("item_id", $album)->find()->view_1);
- }
-
- public function cant_reset_root_item_test() {
- try {
- access::reset(group::everybody(), "view", ORM::factory("item", 1));
- } catch (Exception $e) {
- return;
- }
- $this->assert_true(false, "Should not be able to reset root intent");
- }
-
- public function can_view_item_test() {
- $root = ORM::factory("item", 1);
- access::allow(group::everybody(), "view", $root);
- $this->assert_true(access::group_can(group::everybody(), "view", $root));
- }
-
- public function can_always_fails_on_unloaded_items_test() {
- $root = ORM::factory("item", 1);
- access::allow(group::everybody(), "view", $root);
- $this->assert_true(access::group_can(group::everybody(), "view", $root));
-
- $bogus = ORM::factory("item", -1);
- $this->assert_false(access::group_can(group::everybody(), "view", $bogus));
- }
-
- public function cant_view_child_of_hidden_parent_test() {
- $root = ORM::factory("item", 1);
- $album = album::create($root, rand(), "test album");
-
- $root->reload();
- access::deny(group::everybody(), "view", $root);
- access::reset(group::everybody(), "view", $album);
-
- $album->reload();
- $this->assert_false(access::group_can(group::everybody(), "view", $album));
- }
-
- public function view_permissions_propagate_down_test() {
- $root = ORM::factory("item", 1);
- $album = album::create($root, rand(), "test album");
-
- access::allow(group::everybody(), "view", $root);
- access::reset(group::everybody(), "view", $album);
- $album->reload();
- $this->assert_true(access::group_can(group::everybody(), "view", $album));
- }
-
- public function can_toggle_view_permissions_propagate_down_test() {
- $root = ORM::factory("item", 1);
- $album1 = album::create($root, rand(), "test album");
- $album2 = album::create($album1, rand(), "test album");
- $album3 = album::create($album2, rand(), "test album");
- $album4 = album::create($album3, rand(), "test album");
-
- $album1->reload();
- $album2->reload();
- $album3->reload();
- $album4->reload();
-
- access::allow(group::everybody(), "view", $root);
- access::deny(group::everybody(), "view", $album1);
- access::reset(group::everybody(), "view", $album2);
- access::reset(group::everybody(), "view", $album3);
- access::reset(group::everybody(), "view", $album4);
-
- $album4->reload();
- $this->assert_false(access::group_can(group::everybody(), "view", $album4));
-
- access::allow(group::everybody(), "view", $album1);
- $album4->reload();
- $this->assert_true(access::group_can(group::everybody(), "view", $album4));
- }
-
- public function revoked_view_permissions_cant_be_allowed_lower_down_test() {
- $root = ORM::factory("item", 1);
- $album1 = album::create($root, rand(), "test album");
- $album2 = album::create($album1, rand(), "test album");
-
- $root->reload();
- access::deny(group::everybody(), "view", $root);
- access::allow(group::everybody(), "view", $album2);
-
- $album1->reload();
- $this->assert_false(access::group_can(group::everybody(), "view", $album1));
-
- $album2->reload();
- $this->assert_false(access::group_can(group::everybody(), "view", $album2));
- }
-
- public function can_edit_item_test() {
- $root = ORM::factory("item", 1);
- access::allow(group::everybody(), "edit", $root);
- $this->assert_true(access::group_can(group::everybody(), "edit", $root));
- }
-
- public function non_view_permissions_propagate_down_test() {
- $root = ORM::factory("item", 1);
- $album = album::create($root, rand(), "test album");
-
- access::allow(group::everybody(), "edit", $root);
- access::reset(group::everybody(), "edit", $album);
- $this->assert_true(access::group_can(group::everybody(), "edit", $album));
- }
-
- public function non_view_permissions_can_be_revoked_lower_down_test() {
- $root = ORM::factory("item", 1);
- $outer = album::create($root, rand(), "test album");
- $outer_photo = ORM::factory("item");
- $outer_photo->type = "photo";
- $outer_photo->add_to_parent($outer);
- access::add_item($outer_photo);
-
- $inner = album::create($outer, rand(), "test album");
- $inner_photo = ORM::factory("item");
- $inner_photo->type = "photo";
- $inner_photo->add_to_parent($inner);
- access::add_item($inner_photo);
-
- $outer->reload();
- $inner->reload();
-
- access::allow(group::everybody(), "edit", $root);
- access::deny(group::everybody(), "edit", $outer);
- access::allow(group::everybody(), "edit", $inner);
-
- // Outer album is not editable, inner one is.
- $this->assert_false(access::group_can(group::everybody(), "edit", $outer_photo));
- $this->assert_true(access::group_can(group::everybody(), "edit", $inner_photo));
- }
-
- public function i_can_edit_test() {
- // Create a new user that belongs to no groups
- $user = user::create("access_test", "Access Test", "");
- foreach ($user->groups as $group) {
- $user->remove($group);
- }
- $user->save();
- user::set_active($user);
-
- // This user can't edit anything
- $root = ORM::factory("item", 1);
- $this->assert_false(access::can("edit", $root));
-
- // Now add them to a group that has edit permission
- $group = group::create("access_test");
- $group->add($user);
- $group->save();
- access::allow($group, "edit", $root);
-
- $user = ORM::factory("user", $user->id); // reload() does not flush related columns
- user::set_active($user);
-
- // And verify that the user can edit.
- $this->assert_true(access::can("edit", $root));
- }
-
- public function everybody_view_permission_maintains_htaccess_files_test() {
- $root = ORM::factory("item", 1);
- $album = album::create($root, rand(), "test album");
-
- $this->assert_false(file_exists($album->file_path() . "/.htaccess"));
-
- access::deny(group::everybody(), "view", $album);
- $this->assert_true(file_exists($album->file_path() . "/.htaccess"));
-
- access::allow(group::everybody(), "view", $album);
- $this->assert_false(file_exists($album->file_path() . "/.htaccess"));
-
- access::deny(group::everybody(), "view", $album);
- $this->assert_true(file_exists($album->file_path() . "/.htaccess"));
-
- access::reset(group::everybody(), "view", $album);
- $this->assert_false(file_exists($album->file_path() . "/.htaccess"));
- }
-
- public function everybody_view_full_permission_maintains_htaccess_files_test() {
- $root = ORM::factory("item", 1);
- $album = album::create($root, rand(), "test album");
-
- $this->assert_false(file_exists($album->file_path() . "/.htaccess"));
- $this->assert_false(file_exists($album->resize_path() . "/.htaccess"));
- $this->assert_false(file_exists($album->thumb_path() . "/.htaccess"));
-
- access::deny(group::everybody(), "view_full", $album);
- $this->assert_true(file_exists($album->file_path() . "/.htaccess"));
- $this->assert_false(file_exists($album->resize_path() . "/.htaccess"));
- $this->assert_false(file_exists($album->thumb_path() . "/.htaccess"));
-
- access::allow(group::everybody(), "view_full", $album);
- $this->assert_false(file_exists($album->file_path() . "/.htaccess"));
- $this->assert_false(file_exists($album->resize_path() . "/.htaccess"));
- $this->assert_false(file_exists($album->thumb_path() . "/.htaccess"));
-
- access::deny(group::everybody(), "view_full", $album);
- $this->assert_true(file_exists($album->file_path() . "/.htaccess"));
- $this->assert_false(file_exists($album->resize_path() . "/.htaccess"));
- $this->assert_false(file_exists($album->thumb_path() . "/.htaccess"));
-
- access::reset(group::everybody(), "view_full", $album);
- $this->assert_false(file_exists($album->file_path() . "/.htaccess"));
- $this->assert_false(file_exists($album->resize_path() . "/.htaccess"));
- $this->assert_false(file_exists($album->thumb_path() . "/.htaccess"));
- }
-}
diff --git a/core/tests/Album_Helper_Test.php b/core/tests/Album_Helper_Test.php
deleted file mode 100644
index 80afa8d1..00000000
--- a/core/tests/Album_Helper_Test.php
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Album_Helper_Test extends Unit_Test_Case {
- public function create_album_test() {
- $rand = rand();
- $root = ORM::factory("item", 1);
- $album = album::create($root, $rand, $rand, $rand);
-
- $this->assert_equal(VARPATH . "albums/$rand", $album->file_path());
- $this->assert_equal(VARPATH . "thumbs/$rand/.album.jpg", $album->thumb_path());
- $this->assert_true(is_dir(VARPATH . "thumbs/$rand"), "missing thumb dir");
-
- // It's unclear that a resize makes sense for an album. But we have one.
- $this->assert_equal(VARPATH . "resizes/$rand/.album.jpg", $album->resize_path());
- $this->assert_true(is_dir(VARPATH . "resizes/$rand"), "missing resizes dir");
-
- $this->assert_equal(1, $album->parent_id); // MPTT tests will cover other hierarchy checks
- $this->assert_equal($rand, $album->name);
- $this->assert_equal($rand, $album->title);
- $this->assert_equal($rand, $album->description);
- }
-
- public function create_conflicting_album_test() {
- $rand = rand();
- $root = ORM::factory("item", 1);
- $album1 = album::create($root, $rand, $rand, $rand);
- $album2 = album::create($root, $rand, $rand, $rand);
- $this->assert_true($album1->name != $album2->name);
- }
-
- public function thumb_url_test() {
- $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());
- }
-
- public function resize_url_test() {
- $rand = rand();
- $root = ORM::factory("item", 1);
- $album = album::create($root, $rand, $rand, $rand);
- $this->assert_equal("http://./var/resizes/$rand/.album.jpg", $album->resize_url());
- }
-
- public function create_album_shouldnt_allow_names_with_slash_test() {
- $rand = rand();
- $root = ORM::factory("item", 1);
- try {
- $album = album::create($root, $rand . "/", $rand, $rand);
- } catch (Exception $e) {
- // pass
- return;
- }
-
- $this->assert_true(false, "Shouldn't create an album with / in the name");
- }
-
- public function create_album_silently_trims_trailing_periods_test() {
- $rand = rand();
- $root = ORM::factory("item", 1);
- try {
- $album = album::create($root, $rand . "..", $rand, $rand);
- } catch (Exception $e) {
- $this->assert_equal("@todo NAME_CANNOT_END_IN_PERIOD", $e->getMessage());
- return;
- }
-
- $this->assert_true(false, "Shouldn't create an album with trailing . in the name");
- }
-}
diff --git a/core/tests/Albums_Controller_Test.php b/core/tests/Albums_Controller_Test.php
deleted file mode 100644
index ef1fac77..00000000
--- a/core/tests/Albums_Controller_Test.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Albums_Controller_Test extends Unit_Test_Case {
- public function setup() {
- $this->_post = $_POST;
- }
-
- public function teardown() {
- $_POST = $this->_post;
- }
-
- public function change_album_test() {
- $controller = new Albums_Controller();
- $root = ORM::factory("item", 1);
- $album = album::create($root, "test", "test", "test");
- $orig_name = $album->name;
-
- $_POST["dirname"] = "test";
- $_POST["name"] = "new name";
- $_POST["title"] = "new title";
- $_POST["description"] = "new description";
- $_POST["column"] = "weight";
- $_POST["direction"] = "ASC";
- $_POST["csrf"] = access::csrf_token();
- $_POST["_method"] = "put";
- access::allow(group::everybody(), "edit", $root);
-
- ob_start();
- $controller->_update($album);
- $results = ob_get_contents();
- ob_end_clean();
-
- $this->assert_equal(
- json_encode(array("result" => "success", "location" => "http://./index.php/test")),
- $results);
- $this->assert_equal("new title", $album->title);
- $this->assert_equal("new description", $album->description);
-
- // We don't change the name, yet.
- $this->assert_equal($orig_name, $album->name);
- }
-
- public function change_album_no_csrf_fails_test() {
- $controller = new Albums_Controller();
- $root = ORM::factory("item", 1);
- $album = album::create($root, "test", "test", "test");
- $_POST["name"] = "new name";
- $_POST["title"] = "new title";
- $_POST["description"] = "new description";
- access::allow(group::everybody(), "edit", $root);
-
- try {
- $controller->_update($album);
- $this->assert_true(false, "This should fail");
- } catch (Exception $e) {
- // pass
- }
- }
-}
diff --git a/core/tests/Core_Installer_Test.php b/core/tests/Core_Installer_Test.php
deleted file mode 100644
index f7036286..00000000
--- a/core/tests/Core_Installer_Test.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/**
- * This test case operates under the assumption that core_installer::install() is called by the
- * test controller before it starts.
- */
-class Core_Installer_Test extends Unit_Test_Case {
- public function install_creates_dirs_test() {
- $this->assert_true(file_exists(VARPATH . "albums"));
- $this->assert_true(file_exists(VARPATH . "resizes"));
- }
-
- public function install_registers_core_module_test() {
- $core = ORM::factory("module")->where("name", "core")->find();
- $this->assert_equal("core", $core->name);
-
- // This is probably too volatile to keep for long
- $this->assert_equal(1, $core->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/core/tests/Database_Test.php b/core/tests/Database_Test.php
deleted file mode 100644
index bd3d2f53..00000000
--- a/core/tests/Database_Test.php
+++ /dev/null
@@ -1,134 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Database_Test extends Unit_Test_Case {
- function simple_where_test() {
- $sql = Database::instance()
- ->where("a", 1)
- ->where("b", 2)
- ->compile();
- $sql = str_replace("\n", " ", $sql);
- $this->assert_same("SELECT * WHERE `a` = 1 AND `b` = 2", $sql);
- }
-
- function compound_where_test() {
- $sql = Database::instance()
- ->where("outer1", 1)
- ->open_paren()
- ->where("inner1", 1)
- ->orwhere("inner2", 2)
- ->close_paren()
- ->where("outer2", 2)
- ->compile();
- $sql = str_replace("\n", " ", $sql);
- $this->assert_same(
- "SELECT * WHERE `outer1` = 1 AND (`inner1` = 1 OR `inner2` = 2) AND `outer2` = 2",
- $sql);
- }
-
- function group_first_test() {
- $sql = Database::instance()
- ->open_paren()
- ->where("inner1", 1)
- ->orwhere("inner2", 2)
- ->close_paren()
- ->where("outer1", 1)
- ->where("outer2", 2)
- ->compile();
- $sql = str_replace("\n", " ", $sql);
- $this->assert_same(
- "SELECT * WHERE (`inner1` = 1 OR `inner2` = 2) AND `outer1` = 1 AND `outer2` = 2",
- $sql);
- }
-
- function where_array_test() {
- $sql = Database::instance()
- ->where("outer1", 1)
- ->open_paren()
- ->where("inner1", 1)
- ->orwhere(array("inner2" => 2, "inner3" => 3))
- ->close_paren()
- ->compile();
- $sql = str_replace("\n", " ", $sql);
- $this->assert_same(
- "SELECT * WHERE `outer1` = 1 AND (`inner1` = 1 OR `inner2` = 2 OR `inner3` = 3)",
- $sql);
- }
-
- function notlike_test() {
- $sql = Database::instance()
- ->where("outer1", 1)
- ->open_paren()
- ->ornotlike("inner1", 1)
- ->close_paren()
- ->compile();
- $sql = str_replace("\n", " ", $sql);
- $this->assert_same(
- "SELECT * WHERE `outer1` = 1 OR ( `inner1` NOT LIKE '%1%')",
- $sql);
- }
-
- function prefix_replacement_test() {
- $db = Database_For_Test::instance();
- $converted = $db->add_table_prefixes("CREATE TABLE IF NOT EXISTS {test_tables} (
- `id` int(9) NOT NULL auto_increment,
- `name` varchar(32) NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8");
- $expected = "CREATE TABLE IF NOT EXISTS g3test_test_tables (
- `id` int(9) NOT NULL auto_increment,
- `name` varchar(32) NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8";
- $this->assert_same($expected, $converted);
-
- $sql = "UPDATE {test_tables} SET `name` = '{test string}' " .
- "WHERE `item_id` IN " .
- " (SELECT `id` FROM {items} " .
- " WHERE `left` >= 1 " .
- " AND `right` <= 6)";
- $sql = $db->add_table_prefixes($sql);
-
- $expected = "UPDATE g3test_test_tables SET `name` = '{test string}' " .
- "WHERE `item_id` IN " .
- " (SELECT `id` FROM g3test_items " .
- " WHERE `left` >= 1 " .
- " AND `right` <= 6)";
-
- $this->assert_same($expected, $sql);
- }
-
- public function setup() {
- }
-
- public function teardown() {
- }
-
-}
-
-class Database_For_Test extends Database {
- static function instance() {
- $db = new Database_For_Test();
- $db->_table_names["{items}"] = "g3test_items";
- $db->config["table_prefix"] = "g3test_";
- return $db;
- }
-}
diff --git a/core/tests/Dir_Helper_Test.php b/core/tests/Dir_Helper_Test.php
deleted file mode 100644
index 46bb871c..00000000
--- a/core/tests/Dir_Helper_Test.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Dir_Helper_Test extends Unit_Test_Case {
- public function remove_album_test() {
- $dirname = (VARPATH . "albums/testdir");
- mkdir($dirname, 0777, true);
-
- $filename = tempnam($dirname, "file");
- touch($filename);
-
- dir::unlink($dirname);
- $this->assert_boolean(!file_exists($filename), "File not deleted");
- $this->assert_boolean(!file_exists($dirname), "Directory not deleted");
- }
-}
diff --git a/core/tests/DrawForm_Test.php b/core/tests/DrawForm_Test.php
deleted file mode 100644
index 2c5aaba4..00000000
--- a/core/tests/DrawForm_Test.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class DrawForm_Test extends Unit_Test_Case {
- function no_group_test() {
- $form = new Forge("test/controller", "", "post", array("id" => "gTestGroupForm"));
- $form->input("title")->label(t("Title"));
- $form->textarea("description")->label(t("Text Area"));
- $form->submit("")->value(t("Submit"));
- $rendered = $form->__toString();
-
- $expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " .
- "id=\"gTestGroupForm\">\n" .
- "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" .
- " <ul>\n" .
- " <li>\n" .
- " <label for=\"title\" >Title</label>\n" .
- " <input type=\"text\" id=\"title\" name=\"title\" value=\"\" " .
- "class=\"textbox\" />\n" .
- " </li>\n" .
- " <li>\n" .
- " <label for=\"description\" >Text Area</label>\n" .
- " <textarea id=\"description\" name=\"description\" " .
- "class=\"textarea\" ></textarea>\n" .
- " </li>\n" .
- " <li>\n" .
- " <input type=\"submit\" value=\"Submit\" class=\"submit\" />\n" .
- " </li>\n" .
- " </ul>\n" .
- "</form>\n";
- $this->assert_same($expected, $rendered);
- }
-
- function group_test() {
- $form = new Forge("test/controller", "", "post", array("id" => "gTestGroupForm"));
- $group = $form->group("test_group")->label(t("Test Group"));
- $group->input("title")->label(t("Title"));
- $group->textarea("description")->label(t("Text Area"));
- $group->submit("")->value(t("Submit"));
- $rendered = $form->__toString();
-
- $expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " .
- "id=\"gTestGroupForm\">\n" .
- "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" .
- " <fieldset>\n" .
- " <legend>Test Group</legend>\n" .
- " <ul>\n" .
- " <li>\n" .
- " <label for=\"title\" >Title</label>\n" .
- " <input type=\"text\" id=\"title\" name=\"title\" value=\"\" " .
- "class=\"textbox\" />\n" .
- " </li>\n" .
- " <li>\n" .
- " <label for=\"description\" >Text Area</label>\n" .
- " <textarea id=\"description\" name=\"description\" " .
- "class=\"textarea\" ></textarea>\n" .
- " </li>\n" .
- " <li>\n" .
- " <input type=\"submit\" value=\"Submit\" class=\"submit\" />\n" .
- " </li>\n" .
- " </ul>\n" .
- " </fieldset>\n" .
- "</form>\n";
- $this->assert_same($expected, $rendered);
- }
-
-}
-
diff --git a/core/tests/File_Structure_Test.php b/core/tests/File_Structure_Test.php
deleted file mode 100644
index 1caa82ba..00000000
--- a/core/tests/File_Structure_Test.php
+++ /dev/null
@@ -1,235 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class File_Structure_Test extends Unit_Test_Case {
- public function no_trailing_closing_php_tag_test() {
- $dir = new GalleryCodeFilterIterator(
- new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT)));
- foreach ($dir as $file) {
- if (!preg_match("|\.html\.php$|", $file->getPathname())) {
- $this->assert_false(
- preg_match('/\?\>\s*$/', file_get_contents($file)),
- "{$file->getPathname()} ends in ?>");
- }
- }
- }
-
- public function view_files_correct_suffix_test() {
- $dir = new GalleryCodeFilterIterator(
- new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT)));
- foreach ($dir as $file) {
- if (strpos($file, "views")) {
- $this->assert_true(
- preg_match("#/views/.*?(\.html|mrss|txt)\.php$#", $file->getPathname()),
- "{$file->getPathname()} should end in .{html,mrss,txt}.php");
- }
- }
- }
-
- public function no_windows_line_endings_test() {
- $dir = new GalleryCodeFilterIterator(
- new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT)));
- foreach ($dir as $file) {
- if (preg_match("/\.(php|css|html|js)$/", $file)) {
- foreach (file($file) as $line) {
- $this->assert_true(substr($line, -2) != "\r\n", "$file has windows style line endings");
- }
- }
- }
- }
-
- private function _check_view_preamble($path, &$errors) {
- // The preamble for views is a single line that prevents direct script access
- if (strpos($path, SYSPATH) === 0) {
- // Kohana preamble
- $expected = "<?php defined('SYSPATH') OR die('No direct access allowed.'); ?>\n";
- } else {
- // Gallery preamble
- // @todo use the same preamble for both!
- $expected = "<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n";
- }
-
- $fp = fopen($path, "r");
- $actual = fgets($fp);
- fclose($fp);
-
- if ($expected != $actual) {
- $errors[] = "$path:1\n expected:\n\t$expected\n actual:\n\t$actual";
- }
- }
-
- private function _check_php_preamble($path, &$errors) {
- if (strpos($path, SYSPATH) === 0 ||
- strpos($path, MODPATH . "unit_test") === 0) {
- // Kohana: we only care about the first line
- $fp = fopen($path, "r");
- $actual = array(fgets($fp));
- fclose($fp);
- $expected = array("<?php defined('SYSPATH') OR die('No direct access allowed.');\n");
- } else if (strpos($path, MODPATH . "forge") === 0 ||
- strpos($path, MODPATH . "exif/lib") === 0 ||
- $path == MODPATH . "user/lib/PasswordHash.php" ||
- $path == DOCROOT . "var/database.php") {
- // 3rd party module security-only preambles, similar to Gallery's
- $expected = array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\");\n");
- $fp = fopen($path, "r");
- $actual = array(fgets($fp));
- fclose($fp);
- } else {
- // Gallery: we care about the entire copyright
- $actual = $this->_get_preamble($path);
- $expected = array(
- "<?php defined(\"SYSPATH\") or die(\"No direct script access.\");",
- "/**",
- " * Gallery - a web based photo album viewer and editor",
- " * Copyright (C) 2000-2009 Bharat Mediratta",
- " *",
- " * This program is free software; you can redistribute it and/or modify",
- " * it under the terms of the GNU General Public License as published by",
- " * the Free Software Foundation; either version 2 of the License, or (at",
- " * your option) any later version.",
- " *",
- " * This program is distributed in the hope that it will be useful, but",
- " * WITHOUT ANY WARRANTY; without even the implied warranty of",
- " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU",
- " * General Public License for more details.",
- " *",
- " * You should have received a copy of the GNU General Public License",
- " * along with this program; if not, write to the Free Software",
- " * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.",
- " */",
- );
- }
- if ($expected != $actual) {
- $errors[] = "$path:1\n expected\n\t" . join("\n\t", $expected) .
- "\n actual:\n\t" . join("\n\t", $actual);
- }
- }
-
- public function code_files_start_with_preamble_test() {
- $dir = new PhpCodeFilterIterator(
- new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT)));
-
- $errors = array();
- foreach ($dir as $file) {
- $path = $file->getPathname();
- switch ($path) {
- case DOCROOT . "installer/database_config.php":
- case DOCROOT . "installer/init_var.php":
- // Special case views
- $this->_check_view_preamble($path, $errors);
- break;
-
- case DOCROOT . "index.php":
- case DOCROOT . "installer/index.php":
- // Front controllers
- break;
-
- case DOCROOT . "index.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)) {
- $this->_check_view_preamble($path, $errors);
- } else {
- $this->_check_php_preamble($path, $errors);
- }
- }
- }
-
- if ($errors) {
- $this->assert_false(true, "Preamble errors:\n" . join("\n", $errors));
- }
- }
-
- public function no_tabs_in_our_code_test() {
- $dir = new PhpCodeFilterIterator(
- new GalleryCodeFilterIterator(
- new RecursiveIteratorIterator(
- new RecursiveDirectoryIterator(DOCROOT))));
- foreach ($dir as $file) {
- $this->assert_false(
- preg_match('/\t/', file_get_contents($file)),
- "{$file->getPathname()} has tabs in it");
- }
- }
-
- private function _get_preamble($file) {
- $lines = file($file);
- $copy = array();
- for ($i = 0; $i < count($lines); $i++) {
- $copy[] = rtrim($lines[$i]);
- if (!strncmp($lines[$i], ' */', 3)) {
- return $copy;
- }
- }
- return $copy;
- }
-
- public function helpers_are_static_test() {
- $dir = new PhpCodeFilterIterator(
- new GalleryCodeFilterIterator(
- new RecursiveIteratorIterator(
- new RecursiveDirectoryIterator(DOCROOT))));
- foreach ($dir as $file) {
- if (basename(dirname($file)) == "helpers") {
- foreach (file($file) as $line) {
- $this->assert_true(
- !preg_match("/\sfunction\s.*\(/", $line) ||
- preg_match("/^\s*(private static function _|static function)/", $line),
- "should be \"static function foo\" or \"private static function _foo\":\n" .
- "$file\n$line\n");
- }
- }
- }
- }
-}
-
-class PhpCodeFilterIterator extends FilterIterator {
- public function accept() {
- $path_name = $this->getInnerIterator()->getPathName();
- return (substr($path_name, -4) == ".php" &&
- !(strpos($path_name, VARPATH) === 0));
- }
-}
-
-class GalleryCodeFilterIterator extends FilterIterator {
- public function accept() {
- // Skip anything that we didn"t write
- $path_name = $this->getInnerIterator()->getPathName();
- return !(
- strpos($path_name, ".svn") ||
- strpos($path_name, "core/views/kohana_profiler.php") !== false ||
- strpos($path_name, DOCROOT . "test") !== false ||
- strpos($path_name, DOCROOT . "var") !== false ||
- strpos($path_name, MODPATH . "forge") !== false ||
- strpos($path_name, APPPATH . "views/kohana_error_page.php") !== false ||
- strpos($path_name, MODPATH . "gallery_unit_test/views/kohana_error_page.php") !== false ||
- strpos($path_name, MODPATH . "gallery_unit_test/views/kohana_unit_test_cli.php") !== false ||
- strpos($path_name, MODPATH . "unit_test") !== false ||
- strpos($path_name, MODPATH . "exif/lib") !== false ||
- strpos($path_name, MODPATH . "user/lib/PasswordHash") !== false ||
- strpos($path_name, DOCROOT . "lib/swfupload") !== false ||
- strpos($path_name, SYSPATH) !== false ||
- substr($path_name, -1, 1) == "~");
- }
-}
diff --git a/core/tests/I18n_Test.php b/core/tests/I18n_Test.php
deleted file mode 100644
index 9010606a..00000000
--- a/core/tests/I18n_Test.php
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-class I18n_Test extends Unit_Test_Case {
- private $i18n;
-
- public function setup() {
- $config = array(
- 'root_locale' => 'en',
- 'default_locale' => 'te_ST',
- 'locale_dir' => VARPATH . 'locale/');
- $this->i18n = I18n::instance($config);
-
- ORM::factory("incoming_translation")
- ->where("locale", "te_ST")
- ->delete_all();
-
- $messages_te_ST = array(
- array('Hello world', 'Hallo Welt'),
- array(array('one' => 'One item has been added',
- 'other' => '%count elements have been added'),
- array('one' => 'Ein Element wurde hinzugefuegt.',
- 'other' => '%count Elemente wurden hinzugefuegt.')),
- array('Hello %name, how are you today?', 'Hallo %name, wie geht es Dir heute?'));
-
- foreach ($messages_te_ST as $data) {
- list ($message, $translation) = $data;
- $entry = ORM::factory("incoming_translation");
- $entry->key = I18n::get_message_key($message);
- $entry->message = serialize($message);
- $entry->translation = serialize($translation);
- $entry->locale = 'te_ST';
- $entry->revision = null;
- $entry->save();
- }
- }
-
- public function get_locale_test() {
- $locale = $this->i18n->locale();
- $this->assert_equal("te_ST", $locale);
- }
-
- public function set_locale_test() {
- $this->i18n->locale("de_DE");
- $locale = $this->i18n->locale();
- $this->assert_equal("de_DE", $locale);
- }
-
- public function translate_simple_test() {
- $result = $this->i18n->translate('Hello world');
- $this->assert_equal('Hallo Welt', $result);
- }
-
- public function translate_simple_root_fallback_test() {
- $result = $this->i18n->translate('Hello world zzz');
- $this->assert_equal('Hello world zzz', $result);
- }
-
- public function translate_plural_other_test() {
- $result = $this->i18n->translate(array('one' => 'One item has been added',
- 'other' => '%count elements have been added'),
- array('count' => 5));
- $this->assert_equal('5 Elemente wurden hinzugefuegt.', $result);
- }
-
- public function translate_plural_one_test() {
- $result = $this->i18n->translate(array('one' => 'One item has been added',
- 'other' => '%count elements have been added'),
- array('count' => 1));
- $this->assert_equal('Ein Element wurde hinzugefuegt.', $result);
- }
-
- public function translate_interpolate_test() {
- $result = $this->i18n->translate('Hello %name, how are you today?', array('name' => 'John'));
- $this->assert_equal('Hallo John, wie geht es Dir heute?', $result);
- }
-
- public function translate_interpolate_missing_value_test() {
- $result = $this->i18n->translate('Hello %name, how are you today?', array('foo' => 'bar'));
- $this->assert_equal('Hallo %name, wie geht es Dir heute?', $result);
- }
-
- public function translate_plural_zero_test() {
- // te_ST has the same plural rules as en and de.
- // For count 0, plural form "other" should be used.
- $result = $this->i18n->translate(array('one' => 'One item has been added',
- 'other' => '%count elements have been added'),
- array('count' => 0));
- $this->assert_equal('0 Elemente wurden hinzugefuegt.', $result);
- }
-} \ No newline at end of file
diff --git a/core/tests/Item_Model_Test.php b/core/tests/Item_Model_Test.php
deleted file mode 100644
index 615b8997..00000000
--- a/core/tests/Item_Model_Test.php
+++ /dev/null
@@ -1,143 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Item_Model_Test extends Unit_Test_Case {
- public function saving_sets_created_and_updated_dates_test() {
- $item = self::create_random_item();
- $this->assert_true(!empty($item->created));
- $this->assert_true(!empty($item->updated));
- }
-
- private function create_random_item() {
- $item = ORM::factory("item");
- /* Set all required fields (values are irrelevant) */
- $item->name = rand();
- $item->type = "photo";
- return $item->add_to_parent(ORM::factory("item", 1));
- }
-
- public function updating_doesnt_change_created_date_test() {
- $item = self::create_random_item();
-
- // Force the creation date to something well known
- $db = Database::instance();
- $db->update("items", array("created" => 0, "updated" => 0), array("id" => $item->id));
- $item->reload();
- $item->title = "foo"; // force a change
- $item->save();
-
- $this->assert_true(empty($item->created));
- $this->assert_true(!empty($item->updated));
- }
-
- public function updating_view_count_only_doesnt_change_updated_date_test() {
- $item = self::create_random_item();
- $item->reload();
- $this->assert_same(0, $item->view_count);
-
- // Force the updated date to something well known
- $db = Database::instance();
- $db->update("items", array("updated" => 0), array("id" => $item->id));
- $item->reload();
- $item->view_count++;
- $item->save();
-
- $this->assert_same(1, $item->view_count);
- $this->assert_true(empty($item->updated));
- }
-
- public function move_photo_test() {
- // Create a test photo
- $item = self::create_random_item();
-
- file_put_contents($item->thumb_path(), "thumb");
- file_put_contents($item->resize_path(), "resize");
- file_put_contents($item->file_path(), "file");
-
- $original_name = $item->name;
- $new_name = rand();
-
- // Now rename it
- $item->rename($new_name)->save();
-
- // Expected: the name changed, the name is now baked into all paths, and all files were moved.
- $this->assert_equal($new_name, $item->name);
- $this->assert_equal($new_name, basename($item->file_path()));
- $this->assert_equal($new_name, basename($item->thumb_path()));
- $this->assert_equal($new_name, basename($item->resize_path()));
- $this->assert_equal("thumb", file_get_contents($item->thumb_path()));
- $this->assert_equal("resize", file_get_contents($item->resize_path()));
- $this->assert_equal("file", file_get_contents($item->file_path()));
- }
-
- public function move_album_test() {
- // Create an album with a photo in it
- $root = ORM::factory("item", 1);
- $album = album::create($root, rand(), rand(), rand());
- $photo = ORM::factory("item");
- $photo->name = rand();
- $photo->type = "photo";
- $photo->add_to_parent($album);
-
- file_put_contents($photo->thumb_path(), "thumb");
- file_put_contents($photo->resize_path(), "resize");
- file_put_contents($photo->file_path(), "file");
-
- $original_album_name = $album->name;
- $original_photo_name = $photo->name;
- $new_album_name = rand();
-
- // Now rename the album
- $album->rename($new_album_name)->save();
- $photo->reload();
-
- // Expected:
- // * the album name changed.
- // * the album dirs are all moved
- // * the photo's paths are all inside the albums paths
- // * the photo files are all still intact and accessible
- $this->assert_equal($new_album_name, $album->name);
- $this->assert_equal($new_album_name, basename($album->file_path()));
- $this->assert_equal($new_album_name, basename(dirname($album->thumb_path())));
- $this->assert_equal($new_album_name, basename(dirname($album->resize_path())));
-
- $this->assert_same(0, strpos($photo->file_path(), $album->file_path()));
- $this->assert_same(0, strpos($photo->thumb_path(), dirname($album->thumb_path())));
- $this->assert_same(0, strpos($photo->resize_path(), dirname($album->resize_path())));
-
- $this->assert_equal("thumb", file_get_contents($photo->thumb_path()));
- $this->assert_equal("resize", file_get_contents($photo->resize_path()));
- $this->assert_equal("file", file_get_contents($photo->file_path()));
- }
-
- public function item_rename_wont_accept_slash_test() {
- // Create a test photo
- $item = self::create_random_item();
-
- $new_name = rand() . "/";
-
- try {
- $item->rename($new_name)->save();
- } catch (Exception $e) {
- // pass
- return;
- }
- $this->assert_false(true, "Item_Model::rename should not accept / characters");
- }
-}
diff --git a/core/tests/Menu_Test.php b/core/tests/Menu_Test.php
deleted file mode 100644
index c91aee0b..00000000
--- a/core/tests/Menu_Test.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Menu_Test extends Unit_Test_Case {
- public function find_menu_item_test() {
- $menu = new Menu(true);
- $menu
- ->append(Menu::factory("link")->id("element_1"))
- ->append(Menu::factory("dialog")->id("element_2"))
- ->append(Menu::factory("submenu")->id("element_3")
- ->append(Menu::factory("link")->id("element_3_1")));
-
- $this->assert_equal("element_2", $menu->get("element_2")->id);
- $this->assert_equal("element_3_1", $menu->get("element_3")->get("element_3_1")->id);
- }
-} \ No newline at end of file
diff --git a/core/tests/Movie_Helper_Test.php b/core/tests/Movie_Helper_Test.php
deleted file mode 100644
index b92ef3f8..00000000
--- a/core/tests/Movie_Helper_Test.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Movie_Helper_Test extends Unit_Test_Case {
- public function create_movie_shouldnt_allow_names_with_slash_test() {
- $rand = rand();
- $root = ORM::factory("item", 1);
- try {
- $movie = movie::create($root, DOCROOT . "core/tests/test.jpg", "$rand/.jpg", $rand, $rand);
- } catch (Exception $e) {
- // pass
- return;
- }
-
- $this->assert_true(false, "Shouldn't create a movie with / in the name");
- }
-
- public function create_movie_shouldnt_allow_names_with_trailing_periods_test() {
- $rand = rand();
- $root = ORM::factory("item", 1);
- try {
- $movie = movie::create($root, DOCROOT . "core/tests/test.jpg", "$rand.jpg.", $rand, $rand);
- } catch (Exception $e) {
- $this->assert_equal("@todo NAME_CANNOT_END_IN_PERIOD", $e->getMessage());
- return;
- }
-
- $this->assert_true(false, "Shouldn't create a movie with trailing . in the name");
- }
-}
diff --git a/core/tests/ORM_MPTT_Test.php b/core/tests/ORM_MPTT_Test.php
deleted file mode 100644
index 200c8a74..00000000
--- a/core/tests/ORM_MPTT_Test.php
+++ /dev/null
@@ -1,221 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class ORM_MPTT_Test extends Unit_Test_Case {
-
- private function create_item_and_add_to_parent($parent) {
- $album = album::create($parent, rand(), "test album");
- return $album;
- }
-
- public function add_to_parent_test() {
- $root = ORM::factory("item", 1);
- $album = ORM::factory("item");
- $album->type = "album";
- $album->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
- $album->sort_column = "weight";
- $album->sort_order = "ASC";
- $album->add_to_parent($root);
-
- $this->assert_equal($album->parent()->right - 2, $album->left);
- $this->assert_equal($album->parent()->right - 1, $album->right);
- $this->assert_equal($album->parent()->level + 1, $album->level);
- $this->assert_equal($album->parent()->id, $album->parent_id);
- }
-
- public function add_hierarchy_test() {
- $root = ORM::factory("item", 1);
- $album1 = self::create_item_and_add_to_parent($root);
- $album1_1 = self::create_item_and_add_to_parent($album1);
- $album1_2 = self::create_item_and_add_to_parent($album1);
- $album1_1_1 = self::create_item_and_add_to_parent($album1_1);
- $album1_1_2 = self::create_item_and_add_to_parent($album1_1);
-
- $album1->reload();
- $this->assert_equal(9, $album1->right - $album1->left);
-
- $album1_1->reload();
- $this->assert_equal(5, $album1_1->right - $album1_1->left);
- }
-
- public function delete_hierarchy_test() {
- $root = ORM::factory("item", 1);
- $album1 = self::create_item_and_add_to_parent($root);
- $album1_1 = self::create_item_and_add_to_parent($album1);
- $album1_2 = self::create_item_and_add_to_parent($album1);
- $album1_1_1 = self::create_item_and_add_to_parent($album1_1);
- $album1_1_2 = self::create_item_and_add_to_parent($album1_1);
-
- $album1_1->delete();
- $album1->reload();
-
- // Now album1 contains only album1_2
- $this->assert_equal(3, $album1->right - $album1->left);
- }
-
- public function move_to_test() {
- $root = ORM::factory("item", 1);
- $album1 = album::create($root, "move_to_test_1", "move_to_test_1");
- $album1_1 = album::create($album1, "move_to_test_1_1", "move_to_test_1_1");
- $album1_2 = album::create($album1, "move_to_test_1_2", "move_to_test_1_2");
- $album1_1_1 = album::create($album1_1, "move_to_test_1_1_1", "move_to_test_1_1_1");
- $album1_1_2 = album::create($album1_1, "move_to_test_1_1_2", "move_to_test_1_1_2");
-
- $album1_2->reload();
- $album1_1_1->reload();
-
- $album1_1_1->move_to($album1_2);
-
- $album1_1->reload();
- $album1_2->reload();
-
- $this->assert_equal(3, $album1_1->right - $album1_1->left);
- $this->assert_equal(3, $album1_2->right - $album1_2->left);
-
- $this->assert_equal(
- array($album1_1_2->id => "move_to_test_1_1_2"),
- $album1_1->children()->select_list());
-
- $this->assert_equal(
- array($album1_1_1->id => "move_to_test_1_1_1"),
- $album1_2->children()->select_list());
- }
-
- public function parent_test() {
- $root = ORM::factory("item", 1);
- $album = self::create_item_and_add_to_parent($root);
-
- $parent = ORM::factory("item", 1);
- $this->assert_equal($parent->id, $album->parent()->id);
- }
-
- public function parents_test() {
- $root = ORM::factory("item", 1);
- $outer = self::create_item_and_add_to_parent($root);
- $inner = self::create_item_and_add_to_parent($outer);
-
- $parent_ids = array();
- foreach ($inner->parents() as $parent) {
- $parent_ids[] = $parent->id;
- }
- $this->assert_equal(array(1, $outer->id), $parent_ids);
- }
-
- public function children_test() {
- $root = ORM::factory("item", 1);
- $outer = self::create_item_and_add_to_parent($root);
- $inner1 = self::create_item_and_add_to_parent($outer);
- $inner2 = self::create_item_and_add_to_parent($outer);
-
- $child_ids = array();
- foreach ($outer->children() as $child) {
- $child_ids[] = $child->id;
- }
- $this->assert_equal(array($inner1->id, $inner2->id), $child_ids);
- }
-
- public function children_limit_test() {
- $root = ORM::factory("item", 1);
- $outer = self::create_item_and_add_to_parent($root);
- $inner1 = self::create_item_and_add_to_parent($outer);
- $inner2 = self::create_item_and_add_to_parent($outer);
-
- $this->assert_equal(array($inner2->id => $inner2->name),
- $outer->children(1, 1)->select_list('id'));
- }
-
- public function children_count_test() {
- $root = ORM::factory("item", 1);
- $outer = self::create_item_and_add_to_parent($root);
- $inner1 = self::create_item_and_add_to_parent($outer);
- $inner2 = self::create_item_and_add_to_parent($outer);
-
- $this->assert_equal(2, $outer->children_count());
- }
-
- public function descendant_test() {
- $root = ORM::factory("item", 1);
-
- $parent = ORM::factory("item");
- $parent->type = "album";
- $parent->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
- $parent->sort_column = "weight";
- $parent->sort_order = "ASC";
- $parent->add_to_parent($root);
-
- $photo = ORM::factory("item");
- $photo->type = "photo";
- $photo->add_to_parent($parent);
-
- $album1 = ORM::factory("item");
- $album1->type = "album";
- $album1->rand_key = ((float)mt_rand()) / (float)mt_getrandmax();
- $album1->sort_column = "weight";
- $album1->sort_order = "ASC";
- $album1->add_to_parent($parent);
-
- $photo1 = ORM::factory("item");
- $photo1->type = "photo";
- $photo1->add_to_parent($album1);
-
- $parent->reload();
-
- $this->assert_equal(3, $parent->descendants()->count());
- $this->assert_equal(2, $parent->descendants(null, 0, "photo")->count());
- $this->assert_equal(1, $parent->descendants(null, 0, "album")->count());
- }
-
- public function descendant_limit_test() {
- $root = ORM::factory("item", 1);
-
- $parent = self::create_item_and_add_to_parent($root);
- $album1 = self::create_item_and_add_to_parent($parent);
- $album2 = self::create_item_and_add_to_parent($parent);
- $album3 = self::create_item_and_add_to_parent($parent);
-
- $parent->reload();
- $this->assert_equal(2, $parent->descendants(2)->count());
- }
-
- public function descendant_count_test() {
- $root = ORM::factory("item", 1);
-
- $parent = ORM::factory("item");
- $parent->type = "album";
- $parent->add_to_parent($root);
-
- $photo = ORM::factory("item");
- $photo->type = "photo";
- $photo->add_to_parent($parent);
-
- $album1 = ORM::factory("item");
- $album1->type = "album";
- $album1->add_to_parent($parent);
-
- $photo1 = ORM::factory("item");
- $photo1->type = "photo";
- $photo1->add_to_parent($album1);
-
- $parent->reload();
-
- $this->assert_equal(3, $parent->descendants_count());
- $this->assert_equal(2, $parent->descendants_count("photo"));
- $this->assert_equal(1, $parent->descendants_count("album"));
- }
-}
diff --git a/core/tests/Photo_Helper_Test.php b/core/tests/Photo_Helper_Test.php
deleted file mode 100644
index deb11bb9..00000000
--- a/core/tests/Photo_Helper_Test.php
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Photo_Helper_Test extends Unit_Test_Case {
- public function create_photo_test() {
- $rand = rand();
-
- $filename = DOCROOT . "core/tests/test.jpg";
- $image_info = getimagesize($filename);
-
- $root = ORM::factory("item", 1);
- $photo = photo::create($root, $filename, "$rand.jpg", $rand, $rand);
-
- $this->assert_equal(VARPATH . "albums/$rand.jpg", $photo->file_path());
- $this->assert_equal(VARPATH . "thumbs/{$rand}.jpg", $photo->thumb_path());
- $this->assert_equal(VARPATH . "resizes/{$rand}.jpg", $photo->resize_path());
-
- $this->assert_true(is_file($photo->file_path()), "missing: {$photo->file_path()}");
- $this->assert_true(is_file($photo->resize_path()), "missing: {$photo->resize_path()}");
- $this->assert_true(is_file($photo->thumb_path()), "missing: {$photo->thumb_path()}");
-
- $this->assert_equal($root->id, $photo->parent_id); // MPTT tests cover other hierarchy checks
- $this->assert_equal("$rand.jpg", $photo->name);
- $this->assert_equal($rand, $photo->title);
- $this->assert_equal($rand, $photo->description);
- $this->assert_equal("image/jpeg", $photo->mime_type);
- $this->assert_equal($image_info[0], $photo->width);
- $this->assert_equal($image_info[1], $photo->height);
-
- $this->assert_equal($photo->parent()->right - 2, $photo->left);
- $this->assert_equal($photo->parent()->right - 1, $photo->right);
- }
-
- public function create_conflicting_photo_test() {
- $rand = rand();
- $root = ORM::factory("item", 1);
- $photo1 = photo::create($root, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand);
- $photo2 = photo::create($root, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand);
- $this->assert_true($photo1->name != $photo2->name);
- }
-
- public function create_photo_with_no_extension_test() {
- $root = ORM::factory("item", 1);
- try {
- photo::create($root, "/tmp", "name", "title", "description");
- $this->assert_false("should fail with an exception");
- } catch (Exception $e) {
- // pass
- }
- }
-
- public function thumb_url_test() {
- $rand = rand();
- $root = ORM::factory("item", 1);
- $photo = photo::create($root, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand);
- $this->assert_equal("http://./var/thumbs/{$rand}.jpg", $photo->thumb_url());
- }
-
- public function resize_url_test() {
- $rand = rand();
- $root = ORM::factory("item", 1);
- $album = album::create($root, $rand, $rand, $rand);
- $photo = photo::create($album, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand);
-
- $this->assert_equal("http://./var/resizes/{$rand}/{$rand}.jpg", $photo->resize_url());
- }
-
- public function create_photo_shouldnt_allow_names_with_slash_test() {
- $rand = rand();
- $root = ORM::factory("item", 1);
- try {
- $photo = photo::create($root, DOCROOT . "core/tests/test.jpg", "$rand/.jpg", $rand, $rand);
- } catch (Exception $e) {
- // pass
- return;
- }
-
- $this->assert_true(false, "Shouldn't create a photo with / in the name");
- }
-
- public function create_photo_silently_trims_trailing_periods_test() {
- $rand = rand();
- $root = ORM::factory("item", 1);
- try {
- $photo = photo::create($root, DOCROOT . "core/tests/test.jpg", "$rand.jpg.", $rand, $rand);
- } catch (Exception $e) {
- $this->assert_equal("@todo NAME_CANNOT_END_IN_PERIOD", $e->getMessage());
- return;
- }
-
- $this->assert_true(false, "Shouldn't create a photo with trailing . in the name");
- }
-}
diff --git a/core/tests/Photos_Controller_Test.php b/core/tests/Photos_Controller_Test.php
deleted file mode 100644
index 71319315..00000000
--- a/core/tests/Photos_Controller_Test.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Photos_Controller_Test extends Unit_Test_Case {
- public function setup() {
- $this->_post = $_POST;
- }
-
- public function teardown() {
- $_POST = $this->_post;
- }
-
- public function change_photo_test() {
- $controller = new Photos_Controller();
- $root = ORM::factory("item", 1);
- $photo = photo::create($root, DOCROOT . "core/tests/test.jpg", "test.jpeg", "test", "test");
- $orig_name = $photo->name;
-
- $_POST["filename"] = "test.jpeg";
- $_POST["name"] = "new name";
- $_POST["title"] = "new title";
- $_POST["description"] = "new description";
- $_POST["csrf"] = access::csrf_token();
- access::allow(group::everybody(), "edit", $root);
-
- ob_start();
- $controller->_update($photo);
- $results = ob_get_contents();
- ob_end_clean();
-
- $this->assert_equal(
- json_encode(array("result" => "success",
- "location" => "http://./index.php/test.jpeg")),
- $results);
- $this->assert_equal("new title", $photo->title);
- $this->assert_equal("new description", $photo->description);
-
- // We don't change the name, yet.
- $this->assert_equal($orig_name, $photo->name);
- }
-
- public function change_photo_no_csrf_fails_test() {
- $controller = new Photos_Controller();
- $root = ORM::factory("item", 1);
- $photo = photo::create($root, DOCROOT . "core/tests/test.jpg", "test", "test", "test");
- $_POST["name"] = "new name";
- $_POST["title"] = "new title";
- $_POST["description"] = "new description";
- access::allow(group::everybody(), "edit", $root);
-
- try {
- $controller->_update($photo);
- $this->assert_true(false, "This should fail");
- } catch (Exception $e) {
- // pass
- }
- }
-}
diff --git a/core/tests/REST_Controller_Test.php b/core/tests/REST_Controller_Test.php
deleted file mode 100644
index 8fb04d86..00000000
--- a/core/tests/REST_Controller_Test.php
+++ /dev/null
@@ -1,197 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class REST_Controller_Test extends Unit_Test_Case {
- public function setup() {
- $this->_post = $_POST;
- $this->mock_controller = new Mock_RESTful_Controller("mock");
- $this->mock_not_loaded_controller = new Mock_RESTful_Controller("mock_not_loaded");
- $_POST = array();
- }
-
- public function teardown() {
- $_POST = $this->_post;
- }
-
- public function dispatch_index_test() {
- $_SERVER["REQUEST_METHOD"] = "GET";
- $_POST["_method"] = "";
- $this->mock_controller->__call("index", "");
- $this->assert_equal("index", $this->mock_controller->method_called);
- }
-
- public function dispatch_show_test() {
- $_SERVER["REQUEST_METHOD"] = "GET";
- $_POST["_method"] = "";
- $this->mock_controller->__call("3", "");
- $this->assert_equal("show", $this->mock_controller->method_called);
- $this->assert_equal("Mock_Model", get_class($this->mock_controller->resource));
- }
-
- public function dispatch_update_test() {
- $_SERVER["REQUEST_METHOD"] = "POST";
- $_POST["_method"] = "PUT";
- $_POST["csrf"] = access::csrf_token();
- $this->mock_controller->__call("3", "");
- $this->assert_equal("update", $this->mock_controller->method_called);
- $this->assert_equal("Mock_Model", get_class($this->mock_controller->resource));
- }
-
- public function dispatch_update_fails_without_csrf_test() {
- $_SERVER["REQUEST_METHOD"] = "POST";
- $_POST["_method"] = "PUT";
- try {
- $this->mock_controller->__call("3", "");
- $this->assert_false(true, "this should fail with a forbidden exception");
- } catch (Exception $e) {
- // pass
- }
- }
-
- public function dispatch_delete_test() {
- $_SERVER["REQUEST_METHOD"] = "POST";
- $_POST["_method"] = "DELETE";
- $_POST["csrf"] = access::csrf_token();
- $this->mock_controller->__call("3", "");
- $this->assert_equal("delete", $this->mock_controller->method_called);
- $this->assert_equal("Mock_Model", get_class($this->mock_controller->resource));
- }
-
- public function dispatch_delete_fails_without_csrf_test() {
- $_SERVER["REQUEST_METHOD"] = "POST";
- $_POST["_method"] = "DELETE";
- try {
- $this->mock_controller->__call("3", "");
- $this->assert_false(true, "this should fail with a forbidden exception");
- } catch (Exception $e) {
- // pass
- }
- }
-
- public function dispatch_404_test() {
- /* The dispatcher should throw a 404 if the resource isn't loaded and the method isn't POST. */
- $methods = array(
- array("GET", ""),
- array("POST", "PUT"),
- array("POST", "DELETE"));
-
- foreach ($methods as $method) {
- $_SERVER["REQUEST_METHOD"] = $method[0];
- $_POST["_method"] = $method[1];
- $exception_caught = false;
- try {
- $this->mock_not_loaded_controller->__call(rand(), "");
- } catch (Kohana_404_Exception $e) {
- $exception_caught = true;
- }
- $this->assert_true($exception_caught, "$method[0], $method[1]");
- }
- }
-
- public function dispatch_create_test() {
- $_SERVER["REQUEST_METHOD"] = "POST";
- $_POST["_method"] = "";
- $_POST["csrf"] = access::csrf_token();
- $this->mock_not_loaded_controller->__call("", "");
- $this->assert_equal("create", $this->mock_not_loaded_controller->method_called);
- $this->assert_equal(
- "Mock_Not_Loaded_Model", get_class($this->mock_not_loaded_controller->resource));
- }
-
- public function dispatch_create_fails_without_csrf_test() {
- $_SERVER["REQUEST_METHOD"] = "POST";
- $_POST["_method"] = "";
- try {
- $this->mock_not_loaded_controller->__call("", "");
- $this->assert_false(true, "this should fail with a forbidden exception");
- } catch (Exception $e) {
- // pass
- }
- }
-
- public function dispatch_form_test_add() {
- $this->mock_controller->form_add("args");
- $this->assert_equal("form_add", $this->mock_controller->method_called);
- $this->assert_equal("args", $this->mock_controller->resource);
- }
-
- public function dispatch_form_test_edit() {
- $this->mock_controller->form_edit("1");
- $this->assert_equal("form_edit", $this->mock_controller->method_called);
- $this->assert_equal("Mock_Model", get_class($this->mock_controller->resource));
- }
-
- public function routes_test() {
- $this->assert_equal("mock/form_add/args", router::routed_uri("form/add/mock/args"));
- $this->assert_equal("mock/form_edit/args", router::routed_uri("form/edit/mock/args"));
- $this->assert_equal(null, router::routed_uri("rest/args"));
- }
-}
-
-class Mock_RESTful_Controller extends REST_Controller {
- public $method_called;
- public $resource;
-
- public function __construct($type) {
- $this->resource_type = $type;
- parent::__construct();
- }
-
- public function _index() {
- $this->method_called = "index";
- }
-
- public function _create($resource) {
- $this->method_called = "create";
- $this->resource = $resource;
- }
-
- public function _show($resource) {
- $this->method_called = "show";
- $this->resource = $resource;
- }
-
- public function _update($resource) {
- $this->method_called = "update";
- $this->resource = $resource;
- }
-
- public function _delete($resource) {
- $this->method_called = "delete";
- $this->resource = $resource;
- }
-
- public function _form_add($args) {
- $this->method_called = "form_add";
- $this->resource = $args;
- }
-
- public function _form_edit($resource) {
- $this->method_called = "form_edit";
- $this->resource = $resource;
- }
-}
-
-class Mock_Model {
- public $loaded = true;
-}
-
-class Mock_Not_Loaded_Model {
- public $loaded = false;
-}
diff --git a/core/tests/REST_Helper_Test.php b/core/tests/REST_Helper_Test.php
deleted file mode 100644
index 1bfc63ab..00000000
--- a/core/tests/REST_Helper_Test.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class REST_Helper_Test extends Unit_Test_Case {
- public function setup() {
- $this->_post = $_POST;
- }
-
- public function teardown() {
- $_POST = $this->_post;
- }
-
- public function request_method_test() {
- foreach (array("GET", "POST") as $method) {
- foreach (array("", "PUT", "DELETE") as $tunnel) {
- if ($method == "GET") {
- $expected = "GET";
- } else {
- $expected = $tunnel == "" ? $method : $tunnel;
- }
- $_SERVER["REQUEST_METHOD"] = $method;
- $_POST["_method"] = $tunnel;
-
- $this->assert_equal(strtolower(rest::request_method()), strtolower($expected),
- "Request method: {$method}, tunneled: {$tunnel}");
- }
- }
- }
-}
diff --git a/core/tests/Sendmail_Test.php b/core/tests/Sendmail_Test.php
deleted file mode 100644
index 64c1fff0..00000000
--- a/core/tests/Sendmail_Test.php
+++ /dev/null
@@ -1,115 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Sendmail_Test extends Unit_Test_Case {
- public function setup() {
- $config = Kohana::config("sendmail");
- $config["from"] = "from@gallery3.com";
- Kohana::config_set("sendmail", $config);
- }
-
- public function sendmail_test() {
- $expected = "To: receiver@someemail.com\r\n" .
- "From: from@gallery3.com\n" .
- "Reply-To: public@gallery3.com\r\n" .
- "Subject: Test Email Unit test\r\n\r\n" .
- "The mail message body";
- $result = Sendmail_For_Test::factory()
- ->to("receiver@someemail.com")
- /*
- * @todo figure out why this test fails so badly, when the following
- * line is not supplied. It doesn't seem to be set by setup method
- * as you would expect.
- */
- ->from("from@gallery3.com")
- ->subject("Test Email Unit test")
- ->message("The mail message body")
- ->send()
- ->send_text;
-
- $this->assert_equal($expected, $result);
- }
-
- public function sendmail_reply_to_test() {
- $expected = "To: receiver@someemail.com\r\n" .
- "From: from@gallery3.com\n" .
- "Reply-To: reply-to@gallery3.com\r\n" .
- "Subject: Test Email Unit test\r\n\r\n" .
- "The mail message body";
- $result = Sendmail_For_Test::factory()
- ->to("receiver@someemail.com")
- ->subject("Test Email Unit test")
- ->reply_to("reply-to@gallery3.com")
- ->message("The mail message body")
- ->send()
- ->send_text;
- $this->assert_equal($expected, $result);
- }
-
- public function sendmail_html_message_test() {
- $expected = "To: receiver@someemail.com\r\n" .
- "From: from@gallery3.com\n" .
- "Reply-To: public@gallery3.com\n" .
- "MIME-Version: 1.0\n" .
- "Content-type: text/html; charset=iso-8859-1\r\n" .
- "Subject: Test Email Unit test\r\n\r\n" .
- "<html><body><p>This is an html msg</p></body></html>";
- $result = Sendmail_For_Test::factory()
- ->to("receiver@someemail.com")
- ->subject("Test Email Unit test")
- ->header("MIME-Version", "1.0")
- ->header("Content-type", "text/html; charset=iso-8859-1")
- ->message("<html><body><p>This is an html msg</p></body></html>")
- ->send()
- ->send_text;
- $this->assert_equal($expected, $result);
- }
-
- public function sendmail_wrapped_message_test() {
- $expected = "To: receiver@someemail.com\r\n" .
- "From: from@gallery3.com\n" .
- "Reply-To: public@gallery3.com\r\n" .
- "Subject: Test Email Unit test\r\n\r\n" .
- "This is a long message that needs to go\n" .
- "over forty characters If we get lucky we\n" .
- "might make it long enought to wrap a\n" .
- "couple of times.";
- $result = Sendmail_For_Test::factory()
- ->to("receiver@someemail.com")
- ->subject("Test Email Unit test")
- ->line_length(40)
- ->message("This is a long message that needs to go over forty characters " .
- "If we get lucky we might make it long enought to wrap a couple " .
- "of times.")
- ->send()
- ->send_text;
- $this->assert_equal($expected, $result);
- }
-}
-
-class Sendmail_For_Test extends Sendmail {
- static function factory() {
- return new Sendmail_For_Test();
- }
-
- public function mail($to, $subject, $message, $headers) {
- $this->send_text = "To: $to\r\n{$headers}\r\nSubject: $this->subject\r\n\r\n$message";
- return true;
- }
-} \ No newline at end of file
diff --git a/core/tests/Var_Test.php b/core/tests/Var_Test.php
deleted file mode 100644
index 82370631..00000000
--- a/core/tests/Var_Test.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2009 Bharat Mediratta
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
- */
-class Var_Test extends Unit_Test_Case {
- public function add_parameter_test() {
- module::set_var("core", "Parameter", "original value");
- $this->assert_equal("original value", module::get_var("core", "Parameter"));
-
- module::set_var("core", "Parameter", "updated value");
- $this->assert_equal("updated value", module::get_var("core", "Parameter"));
- }
-
- public function clear_parameter_test() {
- module::set_var("core", "Parameter", "original value");
- $this->assert_equal("original value", module::get_var("core", "Parameter"));
-
- module::clear_var("core", "Parameter");
- $this->assert_equal(null, module::get_var("core", "Parameter"));
- }
-
- public function incr_parameter_test() {
- module::set_var("core", "Parameter", "original value");
- module::incr_var("core", "Parameter");
- $this->assert_equal("1", module::get_var("core", "Parameter"));
-
- module::set_var("core", "Parameter", "2");
- module::incr_var("core", "Parameter", "9");
- $this->assert_equal("11", module::get_var("core", "Parameter"));
-
- module::incr_var("core", "NonExistent", "9");
- $this->assert_equal(null, module::get_var("core", "NonExistent"));
- }
-} \ No newline at end of file
diff --git a/core/tests/images/DSC_0003.jpg b/core/tests/images/DSC_0003.jpg
deleted file mode 100644
index 5780d9d8..00000000
--- a/core/tests/images/DSC_0003.jpg
+++ /dev/null
Binary files differ
diff --git a/core/tests/images/DSC_0005.jpg b/core/tests/images/DSC_0005.jpg
deleted file mode 100644
index 4d2b53a9..00000000
--- a/core/tests/images/DSC_0005.jpg
+++ /dev/null
Binary files differ
diff --git a/core/tests/images/DSC_0017.jpg b/core/tests/images/DSC_0017.jpg
deleted file mode 100644
index b7f7bb90..00000000
--- a/core/tests/images/DSC_0017.jpg
+++ /dev/null
Binary files differ
diff --git a/core/tests/images/DSC_0019.jpg b/core/tests/images/DSC_0019.jpg
deleted file mode 100644
index 0ce25aa4..00000000
--- a/core/tests/images/DSC_0019.jpg
+++ /dev/null
Binary files differ
diff --git a/core/tests/images/DSC_0067.jpg b/core/tests/images/DSC_0067.jpg
deleted file mode 100644
index 84f134cb..00000000
--- a/core/tests/images/DSC_0067.jpg
+++ /dev/null
Binary files differ
diff --git a/core/tests/images/DSC_0072.jpg b/core/tests/images/DSC_0072.jpg
deleted file mode 100644
index dfad82b0..00000000
--- a/core/tests/images/DSC_0072.jpg
+++ /dev/null
Binary files differ
diff --git a/core/tests/images/P4050088.jpg b/core/tests/images/P4050088.jpg
deleted file mode 100644
index 62f4749d..00000000
--- a/core/tests/images/P4050088.jpg
+++ /dev/null
Binary files differ
diff --git a/core/tests/selenium/Add_Album.html b/core/tests/selenium/Add_Album.html
deleted file mode 100644
index ccd4d0b7..00000000
--- a/core/tests/selenium/Add_Album.html
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>AddAlbum</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">AddAlbum</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/index.php/albums/1</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>link=Add album</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>name</td>
- <td>seleniumtest</td>
-</tr>
-<tr>
- <td>type</td>
- <td>title</td>
- <td>Selenium Test Album</td>
-</tr>
-<tr>
- <td>type</td>
- <td>description</td>
- <td>Test</td>
-</tr>
-<tr>
- <td>click</td>
- <td>//button[@type='button']</td>
- <td></td>
-</tr>
-<tr>
- <td>assertTextPresent</td>
- <td>Selenium Test Album</td>
- <td></td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/core/tests/selenium/Add_Comment.html b/core/tests/selenium/Add_Comment.html
deleted file mode 100644
index b4b96ed2..00000000
--- a/core/tests/selenium/Add_Comment.html
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>Add comment</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">Add comment</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/index.php/albums/1</td>
- <td></td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>gPhotoId-2</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>gAuthor</td>
- <td>Test</td>
-</tr>
-<tr>
- <td>type</td>
- <td>gEmail</td>
- <td>test@gmail.com</td>
-</tr>
-<tr>
- <td>type</td>
- <td>gText</td>
- <td>This is a selenium test comment.</td>
-</tr>
-<tr>
- <td>click</td>
- <td>//button[@type='submit']</td>
- <td></td>
-</tr>
-<tr>
- <td>assertTextPresent</td>
- <td>This is a selenium test comment.</td>
- <td></td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/core/tests/selenium/Add_Item.html b/core/tests/selenium/Add_Item.html
deleted file mode 100644
index 741dff65..00000000
--- a/core/tests/selenium/Add_Item.html
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>AddItem</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">AddItem</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/index.php/albums/1</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>link=Add an item</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>name</td>
- <td>seleniumitem.jpg</td>
-</tr>
-<tr>
- <td>type</td>
- <td>title</td>
- <td>Selenium Item</td>
-</tr>
-<tr>
- <td>type</td>
- <td>description</td>
- <td>Test item</td>
-</tr>
-<tr>
- <td>type</td>
- <td>file</td>
- <td>/Users/ckieffer/Sites/gallery3.0/core/tests/images/DSC_0003.jpg</td>
-</tr>
-<tr>
- <td>click</td>
- <td>//button[@type='button']</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>link=X</td>
- <td></td>
-</tr>
-<tr>
- <td>assertTextPresent</td>
- <td>Selenium Item</td>
- <td></td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/core/tests/selenium/Login.html b/core/tests/selenium/Login.html
deleted file mode 100644
index 5e17a3c7..00000000
--- a/core/tests/selenium/Login.html
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>Login</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">Login</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/index.php/albums/1</td>
- <td></td>
-</tr>
-<tr>
- <td>click</td>
- <td>gLoginLink</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>gName</td>
- <td>admin</td>
-</tr>
-<tr>
- <td>type</td>
- <td>gPassword</td>
- <td>admin</td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>//button[@type='button']</td>
- <td></td>
-</tr>
-<tr>
- <td>clickAndWait</td>
- <td>gUserProfileLink</td>
- <td></td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/core/tests/test.jpg b/core/tests/test.jpg
deleted file mode 100644
index 1f3525e5..00000000
--- a/core/tests/test.jpg
+++ /dev/null
Binary files differ