summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codeigniter')
-rw-r--r--tests/codeigniter/database/DB_driver_test.php36
-rw-r--r--tests/codeigniter/database/query_builder/.gitkeep0
-rw-r--r--tests/codeigniter/database/query_builder/get_test.php48
3 files changed, 84 insertions, 0 deletions
diff --git a/tests/codeigniter/database/DB_driver_test.php b/tests/codeigniter/database/DB_driver_test.php
new file mode 100644
index 000000000..fb40f0608
--- /dev/null
+++ b/tests/codeigniter/database/DB_driver_test.php
@@ -0,0 +1,36 @@
+<?php
+
+class DB_driver_test extends CI_TestCase {
+
+ // ------------------------------------------------------------------------
+
+ public function test_initialize()
+ {
+ $config = Mock_Database_DB::config(DB_DRIVER);
+ $driver_name = current(explode('/', DB_DRIVER));
+ $driver = $this->$driver_name($config[DB_DRIVER]);
+
+ $this->assertTrue($driver->initialize());
+ }
+
+ protected function pdo($config)
+ {
+ return new Mock_Database_Drivers_PDO($config);
+ }
+
+ protected function mysql($config)
+ {
+ return new Mock_Database_Drivers_Mysql($config);
+ }
+
+ protected function sqlite($config)
+ {
+ return new Mock_Database_Drivers_Sqlite($config);
+ }
+
+ protected function pgsql($config)
+ {
+ return new Mock_Database_Drivers_Postgre($config);
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/.gitkeep b/tests/codeigniter/database/query_builder/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/codeigniter/database/query_builder/.gitkeep
+++ /dev/null
diff --git a/tests/codeigniter/database/query_builder/get_test.php b/tests/codeigniter/database/query_builder/get_test.php
new file mode 100644
index 000000000..e6fe319c5
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/get_test.php
@@ -0,0 +1,48 @@
+<?php
+
+class Get_test extends CI_TestCase {
+
+ /**
+ * @var object Database/Query Builder holder
+ */
+ protected $query_builder;
+
+ 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);
+
+ $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);
+
+ $this->query_builder = $db;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_get_simple()
+ {
+ $jobs = $this->query_builder->get('job')->result_array();
+
+ // Dummy jobs contain 4 rows
+ $this->assertCount(4, $jobs);
+
+ // Check rows item
+ $this->assertEquals('Developer', $jobs[0]['name']);
+ $this->assertEquals('Politician', $jobs[1]['name']);
+ $this->assertEquals('Accountant', $jobs[2]['name']);
+ $this->assertEquals('Musician', $jobs[3]['name']);
+ }
+
+} \ No newline at end of file