summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/database/query_builder/join_test.php
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2012-05-17 15:54:35 +0200
committerPhil Sturgeon <email@philsturgeon.co.uk>2012-05-17 15:54:35 +0200
commit76c5185c6ed8c44cb0f249afd72677627d54ff3c (patch)
treedb10cc2cc30f731ac8625117f08ad8855efdf816 /tests/codeigniter/database/query_builder/join_test.php
parent714252bf88306839484579059e3a447dd93d55c1 (diff)
parente30b3f7afafa2c016cf78cc8bb8a457c2dbcda8c (diff)
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into develop
Diffstat (limited to 'tests/codeigniter/database/query_builder/join_test.php')
-rw-r--r--tests/codeigniter/database/query_builder/join_test.php38
1 files changed, 38 insertions, 0 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