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/Cache_Test.php79
-rw-r--r--modules/gallery/tests/Database_Test.php153
-rw-r--r--modules/gallery/tests/DrawForm_Test.php27
-rw-r--r--modules/gallery/tests/File_Structure_Test.php16
-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/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/Sendmail_Test.php4
-rw-r--r--modules/gallery/tests/controller_auth_data.txt3
-rw-r--r--modules/gallery/tests/xss_data.txt11
13 files changed, 200 insertions, 156 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/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..90361d06 100644
--- a/modules/gallery/tests/DrawForm_Test.php
+++ b/modules/gallery/tests/DrawForm_Test.php
@@ -25,25 +25,26 @@ class DrawForm_Test extends Unit_Test_Case {
$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";
+ "</form>";
$this->assert_same($expected, $rendered);
}
@@ -55,20 +56,21 @@ class DrawForm_Test extends Unit_Test_Case {
$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,7 +78,7 @@ class DrawForm_Test extends Unit_Test_Case {
" </li>\n" .
" </ul>\n" .
" </fieldset>\n" .
- "</form>\n";
+ "</form>";
$this->assert_same($expected, $rendered);
}
@@ -91,20 +93,21 @@ class DrawForm_Test extends Unit_Test_Case {
$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,7 +119,7 @@ class DrawForm_Test extends Unit_Test_Case {
"<script type=\"text/javascript\">\n" .
"alert('Test Javascript');\n" .
"</script>\n" .
- "</form>\n";
+ "</form>";
$this->assert_same($expected, $rendered);
}
}
diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php
index 36342fda..a046b4dd 100644
--- a/modules/gallery/tests/File_Structure_Test.php
+++ b/modules/gallery/tests/File_Structure_Test.php
@@ -57,10 +57,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 +73,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 +139,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/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/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..044a8f22 100644
--- a/modules/gallery/tests/controller_auth_data.txt
+++ b/modules/gallery/tests/controller_auth_data.txt
@@ -3,7 +3,8 @@ modules/comment/helpers/comment_rss.php feed
modules/digibug/controllers/digibug.php print_proxy DIRTY_CSRF|DIRTY_AUTH
modules/digibug/controllers/digibug.php close_window DIRTY_AUTH
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
diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt
index 3708bc6d..5a15d2ac 100644
--- a/modules/gallery/tests/xss_data.txt
+++ b/modules/gallery/tests/xss_data.txt
@@ -121,6 +121,7 @@ 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 27 DIRTY_JS $simultaneous_upload_limit
modules/gallery/views/form_uploadify.html.php 52 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\"")
@@ -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