summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/database/query_builder
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codeigniter/database/query_builder')
-rw-r--r--tests/codeigniter/database/query_builder/get_test.php31
-rw-r--r--tests/codeigniter/database/query_builder/select_test.php37
2 files changed, 56 insertions, 12 deletions
diff --git a/tests/codeigniter/database/query_builder/get_test.php b/tests/codeigniter/database/query_builder/get_test.php
index e6fe319c5..dd946a40c 100644
--- a/tests/codeigniter/database/query_builder/get_test.php
+++ b/tests/codeigniter/database/query_builder/get_test.php
@@ -9,19 +9,10 @@ class Get_test extends CI_TestCase {
public function set_up()
{
- $config = Mock_Database_DB::config(DB_DRIVER);
- $connection = new Mock_Database_DB($config);
- $db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER), TRUE);
+ $db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
- $this->ci_instance_var('db', $db);
-
- $loader = new Mock_Core_Loader();
- $loader->dbforge();
-
- $forge = $this->ci_instance->dbforge;
-
- Mock_Database_Schema_Skeleton::create_tables($forge, DB_DRIVER);
- Mock_Database_Schema_Skeleton::create_data($db);
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
$this->query_builder = $db;
}
@@ -44,5 +35,21 @@ class Get_test extends CI_TestCase {
$this->assertEquals('Accountant', $jobs[2]['name']);
$this->assertEquals('Musician', $jobs[3]['name']);
}
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_get_where()
+ {
+ $job1 = $this->query_builder->get('job', array('id' => 1))->result_array();
+
+ // Dummy jobs contain 1 rows
+ $this->assertCount(1, $job1);
+
+ // Check rows item
+ $this->assertEquals('Developer', $job1[0]['name']);
+ }
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/select_test.php b/tests/codeigniter/database/query_builder/select_test.php
new file mode 100644
index 000000000..ba2f21b64
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/select_test.php
@@ -0,0 +1,37 @@
+<?php
+
+class Select_test extends CI_TestCase {
+
+ /**
+ * @var object Database/Query Builder holder
+ */
+ protected $query_builder;
+
+ public function set_up()
+ {
+ $db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+
+ $this->query_builder = $db;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_select_only_one_collumn()
+ {
+ $jobs_name = $this->query_builder->select('name')
+ ->get('job')
+ ->result_array();
+
+ // Check rows item
+ $this->assertArrayHasKey('name',$jobs_name[0]);
+ $this->assertFalse(array_key_exists('id', $jobs_name[0]));
+ $this->assertFalse(array_key_exists('description', $jobs_name[0]));
+ }
+
+} \ No newline at end of file