Skip to content
Browse files

Updated for K24

  • Loading branch information...
1 parent 0cd03c8 commit bfcd99f3f2a7d1b2c5ed0b6593c202ff07058b68 @bharat bharat committed
View
2 modules/akismet/tests/Akismet_Helper_Test.php
@@ -22,7 +22,7 @@ class Akismet_Helper_Test extends Unit_Test_Case {
public function setup() {
Input::instance()->ip_address = "1.1.1.1";
- Kohana::$user_agent = "Akismet_Helper_Test";
+ request::set_user_agent("Akismet_Helper_Test");
$root = ORM::factory("item", 1);
$this->_comment = comment::create(
View
7 modules/comment/tests/Comment_Helper_Test.php
@@ -23,7 +23,7 @@ class Comment_Helper_Test extends Unit_Test_Case {
public function setup() {
$this->_ip_address = Input::instance()->ip_address;
- $this->_user_agent = Kohana::$user_agent;
+ $this->_user_agent = request::user_agent();
$this->_save = $_SERVER;
$_SERVER["HTTP_ACCEPT"] = "HTTP_ACCEPT";
@@ -33,16 +33,17 @@ public function setup() {
$_SERVER["HTTP_CONNECTION"] = "HTTP_CONNECTION";
$_SERVER["HTTP_HOST"] = "HTTP_HOST";
$_SERVER["HTTP_REFERER"] = "HTTP_REFERER";
- $_SERVER["HTTP_USER_AGENT"] = "HTTP_USER_AGENT";
$_SERVER["QUERY_STRING"] = "QUERY_STRING";
$_SERVER["REMOTE_ADDR"] = "REMOTE_ADDR";
$_SERVER["REMOTE_HOST"] = "REMOTE_HOST";
$_SERVER["REMOTE_PORT"] = "REMOTE_PORT";
+
+ request::set_user_agent("HTTP_USER_AGENT");
}
public function teardown() {
Input::instance()->ip_address = $this->_ip_address;
- Kohana::$user_agent = $this->_user_agent;
+ request::set_user_agent($this->_user_agent);
$_SERVER = $this->_save;
}
View
25 modules/gallery/tests/Database_Test.php
@@ -19,7 +19,7 @@
*/
class Database_Test extends Unit_Test_Case {
function simple_where_test() {
- $sql = Database::instance()
+ $sql = Database_Builder_For_Test::instance()
->where("a", "=", 1)
->where("b", "=", 2)
->compile();
@@ -28,7 +28,7 @@ function simple_where_test() {
}
function compound_where_test() {
- $sql = Database::instance()
+ $sql = Database_Builder_For_Test::instance()
->where("outer1", "=", 1)
->and_open()
->where("inner1", "=", 1)
@@ -43,7 +43,7 @@ function compound_where_test() {
}
function group_first_test() {
- $sql = Database::instance()
+ $sql = Database_Builder_For_Test::instance()
->and_open()
->where("inner1", "=", 1)
->or_where("inner2", "=", 2)
@@ -58,12 +58,12 @@ function group_first_test() {
}
function where_array_test() {
- $sql = Database::instance()
+ $sql = Database_Builder_For_Test::instance()
->where("outer1", "=", 1)
->and_open()
->where("inner1", "=", 1)
->or_where("inner2", "=", 2)
- ->or_where("inner3", "=", 3))
+ ->or_where("inner3", "=", 3)
->close()
->compile();
$sql = str_replace("\n", " ", $sql);
@@ -73,7 +73,7 @@ function where_array_test() {
}
function notlike_test() {
- $sql = Database::instance()
+ $sql = Database_Builder_For_Test::instance()
->where("outer1", "=", 1)
->or_open()
->where("inner1", "NOT LIKE", 1)
@@ -86,7 +86,7 @@ function notlike_test() {
}
function prefix_replacement_test() {
- $db = Database_For_Test::instance();
+ $db = Database::instance();
$converted = $db->add_table_prefixes("CREATE TABLE IF NOT EXISTS {test_tables} (
`id` int(9) NOT NULL auto_increment,
`name` varchar(32) NOT NULL,
@@ -118,7 +118,8 @@ function prefix_replacement_test() {
}
function prefix_no_replacement_test() {
- $update = Database_For_Test::instance()->from("test_tables")
+ $update = Database_Builder_For_Test::instance()
+ ->from("test_tables")
->where("1", "=", "1")
->set(array("name" => "Test Name"))
->update();
@@ -129,9 +130,9 @@ function prefix_no_replacement_test() {
}
}
-class Database_For_Test extends Database {
+class Database_Builder_For_Test extends Database_Builder {
static function instance() {
- $db = new Database_For_Test();
+ $db = new Database_Builder_For_Test();
$db->_table_names["{items}"] = "g3test_items";
$db->config["table_prefix"] = "g3test_";
return $db;
@@ -143,4 +144,8 @@ public function query($sql = '') {
}
return $sql;
}
+
+ public function compile() {
+ return parent::compile();
+ }
}
View
15 modules/gallery/tests/Item_Model_Test.php
@@ -35,8 +35,12 @@ public function updating_doesnt_change_created_date_test() {
$item = self::_create_random_item();
// Force the creation date to something well known
- $db = Database::instance();
- $db->update("items", array("created" => 0, "updated" => 0), array("id" => $item->id));
+ 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 @@ public function updating_view_count_only_doesnt_change_updated_date_test() {
$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();

0 comments on commit bfcd99f

Please sign in to comment.
Something went wrong with that request. Please try again.