summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
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'),