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.php16
-rw-r--r--modules/gallery/tests/Cache_Test.php2
-rw-r--r--modules/gallery/tests/Database_Test.php49
-rw-r--r--modules/gallery/tests/Gallery_Installer_Test.php2
-rw-r--r--modules/gallery/tests/I18n_Test.php10
-rw-r--r--modules/gallery/tests/Item_Helper_Test.php4
-rw-r--r--modules/gallery/tests/ORM_MPTT_Test.php4
7 files changed, 44 insertions, 43 deletions
diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php
index e9e5cb26..771c6a85 100644
--- a/modules/gallery/tests/Access_Helper_Test.php
+++ b/modules/gallery/tests/Access_Helper_Test.php
@@ -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)->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)->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)->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)->find()->view_1);
}
public function cant_reset_root_item_test() {
diff --git a/modules/gallery/tests/Cache_Test.php b/modules/gallery/tests/Cache_Test.php
index 6b525265..776c6625 100644
--- a/modules/gallery/tests/Cache_Test.php
+++ b/modules/gallery/tests/Cache_Test.php
@@ -20,7 +20,7 @@
class Cache_Test extends Unit_Test_Case {
private $_driver;
public function setup() {
- Database::instance()->from("caches")->where(1)->delete();
+ Database::instance()->from("caches")->where("1", "=", "1")->delete();
$this->_driver = new Cache_Database_Driver();
}
diff --git a/modules/gallery/tests/Database_Test.php b/modules/gallery/tests/Database_Test.php
index 98bd4046..9b428379 100644
--- a/modules/gallery/tests/Database_Test.php
+++ b/modules/gallery/tests/Database_Test.php
@@ -20,8 +20,8 @@
class Database_Test extends Unit_Test_Case {
function simple_where_test() {
$sql = Database::instance()
- ->where("a", 1)
- ->where("b", 2)
+ ->where("a", "=", 1)
+ ->where("b", "=", 2)
->compile();
$sql = str_replace("\n", " ", $sql);
$this->assert_same("SELECT * WHERE `a` = 1 AND `b` = 2", $sql);
@@ -29,12 +29,12 @@ class Database_Test extends Unit_Test_Case {
function compound_where_test() {
$sql = Database::instance()
- ->where("outer1", 1)
- ->open_paren()
- ->where("inner1", 1)
- ->orwhere("inner2", 2)
- ->close_paren()
- ->where("outer2", 2)
+ ->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(
@@ -44,12 +44,12 @@ class Database_Test extends Unit_Test_Case {
function group_first_test() {
$sql = Database::instance()
- ->open_paren()
- ->where("inner1", 1)
- ->orwhere("inner2", 2)
- ->close_paren()
- ->where("outer1", 1)
- ->where("outer2", 2)
+ ->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(
@@ -59,11 +59,12 @@ class Database_Test extends Unit_Test_Case {
function where_array_test() {
$sql = Database::instance()
- ->where("outer1", 1)
- ->open_paren()
- ->where("inner1", 1)
- ->orwhere(array("inner2" => 2, "inner3" => 3))
- ->close_paren()
+ ->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(
@@ -73,10 +74,10 @@ class Database_Test extends Unit_Test_Case {
function notlike_test() {
$sql = Database::instance()
- ->where("outer1", 1)
- ->open_paren()
- ->ornotlike("inner1", 1)
- ->close_paren()
+ ->where("outer1", "=", 1)
+ ->or_open()
+ ->where("inner1", "NOT LIKE", 1)
+ ->close()
->compile();
$sql = str_replace("\n", " ", $sql);
$this->assert_same(
@@ -118,7 +119,7 @@ class Database_Test extends Unit_Test_Case {
function prefix_no_replacement_test() {
$update = Database_For_Test::instance()->from("test_tables")
- ->where("1 = 1")
+ ->where("1", "=", "1")
->set(array("name" => "Test Name"))
->update();
diff --git a/modules/gallery/tests/Gallery_Installer_Test.php b/modules/gallery/tests/Gallery_Installer_Test.php
index 36ced2bb..f36f638f 100644
--- a/modules/gallery/tests/Gallery_Installer_Test.php
+++ b/modules/gallery/tests/Gallery_Installer_Test.php
@@ -29,7 +29,7 @@ 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);
}
diff --git a/modules/gallery/tests/I18n_Test.php b/modules/gallery/tests/I18n_Test.php
index 9010606a..895e3051 100644
--- a/modules/gallery/tests/I18n_Test.php
+++ b/modules/gallery/tests/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/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/ORM_MPTT_Test.php b/modules/gallery/tests/ORM_MPTT_Test.php
index a749542b..36a81d2c 100644
--- a/modules/gallery/tests/ORM_MPTT_Test.php
+++ b/modules/gallery/tests/ORM_MPTT_Test.php
@@ -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"))));
}
}