From 1fd0e14359a7c7164573e4aa897c07680339e713 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 26 Nov 2009 12:09:04 -0800 Subject: Convert all DB where() calls to take 3 arguments. Convert all open_paren() calls to and_open() or or_open() as appropriate. --- modules/gallery/tests/Access_Helper_Test.php | 16 ++++---- modules/gallery/tests/Cache_Test.php | 2 +- modules/gallery/tests/Database_Test.php | 49 ++++++++++++------------ modules/gallery/tests/Gallery_Installer_Test.php | 2 +- modules/gallery/tests/I18n_Test.php | 4 +- modules/gallery/tests/Item_Helper_Test.php | 4 +- 6 files changed, 39 insertions(+), 38 deletions(-) (limited to 'modules/gallery/tests') diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php index d90d7ed6..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..4f5a1da2 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) + ->orwhere("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) + ->orwhere("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) + ->orwhere("inner2", "=", 2) + ->orwhere("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 d0555cbf..895e3051 100644 --- a/modules/gallery/tests/I18n_Test.php +++ b/modules/gallery/tests/I18n_Test.php @@ -29,7 +29,7 @@ class Gallery_I18n_Test extends Unit_Test_Case { $this->i18n = Gallery_I18n::instance($config); ORM::factory("incoming_translation") - ->where("locale", "te_ST") + ->where("locale", "=", "te_ST") ->delete_all(); $messages_te_ST = array( @@ -62,7 +62,7 @@ class Gallery_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() { -- cgit v1.2.3