summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTaufan Aditya <toopay@taufanaditya.com>2012-05-04 10:05:22 +0200
committerTaufan Aditya <toopay@taufanaditya.com>2012-05-04 10:05:22 +0200
commitd6b41bb2659f959da01aee0ddb38bb4bce6cd4b6 (patch)
tree781941ca709e2c40eab3a7191d5e42c558893580 /tests
parent17f799e1017d1688a2890a1ba78e4f53d80af77e (diff)
JOIN clause API code-coverage
Diffstat (limited to 'tests')
-rw-r--r--tests/codeigniter/database/query_builder/join_test.php38
-rw-r--r--tests/mocks/database/schema/skeleton.php2
2 files changed, 39 insertions, 1 deletions
diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php
new file mode 100644
index 000000000..e05329d67
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/join_test.php
@@ -0,0 +1,38 @@
+<?php
+
+class Join_test extends CI_TestCase {
+
+ /**
+ * @var object Database/Query Builder holder
+ */
+ protected $db;
+
+ public function set_up()
+ {
+ $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_join_simple()
+ {
+ $job_user = $this->db->select('job.id as job_id, job.name as job_name, user.id as user_id, user.name as user_name')
+ ->from('job')
+ ->join('user', 'user.id = job.id')
+ ->get()
+ ->result_array();
+
+ // Check the result
+ $this->assertEquals('1', $job_user[0]['job_id']);
+ $this->assertEquals('1', $job_user[0]['user_id']);
+ $this->assertEquals('Derek Jones', $job_user[0]['user_name']);
+ $this->assertEquals('Developer', $job_user[0]['job_name']);
+ }
+
+} \ No newline at end of file
diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php
index fbd533bfb..9ebd6e85f 100644
--- a/tests/mocks/database/schema/skeleton.php
+++ b/tests/mocks/database/schema/skeleton.php
@@ -100,7 +100,7 @@ class Mock_Database_Schema_Skeleton {
array('id' => 2, 'name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com'),
array('id' => 3, 'name' => 'Richard A Causey', 'email' => 'richard@world.com'),
array('id' => 4, 'name' => 'Chris Martin', 'email' => 'chris@world.com'),
- )
+ ),
'job' => array(
array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'),
array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'),