summaryrefslogtreecommitdiff
path: root/modules/gallery/tests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/tests')
-rw-r--r--modules/gallery/tests/Access_Helper_Test.php22
-rw-r--r--modules/gallery/tests/Album_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Albums_Controller_Test.php13
-rw-r--r--modules/gallery/tests/Cache_Test.php79
-rw-r--r--modules/gallery/tests/Database_Test.php153
-rw-r--r--modules/gallery/tests/DrawForm_Test.php50
-rw-r--r--modules/gallery/tests/File_Structure_Test.php20
-rw-r--r--modules/gallery/tests/Gallery_I18n_Test.php (renamed from modules/gallery/tests/I18n_Test.php)10
-rw-r--r--modules/gallery/tests/Gallery_Installer_Test.php4
-rw-r--r--modules/gallery/tests/Gallery_Rest_Helper_Test.php277
-rw-r--r--modules/gallery/tests/Item_Helper_Test.php4
-rw-r--r--modules/gallery/tests/Item_Model_Test.php15
-rw-r--r--modules/gallery/tests/ORM_MPTT_Test.php8
-rw-r--r--modules/gallery/tests/Photo_Helper_Test.php13
-rw-r--r--modules/gallery/tests/Photos_Controller_Test.php3
-rw-r--r--modules/gallery/tests/Sendmail_Test.php4
-rw-r--r--modules/gallery/tests/controller_auth_data.txt7
-rw-r--r--modules/gallery/tests/xss_data.txt23
18 files changed, 528 insertions, 179 deletions
diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php
index e9e5cb26..084bfb47 100644
--- a/modules/gallery/tests/Access_Helper_Test.php
+++ b/modules/gallery/tests/Access_Helper_Test.php
@@ -76,7 +76,7 @@ class Access_Helper_Test extends Unit_Test_Case {
access::deny(identity::registered_users(), "view", $item);
$user = identity::create_user("access_test", "Access Test", "");
- foreach ($user->groups as $group) {
+ foreach ($user->groups() as $group) {
$user->remove($group);
}
$user->add($access_test);
@@ -93,7 +93,7 @@ class Access_Helper_Test extends Unit_Test_Case {
access::deny(identity::registered_users(), "view", $item);
$user = identity::create_user("access_test", "Access Test", "");
- foreach ($user->groups as $group) {
+ foreach ($user->groups() as $group) {
$user->remove($group);
}
$user->save();
@@ -106,15 +106,15 @@ class Access_Helper_Test extends Unit_Test_Case {
$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);
+ $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);
+ $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() {
@@ -131,7 +131,7 @@ class Access_Helper_Test extends Unit_Test_Case {
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();
+ $intent = ORM::factory("access_intent")->where("item_id", "=", $album->id)->find();
// Allow
access::allow(identity::everybody(), "view", $album);
@@ -141,19 +141,19 @@ class Access_Helper_Test extends Unit_Test_Case {
access::deny(identity::everybody(), "view", $album);
$this->assert_same(
access::DENY,
- ORM::factory("access_intent")->where("item_id", $album)->find()->view_1);
+ ORM::factory("access_intent")->where("item_id", "=", $album->id)->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(identity::everybody(), "view", $album);
$this->assert_same(
access::ALLOW,
- ORM::factory("access_intent")->where("item_id", $album)->find()->view_1);
+ ORM::factory("access_intent")->where("item_id", "=", $album->id)->find()->view_1);
access::reset(identity::everybody(), "view", $album);
$this->assert_same(
null,
- ORM::factory("access_intent")->where("item_id", $album)->find()->view_1);
+ ORM::factory("access_intent")->where("item_id", "=", $album->id)->find()->view_1);
}
public function cant_reset_root_item_test() {
@@ -288,7 +288,7 @@ class Access_Helper_Test extends Unit_Test_Case {
public function i_can_edit_test() {
// Create a new user that belongs to no groups
$user = identity::create_user("access_test", "Access Test", "");
- foreach ($user->groups as $group) {
+ foreach ($user->groups() as $group) {
$user->remove($group);
}
$user->save();
diff --git a/modules/gallery/tests/Album_Helper_Test.php b/modules/gallery/tests/Album_Helper_Test.php
index 2080ef30..1284b8cc 100644
--- a/modules/gallery/tests/Album_Helper_Test.php
+++ b/modules/gallery/tests/Album_Helper_Test.php
@@ -57,7 +57,7 @@ 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/resizes/$rand/.album.jpg", $album->resize_url());
+ $this->assert_equal("http://./var/resizes/$rand/.album.jpg?m={$album->updated}", $album->resize_url());
}
public function create_album_shouldnt_allow_names_with_slash_test() {
diff --git a/modules/gallery/tests/Albums_Controller_Test.php b/modules/gallery/tests/Albums_Controller_Test.php
index 5f23f821..4d8935cd 100644
--- a/modules/gallery/tests/Albums_Controller_Test.php
+++ b/modules/gallery/tests/Albums_Controller_Test.php
@@ -20,7 +20,6 @@
class Albums_Controller_Test extends Unit_Test_Case {
public function setup() {
$this->_save = array($_POST, $_SERVER);
- $_SERVER["HTTP_REFERER"] = "HTTP_REFERER";
}
public function teardown() {
@@ -36,8 +35,10 @@ class Albums_Controller_Test extends Unit_Test_Case {
$this->_album = album::create($root, "test", "test", "test");
$orig_name = $this->_album->name;
- $_POST["dirname"] = "test";
- $_POST["name"] = "new name";
+ // Randomize to avoid conflicts.
+ $new_dirname = "new_name_" . rand();
+
+ $_POST["dirname"] = $new_dirname;
$_POST["title"] = "new title";
$_POST["description"] = "new description";
$_POST["column"] = "weight";
@@ -53,13 +54,11 @@ class Albums_Controller_Test extends Unit_Test_Case {
ob_end_clean();
$this->assert_equal(
- json_encode(array("result" => "success", "location" => "HTTP_REFERER")),
+ json_encode(array("result" => "success")),
$results);
+ $this->assert_equal($new_dirname, $this->_album->name);
$this->assert_equal("new title", $this->_album->title);
$this->assert_equal("new description", $this->_album->description);
-
- // We don't change the name, yet.
- $this->assert_equal($orig_name, $this->_album->name);
}
public function change_album_no_csrf_fails_test() {
diff --git a/modules/gallery/tests/Cache_Test.php b/modules/gallery/tests/Cache_Test.php
index 6b525265..d5bf37cc 100644
--- a/modules/gallery/tests/Cache_Test.php
+++ b/modules/gallery/tests/Cache_Test.php
@@ -20,88 +20,83 @@
class Cache_Test extends Unit_Test_Case {
private $_driver;
public function setup() {
- Database::instance()->from("caches")->where(1)->delete();
+ db::build()->delete("caches")->execute();
$this->_driver = new Cache_Database_Driver();
}
public function cache_exists_test() {
- $db = Database::instance();
-
$this->assert_false($this->_driver->exists("test_key"), "test_key should not be defined");
$id = md5(rand());
- $db->insert("caches", array("key" => $id, "tags" => "<tag1>, <tag2>",
- "expiration" => 84600 + time(),
- "cache" => serialize("some test data")));
+ db::build()
+ ->insert("caches")
+ ->columns("key", "tags", "expiration", "cache")
+ ->values($id, "<tag1>, <tag2>", 84600 + time(), serialize("some test data"))
+ ->execute();
$this->assert_true($this->_driver->exists($id), "test_key should be defined");
}
public function cache_get_test() {
- $db = Database::instance();
-
$id = md5(rand());
- $db->insert("caches", array("key" => $id, "tags" => "<tag1>, <tag2>",
- "expiration" => 84600 + time(),
- "cache" => serialize("some test data")));
- $data = $this->_driver->get($id);
+ db::build()
+ ->insert("caches")
+ ->columns("key", "tags", "expiration", "cache")
+ ->values($id, "<tag1>, <tag2>", 84600 + time(), serialize("some test data"))
+ ->execute();
+
+ $data = $this->_driver->get(array($id));
$this->assert_equal("some test data", $data, "cached data should match");
- $data = $this->_driver->get("");
+ $data = $this->_driver->get(array(""));
$this->assert_equal(null, $data, "cached data should not be found");
}
public function cache_set_test() {
- $db = Database::instance();
-
$id = md5(rand());
$original_data = array("field1" => "value1", "field2" => "value2");
- $this->_driver->set($id, $original_data, array("tag1", "tag2"), 84600);
+ $this->_driver->set(array($id => $original_data), array("tag1", "tag2"), 84600);
- $data = $this->_driver->get($id);
+ $data = $this->_driver->get(array($id));
$this->assert_equal($original_data, $data, "cached data should match");
}
- public function cache_find_test() {
- $db = Database::instance();
-
+ public function cache_get_tag_test() {
$id1 = md5(rand());
$value1 = array("field1" => "value1", "field2" => "value2");
- $this->_driver->set($id1, $value1, array("tag1", "tag2"), 84600);
+ $this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), 84600);
$id2 = md5(rand());
$value2 = array("field3" => "value3", "field4" => "value4");
- $this->_driver->set($id2, $value2, array("tag2", "tag3"), 84600);
+ $this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), 84600);
$id3 = md5(rand());
$value3 = array("field5" => "value5", "field6" => "value6");
- $this->_driver->set($id3, $value3, array("tag3", "tag4"), 84600);
+ $this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), 84600);
- $data = $this->_driver->find("tag2");
+ $data = $this->_driver->get_tag(array("tag2"));
$expected = array($id1 => $value1, $id2 => $value2);
ksort($expected);
$this->assert_equal($expected, $data, "Expected id1 & id2");
- $data = $this->_driver->find("tag4");
+ $data = $this->_driver->get_tag(array("tag4"));
$this->assert_equal(array($id3 => $value3), $data, "Expected id3");
}
public function cache_delete_expired_test() {
- $db = Database::instance();
-
$id1 = md5(rand());
$value1 = array("field1" => "value1", "field2" => "value2");
- $this->_driver->set($id1, $value1, array("tag1", "tag2"), -84600);
+ $this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), -84600);
$id2 = md5(rand());
$value2 = array("field3" => "value3", "field4" => "value4");
- $this->_driver->set($id2, $value2, array("tag2", "tag3"), -846000);
+ $this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), -846000);
$id3 = md5(rand());
$value3 = array("field5" => "value5", "field6" => "value6");
- $this->_driver->set($id3, $value3, array("tag3", "tag4"), -84600);
+ $this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), -84600);
$data = $this->_driver->delete_expired();
@@ -111,19 +106,17 @@ class Cache_Test extends Unit_Test_Case {
}
public function cache_delete_id_test() {
- $db = Database::instance();
-
$id1 = md5(rand());
$value1 = array("field1" => "value1", "field2" => "value2");
- $this->_driver->set($id1, $value1, array("tag1", "tag2"), 84600);
+ $this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), 84600);
$id2 = md5(rand());
$value2 = array("field3" => "value3", "field4" => "value4");
- $this->_driver->set($id2, $value2, array("tag2", "tag3"), 846000);
+ $this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), 846000);
$id3 = md5(rand());
$value3 = array("field5" => "value5", "field6" => "value6");
- $this->_driver->set($id3, $value3, array("tag3", "tag4"), 84600);
+ $this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), 84600);
$this->_driver->delete($id1);
@@ -133,19 +126,17 @@ class Cache_Test extends Unit_Test_Case {
}
public function cache_delete_tag_test() {
- $db = Database::instance();
-
$id1 = md5(rand());
$value1 = array("field1" => "value1", "field2" => "value2");
- $this->_driver->set($id1, $value1, array("tag1", "tag2"), 84600);
+ $this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), 84600);
$id2 = md5(rand());
$value2 = array("field3" => "value3", "field4" => "value4");
- $this->_driver->set($id2, $value2, array("tag2", "tag3"), 846000);
+ $this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), 846000);
$id3 = md5(rand());
$value3 = array("field5" => "value5", "field6" => "value6");
- $this->_driver->set($id3, $value3, array("tag3", "tag4"), 84600);
+ $this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), 84600);
$data = $this->_driver->delete("tag3", true);
@@ -155,19 +146,17 @@ class Cache_Test extends Unit_Test_Case {
}
public function cache_delete_all_test() {
- $db = Database::instance();
-
$id1 = md5(rand());
$value1 = array("field1" => "value1", "field2" => "value2");
- $this->_driver->set($id1, $value1, array("tag1", "tag2"), 84600);
+ $this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), 84600);
$id2 = md5(rand());
$value2 = array("field3" => "value3", "field4" => "value4");
- $this->_driver->set($id2, $value2, array("tag2", "tag3"), 846000);
+ $this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), 846000);
$id3 = md5(rand());
$value3 = array("field5" => "value5", "field6" => "value6");
- $this->_driver->set($id3, $value3, array("tag3", "tag4"), 84600);
+ $this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), 84600);
$data = $this->_driver->delete(true);
diff --git a/modules/gallery/tests/Database_Test.php b/modules/gallery/tests/Database_Test.php
index 98bd4046..6aa186e5 100644
--- a/modules/gallery/tests/Database_Test.php
+++ b/modules/gallery/tests/Database_Test.php
@@ -18,81 +18,95 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Database_Test extends Unit_Test_Case {
+ function setup() {
+ $config = Kohana_Config::instance();
+ $config->set("database.mock.connection.type", "mock");
+ $config->set("database.mock.cache", false);
+ $config->set("database.mock.table_prefix", "g_");
+ }
+
function simple_where_test() {
- $sql = Database::instance()
- ->where("a", 1)
- ->where("b", 2)
+ $sql = db::build("mock")
+ ->select("some_column")
+ ->from("some_table")
+ ->where("a", "=", 1)
+ ->where("b", "=", 2)
->compile();
$sql = str_replace("\n", " ", $sql);
- $this->assert_same("SELECT * WHERE `a` = 1 AND `b` = 2", $sql);
+ $this->assert_same("SELECT [some_column] FROM [some_table] 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)
+ $sql = db::build("mock")
+ ->select()
+ ->where("outer1", "=", 1)
+ ->and_open()
+ ->where("inner1", "=", 1)
+ ->or_where("inner2", "=", 2)
+ ->close()
+ ->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",
+ "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)
+ $sql = db::build("mock")
+ ->select()
+ ->and_open()
+ ->where("inner1", "=", 1)
+ ->or_where("inner2", "=", 2)
+ ->close()
+ ->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",
+ "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()
+ $sql = db::build("mock")
+ ->select()
+ ->where("outer1", "=", 1)
+ ->and_open()
+ ->where("inner1", "=", 1)
+ ->or_where("inner2", "=", 2)
+ ->or_where("inner3", "=", 3)
+ ->close()
->compile();
$sql = str_replace("\n", " ", $sql);
$this->assert_same(
- "SELECT * WHERE `outer1` = 1 AND (`inner1` = 1 OR `inner2` = 2 OR `inner3` = 3)",
+ "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()
+ $sql = db::build("mock")
+ ->select()
+ ->where("outer1", "=", 1)
+ ->or_open()
+ ->where("inner1", "NOT LIKE", "%1%")
+ ->close()
->compile();
$sql = str_replace("\n", " ", $sql);
$this->assert_same(
- "SELECT * WHERE `outer1` = 1 OR ( `inner1` NOT LIKE '%1%')",
+ "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} (
+ $db = Database::instance("mock");
+ $converted = $db->add_table_prefixes("CREATE TABLE IF NOT EXISTS {test} (
`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 (
+ $expected = "CREATE TABLE IF NOT EXISTS g_test (
`id` int(9) NOT NULL auto_increment,
`name` varchar(32) NOT NULL,
PRIMARY KEY (`id`),
@@ -100,16 +114,16 @@ class Database_Test extends Unit_Test_Case {
ENGINE=InnoDB DEFAULT CHARSET=utf8";
$this->assert_same($expected, $converted);
- $sql = "UPDATE {test_tables} SET `name` = '{test string}' " .
+ $sql = "UPDATE {test} SET `name` = '{test string}' " .
"WHERE `item_id` IN " .
- " (SELECT `id` FROM {items} " .
+ " (SELECT `id` FROM {test} " .
" WHERE `left_ptr` >= 1 " .
" AND `right_ptr` <= 6)";
$sql = $db->add_table_prefixes($sql);
- $expected = "UPDATE g3test_test_tables SET `name` = '{test string}' " .
+ $expected = "UPDATE g_test SET `name` = '{test string}' " .
"WHERE `item_id` IN " .
- " (SELECT `id` FROM g3test_items " .
+ " (SELECT `id` FROM g_test " .
" WHERE `left_ptr` >= 1 " .
" AND `right_ptr` <= 6)";
@@ -117,29 +131,52 @@ class Database_Test extends Unit_Test_Case {
}
function prefix_no_replacement_test() {
- $update = Database_For_Test::instance()->from("test_tables")
- ->where("1 = 1")
+ $sql = db::build("mock")
+ ->from("test_tables")
+ ->where("1", "=", "1")
->set(array("name" => "Test Name"))
- ->update();
+ ->update()
+ ->compile();
+ $sql = str_replace("\n", " ", $sql);
+ $this->assert_same("UPDATE [test_tables] SET [name] = [Test Name] WHERE [1] = [1]", $sql);
+ }
+}
- $expected = "UPDATE `g3test_test_tables` SET `name` = 'Test Name' WHERE 1 = 1";
+class Database_Mock extends Database {
+ public function connect() {
+ }
- $this->assert_same($expected, $update);
+ public function disconnect() {
}
-}
-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;
+ public function set_charset($charset) {
}
- public function query($sql = '') {
- if (!empty($sql)) {
- $sql = $this->add_table_prefixes($sql);
- }
- return $sql;
+ public function query_execute($sql) {
}
-}
+
+ public function escape($val) {
+ }
+
+ public function list_constraints($table) {
+ }
+
+ public function list_fields($table) {
+ }
+
+ public function list_tables() {
+ return array("test");
+ }
+
+ public function quote_column($val) {
+ return "[$val]";
+ }
+
+ public function quote_table($val) {
+ return "[$val]";
+ }
+
+ public function quote($val) {
+ return "[$val]";
+ }
+} \ No newline at end of file
diff --git a/modules/gallery/tests/DrawForm_Test.php b/modules/gallery/tests/DrawForm_Test.php
index 7ee80ca2..da8a6b04 100644
--- a/modules/gallery/tests/DrawForm_Test.php
+++ b/modules/gallery/tests/DrawForm_Test.php
@@ -23,28 +23,28 @@ class DrawForm_Test extends Unit_Test_Case {
$form->input("title")->label(t("Title"));
$form->textarea("description")->label(t("Text Area"));
$form->submit("")->value(t("Submit"));
- $rendered = $form->__toString();
+ $csrf = access::csrf_token();
$expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " .
"id=\"g-test-group-form\">\n" .
- "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" .
+ "<input type=\"hidden\" name=\"csrf\" value=\"$csrf\" />" .
" <ul>\n" .
" <li>\n" .
" <label for=\"title\" >Title</label>\n" .
- " <input type=\"text\" id=\"title\" name=\"title\" value=\"\" " .
+ " <input type=\"text\" name=\"title\" value=\"\" " .
"class=\"textbox\" />\n" .
" </li>\n" .
" <li>\n" .
" <label for=\"description\" >Text Area</label>\n" .
- " <textarea id=\"description\" name=\"description\" " .
+ " <textarea name=\"description\" rows=\"\" cols=\"\" " .
"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);
+ "</form>";
+ $this->assert_same($expected, (string) $form);
}
function group_test() {
@@ -53,22 +53,22 @@ class DrawForm_Test extends Unit_Test_Case {
$group->input("title")->label(t("Title"));
$group->textarea("description")->label(t("Text Area"));
$group->submit("")->value(t("Submit"));
- $rendered = $form->__toString();
+ $csrf = access::csrf_token();
$expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " .
"id=\"g-test-group-form\">\n" .
- "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" .
+ "<input type=\"hidden\" name=\"csrf\" value=\"$csrf\" />" .
" <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=\"\" " .
+ " <input type=\"text\" name=\"title\" value=\"\" " .
"class=\"textbox\" />\n" .
" </li>\n" .
" <li>\n" .
" <label for=\"description\" >Text Area</label>\n" .
- " <textarea id=\"description\" name=\"description\" " .
+ " <textarea name=\"description\" rows=\"\" cols=\"\" " .
"class=\"textarea\" ></textarea>\n" .
" </li>\n" .
" <li>\n" .
@@ -76,8 +76,8 @@ class DrawForm_Test extends Unit_Test_Case {
" </li>\n" .
" </ul>\n" .
" </fieldset>\n" .
- "</form>\n";
- $this->assert_same($expected, $rendered);
+ "</form>";
+ $this->assert_same($expected, (string) $form);
}
function form_script_test() {
@@ -89,22 +89,22 @@ class DrawForm_Test extends Unit_Test_Case {
->url(url::file("test.js"))
->text("alert('Test Javascript');");
$group->submit("")->value(t("Submit"));
- $rendered = $form->__toString();
+ $csrf = access::csrf_token();
$expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" " .
"id=\"g-test-group-form\">\n" .
- "<input type=\"hidden\" name=\"csrf\" value=\"" . access::csrf_token() . "\" />\n" .
+ "<input type=\"hidden\" name=\"csrf\" value=\"$csrf\" />" .
" <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=\"\" " .
+ " <input type=\"text\" name=\"title\" value=\"\" " .
"class=\"textbox\" />\n" .
" </li>\n" .
" <li>\n" .
" <label for=\"description\" >Text Area</label>\n" .
- " <textarea id=\"description\" name=\"description\" " .
+ " <textarea name=\"description\" rows=\"\" cols=\"\" " .
"class=\"textarea\" ></textarea>\n" .
" </li>\n" .
" <li>\n" .
@@ -116,8 +116,22 @@ class DrawForm_Test extends Unit_Test_Case {
"<script type=\"text/javascript\">\n" .
"alert('Test Javascript');\n" .
"</script>\n" .
- "</form>\n";
- $this->assert_same($expected, $rendered);
+ "</form>";
+ $this->assert_same($expected, (string) $form);
+ }
+
+ function two_hiddens_test() {
+ $form = new Forge("test/controller", "", "post");
+ $form->hidden("HIDDEN_NAME")->value("HIDDEN_VALUE");
+
+ $csrf = access::csrf_token();
+ $expected = "<form action=\"http://./index.php/test/controller\" method=\"post\" class=\"form\">\n" .
+ "<input type=\"hidden\" name=\"csrf\" value=\"$csrf\" />" .
+ "<input type=\"hidden\" name=\"HIDDEN_NAME\" value=\"HIDDEN_VALUE\" />" .
+ " <ul>\n" .
+ " </ul>\n" .
+ "</form>";
+ $this->assert_same($expected, (string) $form);
}
}
diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php
index 36342fda..b5026188 100644
--- a/modules/gallery/tests/File_Structure_Test.php
+++ b/modules/gallery/tests/File_Structure_Test.php
@@ -36,6 +36,10 @@ class File_Structure_Test extends Unit_Test_Case {
$dir = new GalleryCodeFilterIterator(
new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT)));
foreach ($dir as $file) {
+ if (strpos($file, "modules/gallery/views/kohana/error.php")) {
+ continue;
+ }
+
if (strpos($file, "views")) {
$this->assert_true(
preg_match("#/views/.*?(\.html|mrss|txt)\.php$#", $file->getPathname()),
@@ -57,10 +61,12 @@ class File_Structure_Test extends Unit_Test_Case {
}
private function _check_view_preamble($path, &$errors) {
+ $expected_2 = null;
// 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";
+ $expected_2 = "<?php defined('SYSPATH') OR die('No direct access allowed.');\n"; // error.php
} else {
// Gallery preamble
// @todo use the same preamble for both!
@@ -71,26 +77,32 @@ class File_Structure_Test extends Unit_Test_Case {
$actual = fgets($fp);
fclose($fp);
- if ($expected != $actual) {
+ if ($expected != $actual && $expected_2 != $actual) {
$errors[] = "$path:1\n expected:\n\t$expected\n actual:\n\t$actual";
}
}
private function _check_php_preamble($path, &$errors) {
+ $expected_2 = null; $expected_3 = null; $expected_4 = null;
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");
+ $expected = array("<?php defined('SYSPATH') OR die('No direct script access.');\n");
+ $expected_2 = array("<?php defined('SYSPATH') OR die('No direct access allowed.');\n");
+ $expected_3 = array("<?php defined('SYSPATH') or die('No direct access allowed.');\n");
+ $expected_4 = array("<?php defined('SYSPATH') or die('No direct script access.');\n");
} else if (strpos($path, MODPATH . "forge") === 0 ||
strpos($path, MODPATH . "exif/lib") === 0 ||
strpos($path, MODPATH . "gallery/lib/HTMLPurifier") === 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");
+ $expected = array("<?php defined(\"SYSPATH\") or die(\"No direct access allowed.\");\n");
+ $expected_2 = array("<?php defined('SYSPATH') OR die('No direct access allowed.');\n");
+ $expected_3 = array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\");\n");
$fp = fopen($path, "r");
$actual = array(fgets($fp));
fclose($fp);
@@ -131,7 +143,7 @@ class File_Structure_Test extends Unit_Test_Case {
" */",
);
}
- if ($expected != $actual) {
+ if ($expected != $actual && $expected_2 != $actual && $expected_3 != $actual && $expected_4 != $actual) {
$errors[] = "$path:1\n expected\n\t" . join("\n\t", $expected) .
"\n actual:\n\t" . join("\n\t", $actual);
}
diff --git a/modules/gallery/tests/I18n_Test.php b/modules/gallery/tests/Gallery_I18n_Test.php
index 9010606a..895e3051 100644
--- a/modules/gallery/tests/I18n_Test.php
+++ b/modules/gallery/tests/Gallery_I18n_Test.php
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class I18n_Test extends Unit_Test_Case {
+class Gallery_I18n_Test extends Unit_Test_Case {
private $i18n;
public function setup() {
@@ -26,10 +26,10 @@ class I18n_Test extends Unit_Test_Case {
'root_locale' => 'en',
'default_locale' => 'te_ST',
'locale_dir' => VARPATH . 'locale/');
- $this->i18n = I18n::instance($config);
+ $this->i18n = Gallery_I18n::instance($config);
ORM::factory("incoming_translation")
- ->where("locale", "te_ST")
+ ->where("locale", "=", "te_ST")
->delete_all();
$messages_te_ST = array(
@@ -43,7 +43,7 @@ class I18n_Test extends Unit_Test_Case {
foreach ($messages_te_ST as $data) {
list ($message, $translation) = $data;
$entry = ORM::factory("incoming_translation");
- $entry->key = I18n::get_message_key($message);
+ $entry->key = Gallery_I18n::get_message_key($message);
$entry->message = serialize($message);
$entry->translation = serialize($translation);
$entry->locale = 'te_ST';
@@ -62,7 +62,7 @@ class I18n_Test extends Unit_Test_Case {
$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);
diff --git a/modules/gallery/tests/Gallery_Installer_Test.php b/modules/gallery/tests/Gallery_Installer_Test.php
index 36ced2bb..43399fb4 100644
--- a/modules/gallery/tests/Gallery_Installer_Test.php
+++ b/modules/gallery/tests/Gallery_Installer_Test.php
@@ -29,13 +29,13 @@ class Gallery_Installer_Test extends Unit_Test_Case {
}
public function install_registers_gallery_module_test() {
- $gallery = ORM::factory("module")->where("name", "gallery")->find();
+ $gallery = ORM::factory("module")->where("name", "=", "gallery")->find();
$this->assert_equal("gallery", $gallery->name);
}
public function install_creates_root_item_test() {
$max_right_ptr = ORM::factory("item")
- ->select("MAX(`right_ptr`) AS `right_ptr`")
+ ->select(new Database_Expression("MAX(`right_ptr`) AS `right_ptr`"))
->find()->right_ptr;
$root = ORM::factory('item')->find(1);
$this->assert_equal("Gallery", $root->title);
diff --git a/modules/gallery/tests/Gallery_Rest_Helper_Test.php b/modules/gallery/tests/Gallery_Rest_Helper_Test.php
new file mode 100644
index 00000000..cd0aabae
--- /dev/null
+++ b/modules/gallery/tests/Gallery_Rest_Helper_Test.php
@@ -0,0 +1,277 @@
+<?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 Gallery_Rest_Helper_Test extends Unit_Test_Case {
+ public function setup() {
+ $this->_save = array($_GET, $_POST, $_SERVER, $_FILES);
+ $this->_saved_active_user = identity::active_user();
+ }
+
+ public function teardown() {
+ list($_GET, $_POST, $_SERVER, $_FILES) = $this->_save;
+ identity::set_active_user($this->_saved_active_user);
+ if (!empty($this->_user)) {
+ try {
+ $this->_user->delete();
+ } catch (Exception $e) { }
+ }
+ }
+
+ private function _create_user() {
+ if (empty($this->_user)) {
+ $this->_user = identity::create_user("access_test" . rand(), "Access Test", "password");
+ $key = ORM::factory("user_access_token");
+ $key->access_key = md5($this->_user->name . rand());
+ $key->user_id = $this->_user->id;
+ $key->save();
+ identity::set_active_user($this->_user);
+ }
+ return $this->_user;
+ }
+
+ private function _create_album($parent=null) {
+ $album_name = "rest_album_" . rand();
+ if (empty($parent)) {
+ $parent = ORM::factory("item", 1);
+ }
+ return album::create($parent, $album_name, $album_name, $album_name);
+ }
+
+ private function _create_image($parent=null) {
+ $filename = MODPATH . "gallery/tests/test.jpg";
+ $image_name = "rest_image_" . rand();
+ if (empty($parent)) {
+ $parent = ORM::factory("item", 1);
+ }
+ return photo::create($parent, $filename, "$image_name.jpg", $image_name);
+ }
+
+ public function gallery_rest_get_album_test() {
+ $album = $this->_create_album();
+ $child = $this->_create_album($album);
+ $photo = $this->_create_image($child);
+ $child->reload();
+ $request = (object)array("arguments" => explode("/", $child->relative_url()));
+
+ $this->assert_equal(
+ json_encode(array("status" => "OK",
+ "resource" =>
+ array("type" => $child->type,
+ "name" => $child->name,
+ "path" => $child->relative_url(),
+ "parent_path" => $album->relative_url(),
+ "title" => $child->title,
+ "thumb_url" => $child->thumb_url(),
+ "thumb_size" => array("height" => $child->thumb_height,
+ "width" => $child->thumb_width),
+ "resize_url" => $child->resize_url(),
+ "resize_size" => array("height" => 0,
+ "width" => 0),
+ "url" => $child->file_url(),
+ "size" => array("height" => $child->height,
+ "width" => $child->width),
+ "description" => $child->description,
+ "slug" => $child->slug,
+ "children" => array(array(
+ "type" => "photo",
+ "has_children" => false,
+ "path" => $photo->relative_url(),
+ "thumb_url" => $photo->thumb_url(),
+ "thumb_dimensions" => array(
+ "width" => $photo->thumb_width,
+ "height" => $photo->thumb_height),
+ "has_thumb" => true,
+ "title" => $photo->title))))),
+ gallery_rest::get($request));
+ }
+
+ public function gallery_rest_get_photo_test() {
+ $child = $this->_create_album();
+ $photo = $this->_create_image($child);
+ $request = (object)array("arguments" => explode("/", $photo->relative_url()));
+
+ $this->assert_equal(
+ json_encode(array("status" => "OK",
+ "resource" =>
+ array("type" => $photo->type,
+ "name" => $photo->name,
+ "path" => $photo->relative_url(),
+ "parent_path" => $child->relative_url(),
+ "title" => $photo->title,
+ "thumb_url" => $photo->thumb_url(),
+ "thumb_size" => array("height" => $photo->thumb_height,
+ "width" => $photo->thumb_width),
+ "resize_url" => $photo->resize_url(),
+ "resize_size" => array("height" => $photo->resize_height,
+ "width" => $photo->resize_width),
+ "url" => $photo->file_url(),
+ "size" => array("height" => $photo->height,
+ "width" => $photo->width),
+ "description" => $photo->description,
+ "slug" => $photo->slug))),
+ gallery_rest::get($request));
+ }
+
+ public function gallery_rest_put_album_no_path_test() {
+ $request = (object)array("description" => "Updated description",
+ "title" => "Updated Title",
+ "name" => "new name");
+
+ try {
+ gallery_rest::put($request);
+ } catch (Rest_Exception $e) {
+ $this->assert_equal("400 Bad request", $e->getMessage());
+ } catch (Exception $e) {
+ $this->assert_false(true, $e->__toString());
+ }
+ }
+
+ public function gallery_rest_put_album_not_found_test() {
+ $photo = $this->_create_image();
+ $request = (object)array("arguments" => explode("/", $photo->relative_url() . rand()),
+ "description" => "Updated description",
+ "title" => "Updated Title",
+ "name" => "new name");
+
+ try {
+ gallery_rest::put($request);
+ } catch (Kohana_404_Exception $k404) {
+ } catch (Exception $e) {
+ $this->assert_false(true, $e->__toString());
+ }
+ }
+
+ public function gallery_rest_put_album_no_edit_permission_test() {
+ $child = $this->_create_album();
+ $this->_create_user();
+ $request = (object)array("arguments" => explode("/", $child->relative_url()),
+ "description" => "Updated description",
+ "title" => "Updated Title",
+ "name" => "new name");
+
+ try {
+ gallery_rest::put($request);
+ } catch (Kohana_404_Exception $k404) {
+ } catch (Exception $e) {
+ $this->assert_false(true, $e->__toString());
+ }
+ }
+
+ public function gallery_rest_put_album_rename_conflict_test() {
+ $child = $this->_create_album();
+ $sibling = $this->_create_image();
+ $this->_create_user();
+ access::allow(identity::registered_users(), "edit", $child);
+ $request = (object)array("arguments" => explode("/", $child->relative_url()),
+ "description" => "Updated description",
+ "title" => "Updated Title",
+ "name" => $sibling->name);
+
+ $this->assert_equal(
+ json_encode(array("status" => "VALIDATE_ERROR",
+ "fields" => array("slug" => "Duplicate Internet address"))),
+ gallery_rest::put($request));
+ }
+
+ public function gallery_rest_put_album_test() {
+ $child = $this->_create_album();
+ $sibling = $this->_create_image();
+ $this->_create_user();
+ access::allow(identity::registered_users(), "edit", $child);
+
+ $new_name = "new_album_name" . rand();
+ $request = (object)array("arguments" => explode("/", $child->relative_url()),
+ "description" => "Updated description",
+ "title" => "Updated Title",
+ "name" => $new_name);
+
+ $this->assert_equal(json_encode(array("status" => "OK")), gallery_rest::put($request));
+ $child->reload();
+ $this->assert_equal("Updated description", $child->description);
+ $this->assert_equal("Updated Title", $child->title);
+ $this->assert_equal($new_name, $child->name);
+ }
+
+ public function gallery_rest_put_photo_test() {
+ $child = $this->_create_album();
+ $photo = $this->_create_image($child);
+ $this->_create_user();
+ access::allow(identity::registered_users(), "edit", $child);
+
+ $request = (object)array("arguments" => explode("/", $photo->relative_url()),
+ "description" => "Updated description",
+ "title" => "Updated Title",
+ "name" => "new name");
+
+ $this->assert_equal(json_encode(array("status" => "OK")), gallery_rest::put($request));
+ $photo->reload();
+ $this->assert_equal("Updated description", $photo->description);
+ $this->assert_equal("Updated Title", $photo->title);
+ $this->assert_equal("new name", $photo->name);
+ }
+
+ public function gallery_rest_delete_album_test() {
+ $album = $this->_create_album();
+ $child = $this->_create_album($album);
+ $this->_create_user();
+ access::allow(identity::registered_users(), "edit", $album);
+
+ $request = (object)array("arguments" => explode("/", $child->relative_url()));
+
+ $this->assert_equal(json_encode(array("status" => "OK",
+ "resource" => array(
+ "parent_path" => $album->relative_url()))),
+ gallery_rest::delete($request));
+ $child->reload();
+ $this->assert_false($child->loaded());
+ }
+
+ public function gallery_rest_delete_photo_test() {
+ $album = $this->_create_album();
+ $photo = $this->_create_image($album);
+ $this->_create_user();
+ access::allow(identity::registered_users(), "edit", $album);
+
+ $request = (object)array("arguments" => explode("/", $photo->relative_url()));
+
+ $this->assert_equal(json_encode(array("status" => "OK",
+ "resource" => array(
+ "parent_path" => $album->relative_url()))),
+ gallery_rest::delete($request));
+ $photo->reload();
+ $this->assert_false($photo->loaded());
+ }
+
+ public function gallery_rest_post_album_test() {
+ $album = $this->_create_album();
+ $this->_create_user();
+ access::allow(identity::registered_users(), "edit", $album);
+
+ $new_path = $album->relative_url() . "/new%20child";
+ $request = (object)array("arguments" => explode("/", $new_path));
+
+ $this->assert_equal(json_encode(array("status" => "OK", "path" => $new_path)),
+ gallery_rest::post($request));
+ $album = ORM::factory("item")
+ ->where("relative_url_cache", "=", $new_path)
+ ->find();
+ $this->assert_true($album->loaded());
+ $this->assert_equal("new child", $album->slug);
+ }
+}
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index a364423a..f0c653c0 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -29,13 +29,13 @@ class Item_Helper_Test extends Unit_Test_Case {
access::allow(identity::everybody(), "view", $album);
$this->assert_equal(
1,
- ORM::factory("item")->viewable()->where("id", $item->id)->count_all());
+ ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all());
// We can't see the item when permissions are denied
access::deny(identity::everybody(), "view", $album);
$this->assert_equal(
0,
- ORM::factory("item")->viewable()->where("id", $item->id)->count_all());
+ ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all());
}
public function validate_url_safe_test() {
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index e7dce893..bf5fca1a 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -35,8 +35,12 @@ class Item_Model_Test extends Unit_Test_Case {
$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));
+ db::build()
+ ->update("items")
+ ->set("created", 0)
+ ->set("updated", 0)
+ ->where("id", "=", $item->id)
+ ->execute();
$item->reload();
$item->title = "foo"; // force a change
$item->save();
@@ -51,8 +55,11 @@ class Item_Model_Test extends Unit_Test_Case {
$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));
+ db::build()
+ ->update("items")
+ ->set("updated", 0)
+ ->where("id", "=", $item->id)
+ ->execute();
$item->reload();
$item->view_count++;
$item->save();
diff --git a/modules/gallery/tests/ORM_MPTT_Test.php b/modules/gallery/tests/ORM_MPTT_Test.php
index a749542b..69b6bea9 100644
--- a/modules/gallery/tests/ORM_MPTT_Test.php
+++ b/modules/gallery/tests/ORM_MPTT_Test.php
@@ -190,8 +190,8 @@ class ORM_MPTT_Test extends Unit_Test_Case {
$parent->reload();
$this->assert_equal(3, $parent->descendants()->count());
- $this->assert_equal(2, $parent->descendants(null, 0, array("type" => "photo"))->count());
- $this->assert_equal(1, $parent->descendants(null, 0, array("type" => "album"))->count());
+ $this->assert_equal(2, $parent->descendants(null, null, array(array("type", "=", "photo")))->count());
+ $this->assert_equal(1, $parent->descendants(null, null, array(array("type", "=", "album")))->count());
}
public function descendant_limit_test() {
@@ -228,7 +228,7 @@ class ORM_MPTT_Test extends Unit_Test_Case {
$parent->reload();
$this->assert_equal(3, $parent->descendants_count());
- $this->assert_equal(2, $parent->descendants_count(array("type" => "photo")));
- $this->assert_equal(1, $parent->descendants_count(array("type" => "album")));
+ $this->assert_equal(2, $parent->descendants_count(array(array("type", "=", "photo"))));
+ $this->assert_equal(1, $parent->descendants_count(array(array("type", "=", "album"))));
}
}
diff --git a/modules/gallery/tests/Photo_Helper_Test.php b/modules/gallery/tests/Photo_Helper_Test.php
index da455bf8..97923f90 100644
--- a/modules/gallery/tests/Photo_Helper_Test.php
+++ b/modules/gallery/tests/Photo_Helper_Test.php
@@ -78,7 +78,18 @@ class Photo_Helper_Test extends Unit_Test_Case {
$album = album::create($root, $rand, $rand, $rand);
$photo = photo::create($album, MODPATH . "gallery/tests/test.jpg", "$rand.jpg", $rand, $rand);
- $this->assert_equal("http://./var/resizes/{$rand}/{$rand}.jpg", $photo->resize_url());
+ $this->assert_equal(
+ "http://./var/resizes/{$rand}/{$rand}.jpg?m={$photo->updated}", $photo->resize_url());
+ }
+
+ public function file_url_test() {
+ $rand = rand();
+ $root = ORM::factory("item", 1);
+ $album = album::create($root, $rand, $rand, $rand);
+ $photo = photo::create($album, MODPATH . "gallery/tests/test.jpg", "$rand.jpg", $rand, $rand);
+
+ $this->assert_equal(
+ "http://./var/albums/{$rand}/{$rand}.jpg?m={$photo->updated}", $photo->file_url());
}
public function create_photo_creates_reasonable_slug_test() {
diff --git a/modules/gallery/tests/Photos_Controller_Test.php b/modules/gallery/tests/Photos_Controller_Test.php
index fa4f101a..b6c6df47 100644
--- a/modules/gallery/tests/Photos_Controller_Test.php
+++ b/modules/gallery/tests/Photos_Controller_Test.php
@@ -49,8 +49,7 @@ class Photos_Controller_Test extends Unit_Test_Case {
$results = ob_get_contents();
ob_end_clean();
- $this->assert_equal(
- json_encode(array("result" => "success", "location" => "HTTP_REFERER")), $results);
+ $this->assert_equal(json_encode(array("result" => "success")), $results);
$this->assert_equal("new-slug", $photo->slug);
$this->assert_equal("new title", $photo->title);
$this->assert_equal("new description", $photo->description);
diff --git a/modules/gallery/tests/Sendmail_Test.php b/modules/gallery/tests/Sendmail_Test.php
index 64c1fff0..f3a8d897 100644
--- a/modules/gallery/tests/Sendmail_Test.php
+++ b/modules/gallery/tests/Sendmail_Test.php
@@ -19,9 +19,7 @@
*/
class Sendmail_Test extends Unit_Test_Case {
public function setup() {
- $config = Kohana::config("sendmail");
- $config["from"] = "from@gallery3.com";
- Kohana::config_set("sendmail", $config);
+ Kohana_Config::instance()->set("sendmail.from", "from@gallery3.com");
}
public function sendmail_test() {
diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt
index 1fe29ffb..c1fffe6a 100644
--- a/modules/gallery/tests/controller_auth_data.txt
+++ b/modules/gallery/tests/controller_auth_data.txt
@@ -2,8 +2,10 @@ modules/comment/controllers/admin_comments.php queue
modules/comment/helpers/comment_rss.php feed DIRTY_AUTH
modules/digibug/controllers/digibug.php print_proxy DIRTY_CSRF|DIRTY_AUTH
modules/digibug/controllers/digibug.php close_window DIRTY_AUTH
+modules/g2_import/controllers/g2.php map DIRTY_CSRF
modules/gallery/controllers/admin.php __call DIRTY_AUTH
-modules/gallery/controllers/albums.php _show DIRTY_CSRF
+modules/gallery/controllers/albums.php index DIRTY_AUTH
+modules/gallery/controllers/albums.php show DIRTY_CSRF
modules/gallery/controllers/combined.php javascript DIRTY_AUTH
modules/gallery/controllers/combined.php css DIRTY_AUTH
modules/gallery/controllers/file_proxy.php __call DIRTY_CSRF|DIRTY_AUTH
@@ -13,10 +15,13 @@ modules/gallery/controllers/login.php html
modules/gallery/controllers/login.php auth_html DIRTY_AUTH
modules/gallery/controllers/logout.php index DIRTY_CSRF|DIRTY_AUTH
modules/gallery/controllers/maintenance.php index DIRTY_AUTH
+modules/gallery/controllers/quick.php form_edit DIRTY_CSRF
modules/gallery/controllers/simple_uploader.php start DIRTY_AUTH
modules/gallery/controllers/simple_uploader.php finish DIRTY_AUTH
modules/gallery/controllers/upgrader.php index DIRTY_AUTH
modules/gallery/controllers/welcome_message.php index DIRTY_AUTH
+modules/rest/controllers/rest.php access_key DIRTY_CSRF|DIRTY_AUTH
+modules/rest/controllers/rest.php __call DIRTY_AUTH
modules/rss/controllers/rss.php feed DIRTY_CSRF|DIRTY_AUTH
modules/search/controllers/search.php index DIRTY_CSRF|DIRTY_AUTH
modules/server_add/controllers/admin_server_add.php autocomplete DIRTY_CSRF
diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt
index 3708bc6d..a264286c 100644
--- a/modules/gallery/tests/xss_data.txt
+++ b/modules/gallery/tests/xss_data.txt
@@ -39,7 +39,7 @@ modules/digibug/views/digibug_form.html.php 5 DIRTY form::
modules/digibug/views/digibug_form.html.php 6 DIRTY form::close()
modules/exif/views/exif_dialog.html.php 14 DIRTY $details[$i]["caption"]
modules/exif/views/exif_dialog.html.php 21 DIRTY $details[$i]["caption"]
-modules/g2_import/views/admin_g2_import.html.php 29 DIRTY $form
+modules/g2_import/views/admin_g2_import.html.php 30 DIRTY $form
modules/gallery/views/admin_advanced_settings.html.php 21 DIRTY_ATTR text::alternate("g-odd","g-even")
modules/gallery/views/admin_advanced_settings.html.php 22 DIRTY $var->module_name
modules/gallery/views/admin_block_log_entries.html.php 4 DIRTY_ATTR log::severity_class($entry->severity)
@@ -118,10 +118,11 @@ modules/gallery/views/admin_themes.html.php 62 DIRTY $theme
modules/gallery/views/admin_themes.html.php 76 DIRTY $info->name
modules/gallery/views/admin_themes.html.php 78 DIRTY $info->description
modules/gallery/views/admin_themes_preview.html.php 7 DIRTY_ATTR $url
-modules/gallery/views/form_uploadify.html.php 20 DIRTY_JS url::file("lib/uploadify/uploadify.swf")
-modules/gallery/views/form_uploadify.html.php 21 DIRTY_JS url::site("simple_uploader/add_photo/{$album->id}")
-modules/gallery/views/form_uploadify.html.php 25 DIRTY_JS url::file("lib/uploadify/cancel.png")
-modules/gallery/views/form_uploadify.html.php 52 DIRTY_JS t("Completed")
+modules/gallery/views/form_uploadify.html.php 24 DIRTY_JS url::file("lib/uploadify/uploadify.swf")
+modules/gallery/views/form_uploadify.html.php 25 DIRTY_JS url::site("simple_uploader/add_photo/{$album->id}")
+modules/gallery/views/form_uploadify.html.php 29 DIRTY_JS url::file("lib/uploadify/cancel.png")
+modules/gallery/views/form_uploadify.html.php 30 DIRTY_JS $simultaneous_upload_limit
+modules/gallery/views/form_uploadify.html.php 55 DIRTY_JS t("Completed")
modules/gallery/views/in_place_edit.html.php 2 DIRTY form::open($action,array("method"=>"post","id"=>"g-in-place-edit-form","class"=>"g-short-form"),$hidden)
modules/gallery/views/in_place_edit.html.php 5 DIRTY form::input("input",$form["input"]," class=\"textbox\"")
modules/gallery/views/in_place_edit.html.php 12 DIRTY form::close()
@@ -244,7 +245,7 @@ modules/organize/views/organize_thumb_grid.html.php 7 DIRTY $child
modules/organize/views/organize_thumb_grid.html.php 15 DIRTY_JS url::site("organize/album/$album->id/".($offset+25))
modules/organize/views/organize_tree.html.php 2 DIRTY_ATTR access::can("edit",$album)?"":"g-view-only"
modules/organize/views/organize_tree.html.php 3 DIRTY_ATTR $album->id
-modules/organize/views/organize_tree.html.php 6 DIRTY_ATTR $selected&&$album->id==$selected->id?"selected":""
+modules/organize/views/organize_tree.html.php 6 DIRTY_ATTR $selected&&$album->id==$selected->id?"ui-state-focus":""
modules/organize/views/organize_tree.html.php 7 DIRTY_ATTR $album->id
modules/organize/views/organize_tree.html.php 13 DIRTY View::factory("organize_tree.html",array("selected"=>$selected,"album"=>$child));
modules/organize/views/organize_tree.html.php 15 DIRTY_ATTR access::can("edit",$child)?"":"g-view-only"
@@ -274,11 +275,11 @@ modules/rss/views/feed.mrss.php 55 DIRTY_ATTR @fil
modules/rss/views/feed.mrss.php 56 DIRTY_ATTR $child->mime_type
modules/rss/views/feed.mrss.php 57 DIRTY_ATTR $child->resize_height
modules/rss/views/feed.mrss.php 58 DIRTY_ATTR $child->resize_width
-modules/rss/views/feed.mrss.php 62 DIRTY_ATTR $child->file_url(true)
-modules/rss/views/feed.mrss.php 63 DIRTY_ATTR @filesize($child->file_path())
-modules/rss/views/feed.mrss.php 64 DIRTY_ATTR $child->mime_type
-modules/rss/views/feed.mrss.php 65 DIRTY_ATTR $child->height
-modules/rss/views/feed.mrss.php 66 DIRTY_ATTR $child->width
+modules/rss/views/feed.mrss.php 61 DIRTY_ATTR $child->file_url(true)
+modules/rss/views/feed.mrss.php 62 DIRTY_ATTR @filesize($child->file_path())
+modules/rss/views/feed.mrss.php 63 DIRTY_ATTR $child->mime_type
+modules/rss/views/feed.mrss.php 64 DIRTY_ATTR $child->height
+modules/rss/views/feed.mrss.php 65 DIRTY_ATTR $child->width
modules/rss/views/feed.mrss.php 70 DIRTY_ATTR $child->file_url(true)
modules/rss/views/feed.mrss.php 71 DIRTY_ATTR @filesize($child->file_path())
modules/rss/views/feed.mrss.php 72 DIRTY_ATTR $child->height