summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/database/query_builder
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2017-06-19 10:33:58 +0200
committerAndrey Andreev <narf@devilix.net>2017-06-19 10:33:58 +0200
commit6c7a4266410070d30f8f6bcdf9c9e67f3d6478e3 (patch)
treef0aab8f6f5e781d5947b1a5553b6648eb7b7a4ab /tests/codeigniter/database/query_builder
parent2459285b91d6fc4f5099f9f597529cce1059cb33 (diff)
[ci skip] 3.1.5 release
Diffstat (limited to 'tests/codeigniter/database/query_builder')
-rw-r--r--tests/codeigniter/database/query_builder/count_test.php48
-rw-r--r--tests/codeigniter/database/query_builder/delete_test.php64
-rw-r--r--tests/codeigniter/database/query_builder/distinct_test.php33
-rw-r--r--tests/codeigniter/database/query_builder/empty_test.php39
-rw-r--r--tests/codeigniter/database/query_builder/escape_test.php68
-rw-r--r--tests/codeigniter/database/query_builder/from_test.php49
-rw-r--r--tests/codeigniter/database/query_builder/get_test.php53
-rw-r--r--tests/codeigniter/database/query_builder/group_test.php51
-rw-r--r--tests/codeigniter/database/query_builder/insert_test.php66
-rw-r--r--tests/codeigniter/database/query_builder/join_test.php101
-rw-r--r--tests/codeigniter/database/query_builder/like_test.php106
-rw-r--r--tests/codeigniter/database/query_builder/limit_test.php48
-rw-r--r--tests/codeigniter/database/query_builder/order_test.php55
-rw-r--r--tests/codeigniter/database/query_builder/select_test.php95
-rw-r--r--tests/codeigniter/database/query_builder/truncate_test.php56
-rw-r--r--tests/codeigniter/database/query_builder/update_test.php57
-rw-r--r--tests/codeigniter/database/query_builder/where_test.php134
17 files changed, 0 insertions, 1123 deletions
diff --git a/tests/codeigniter/database/query_builder/count_test.php b/tests/codeigniter/database/query_builder/count_test.php
deleted file mode 100644
index da312d866..000000000
--- a/tests/codeigniter/database/query_builder/count_test.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-class Count_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_count_all()
- {
- $this->assertEquals(4, $this->db->count_all('job'));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_count_all_results()
- {
- $this->assertEquals(2, $this->db->like('name', 'ian')->count_all_results('job'));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_count_all_results_limit()
- {
- $this->assertEquals(1, $this->db->like('name', 'ian')->limit(1)->count_all_results('job'));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/delete_test.php b/tests/codeigniter/database/query_builder/delete_test.php
deleted file mode 100644
index ab9d97f56..000000000
--- a/tests/codeigniter/database/query_builder/delete_test.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-class Delete_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_delete()
- {
- // Check initial record
- $job1 = $this->db->where('id', 1)->get('job')->row();
-
- $this->assertEquals('Developer', $job1->name);
-
- // Do the delete
- $this->db->delete('job', array('id' => 1));
-
- // Check the record
- $job1 = $this->db->where('id', 1)->get('job');
-
- $this->assertEmpty($job1->result_array());
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_delete_several_tables()
- {
- // Check initial record
- $user4 = $this->db->where('id', 4)->get('user')->row();
- $job4 = $this->db->where('id', 4)->get('job')->row();
-
- $this->assertEquals('Musician', $job4->name);
- $this->assertEquals('Chris Martin', $user4->name);
-
- // Do the delete
- $this->db->delete(array('job', 'user'), array('id' => 4));
-
- // Check the record
- $job4 = $this->db->where('id', 4)->get('job');
- $user4 = $this->db->where('id', 4)->get('user');
-
- $this->assertEmpty($job4->result_array());
- $this->assertEmpty($user4->result_array());
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/distinct_test.php b/tests/codeigniter/database/query_builder/distinct_test.php
deleted file mode 100644
index cc98009ce..000000000
--- a/tests/codeigniter/database/query_builder/distinct_test.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-class Distinct_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_distinct()
- {
- $users = $this->db->select('country')
- ->distinct()
- ->get('user')
- ->result_array();
-
- $this->assertEquals(3, count($users));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/empty_test.php b/tests/codeigniter/database/query_builder/empty_test.php
deleted file mode 100644
index d1f56285f..000000000
--- a/tests/codeigniter/database/query_builder/empty_test.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-class Empty_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_empty_table()
- {
- // Check initial record
- $jobs = $this->db->get('job')->result_array();
-
- $this->assertEquals(4, count($jobs));
-
- // Do the empty
- $this->db->empty_table('job');
-
- // Check the record
- $jobs = $this->db->get('job');
-
- $this->assertEmpty($jobs->result_array());
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php
deleted file mode 100644
index 27e678f22..000000000
--- a/tests/codeigniter/database/query_builder/escape_test.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-class Escape_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_escape_like_percent_sign()
- {
- // Escape the like string
- $string = $this->db->escape_like_str('\%foo');
-
- if (strpos(DB_DRIVER, 'mysql') !== FALSE)
- {
- $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%' ESCAPE '!';";
- }
- else
- {
- $sql = 'SELECT "value" FROM "misc" WHERE "key" LIKE \''.$string.'%\' ESCAPE \'!\';';
- }
-
- $res = $this->db->query($sql)->result_array();
-
- // Check the result
- $this->assertEquals(1, count($res));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_escape_like_backslash_sign()
- {
- // Escape the like string
- $string = $this->db->escape_like_str('\\');
-
- if (strpos(DB_DRIVER, 'mysql') !== FALSE)
- {
- $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%' ESCAPE '!';";
- }
- else
- {
- $sql = 'SELECT "value" FROM "misc" WHERE "key" LIKE \''.$string.'%\' ESCAPE \'!\';';
- }
-
- $res = $this->db->query($sql)->result_array();
-
- // Check the result
- $this->assertEquals(2, count($res));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/from_test.php b/tests/codeigniter/database/query_builder/from_test.php
deleted file mode 100644
index 7aaae348d..000000000
--- a/tests/codeigniter/database/query_builder/from_test.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-class From_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_from_simple()
- {
- $jobs = $this->db->from('job')
- ->get()
- ->result_array();
-
- $this->assertEquals(4, count($jobs));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_from_with_where()
- {
- $job1 = $this->db->from('job')
- ->where('id', 1)
- ->get()
- ->row();
-
- $this->assertEquals('1', $job1->id);
- $this->assertEquals('Developer', $job1->name);
- $this->assertEquals('Awesome job, but sometimes makes you bored', $job1->description);
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/get_test.php b/tests/codeigniter/database/query_builder/get_test.php
deleted file mode 100644
index 156027537..000000000
--- a/tests/codeigniter/database/query_builder/get_test.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-class Get_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_get_simple()
- {
- $jobs = $this->db->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']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_get_where()
- {
- $job1 = $this->db->get_where('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/group_test.php b/tests/codeigniter/database/query_builder/group_test.php
deleted file mode 100644
index 5249f7c87..000000000
--- a/tests/codeigniter/database/query_builder/group_test.php
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-
-class Group_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_group_by()
- {
- $jobs = $this->db->select('name')
- ->from('job')
- ->group_by('name')
- ->get()
- ->result_array();
-
- $this->assertEquals(4, count($jobs));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_having_by()
- {
- $jobs = $this->db->select('name')
- ->from('job')
- ->group_by('name')
- ->having('SUM(id) > 2')
- ->get()
- ->result_array();
-
- $this->assertEquals(2, count($jobs));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/insert_test.php b/tests/codeigniter/database/query_builder/insert_test.php
deleted file mode 100644
index 30c055680..000000000
--- a/tests/codeigniter/database/query_builder/insert_test.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-
-class Insert_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- * @see ./mocks/schema/skeleton.php
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
-
- // Truncate the current datas
- $this->db->truncate('job');
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_insert()
- {
- $job_data = array('id' => 1, 'name' => 'Grocery Sales', 'description' => 'Discount!');
-
- // Do normal insert
- $this->assertTrue($this->db->insert('job', $job_data));
-
- $job1 = $this->db->get('job')->row();
-
- // Check the result
- $this->assertEquals('Grocery Sales', $job1->name);
-
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_insert_batch()
- {
- $job_datas = array(
- array('id' => 2, 'name' => 'Commedian', 'description' => 'Theres something in your teeth'),
- array('id' => 3, 'name' => 'Cab Driver', 'description' => 'Iam yellow'),
- );
-
- // Do insert batch except for sqlite driver
- if (strpos(DB_DRIVER, 'sqlite') === FALSE)
- {
- $this->assertEquals(2, $this->db->insert_batch('job', $job_datas));
-
- $job_2 = $this->db->where('id', 2)->get('job')->row();
- $job_3 = $this->db->where('id', 3)->get('job')->row();
-
- // Check the result
- $this->assertEquals('Commedian', $job_2->name);
- $this->assertEquals('Cab Driver', $job_3->name);
- }
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php
deleted file mode 100644
index 54b2a4e18..000000000
--- a/tests/codeigniter/database/query_builder/join_test.php
+++ /dev/null
@@ -1,101 +0,0 @@
-<?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']);
- }
-
- // ------------------------------------------------------------------------
-
- public function test_join_escape_is_null()
- {
- $expected = 'SELECT '.$this->db->escape_identifiers('field')
- ."\nFROM ".$this->db->escape_identifiers('table1')
- ."\nJOIN ".$this->db->escape_identifiers('table2').' ON '.$this->db->escape_identifiers('field').' IS NULL';
-
- $this->assertEquals(
- $expected,
- $this->db->select('field')->from('table1')->join('table2', 'field IS NULL')->get_compiled_select()
- );
-
- $expected = 'SELECT '.$this->db->escape_identifiers('field')
- ."\nFROM ".$this->db->escape_identifiers('table1')
- ."\nJOIN ".$this->db->escape_identifiers('table2').' ON '.$this->db->escape_identifiers('field').' IS NOT NULL';
-
- $this->assertEquals(
- $expected,
- $this->db->select('field')->from('table1')->join('table2', 'field IS NOT NULL')->get_compiled_select()
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_join_escape_multiple_conditions()
- {
- // We just need a valid query produced, not one that makes sense
- $fields = array($this->db->protect_identifiers('table1.field1'), $this->db->protect_identifiers('table2.field2'));
-
- $expected = 'SELECT '.implode(', ', $fields)
- ."\nFROM ".$this->db->escape_identifiers('table1')
- ."\nLEFT JOIN ".$this->db->escape_identifiers('table2').' ON '.implode(' = ', $fields)
- .' AND '.$fields[0]." = 'foo' AND ".$fields[1].' = 0';
-
- $result = $this->db->select('table1.field1, table2.field2')
- ->from('table1')
- ->join('table2', "table1.field1 = table2.field2 AND table1.field1 = 'foo' AND table2.field2 = 0", 'LEFT')
- ->get_compiled_select();
-
- $this->assertEquals($expected, $result);
- }
-
- // ------------------------------------------------------------------------
-
- public function test_join_escape_multiple_conditions_with_parentheses()
- {
- // We just need a valid query produced, not one that makes sense
- $fields = array($this->db->protect_identifiers('table1.field1'), $this->db->protect_identifiers('table2.field2'));
-
- $expected = 'SELECT '.implode(', ', $fields)
- ."\nFROM ".$this->db->escape_identifiers('table1')
- ."\nRIGHT JOIN ".$this->db->escape_identifiers('table2').' ON '.implode(' = ', $fields)
- .' AND ('.$fields[0]." = 'foo' OR ".$fields[1].' IS NULL)';
-
- $result = $this->db->select('table1.field1, table2.field2')
- ->from('table1')
- ->join('table2', "table1.field1 = table2.field2 AND (table1.field1 = 'foo' OR table2.field2 IS NULL)", 'RIGHT')
- ->get_compiled_select();
-
- $this->assertEquals($expected, $result);
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/like_test.php b/tests/codeigniter/database/query_builder/like_test.php
deleted file mode 100644
index 2736fbe0b..000000000
--- a/tests/codeigniter/database/query_builder/like_test.php
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php
-
-class Like_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_like()
- {
- $job1 = $this->db->like('name', 'veloper')
- ->get('job')
- ->row();
-
- // Check the result
- $this->assertEquals('1', $job1->id);
- $this->assertEquals('Developer', $job1->name);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_or_like()
- {
- $jobs = $this->db->like('name', 'ian')
- ->or_like('name', 'veloper')
- ->get('job')
- ->result_array();
-
- // Check the result
- $this->assertEquals(3, count($jobs));
- $this->assertEquals('Developer', $jobs[0]['name']);
- $this->assertEquals('Politician', $jobs[1]['name']);
- $this->assertEquals('Musician', $jobs[2]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_not_like()
- {
- $jobs = $this->db->not_like('name', 'veloper')
- ->get('job')
- ->result_array();
-
- // Check the result
- $this->assertEquals(3, count($jobs));
- $this->assertEquals('Politician', $jobs[0]['name']);
- $this->assertEquals('Accountant', $jobs[1]['name']);
- $this->assertEquals('Musician', $jobs[2]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_or_not_like()
- {
- $jobs = $this->db->like('name', 'an')
- ->or_not_like('name', 'veloper')
- ->get('job')
- ->result_array();
-
- // Check the result
- $this->assertEquals(3, count($jobs));
- $this->assertEquals('Politician', $jobs[0]['name']);
- $this->assertEquals('Accountant', $jobs[1]['name']);
- $this->assertEquals('Musician', $jobs[2]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * GitHub issue #273
- *
- * @see ./mocks/schema/skeleton.php
- */
- public function test_like_spaces_and_tabs()
- {
- $spaces = $this->db->like('value', ' ')->get('misc')->result_array();
- $tabs = $this->db->like('value', "\t")->get('misc')->result_array();
-
- $this->assertEquals(1, count($spaces));
- $this->assertEquals(1, count($tabs));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/limit_test.php b/tests/codeigniter/database/query_builder/limit_test.php
deleted file mode 100644
index a0954c7ab..000000000
--- a/tests/codeigniter/database/query_builder/limit_test.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-class Limit_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_limit()
- {
- $jobs = $this->db->limit(2)
- ->get('job')
- ->result_array();
-
- $this->assertEquals(2, count($jobs));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_limit_and_offset()
- {
- $jobs = $this->db->limit(2, 2)
- ->get('job')
- ->result_array();
-
- $this->assertEquals(2, count($jobs));
- $this->assertEquals('Accountant', $jobs[0]['name']);
- $this->assertEquals('Musician', $jobs[1]['name']);
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/order_test.php b/tests/codeigniter/database/query_builder/order_test.php
deleted file mode 100644
index 46f452bae..000000000
--- a/tests/codeigniter/database/query_builder/order_test.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-class Order_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_order_ascending()
- {
- $jobs = $this->db->order_by('name', 'asc')
- ->get('job')
- ->result_array();
-
- // Check the result
- $this->assertEquals(4, count($jobs));
- $this->assertEquals('Accountant', $jobs[0]['name']);
- $this->assertEquals('Developer', $jobs[1]['name']);
- $this->assertEquals('Musician', $jobs[2]['name']);
- $this->assertEquals('Politician', $jobs[3]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_order_descending()
- {
- $jobs = $this->db->order_by('name', 'desc')
- ->get('job')
- ->result_array();
-
- $this->assertEquals(4, count($jobs));
- $this->assertEquals('Politician', $jobs[0]['name']);
- $this->assertEquals('Musician', $jobs[1]['name']);
- $this->assertEquals('Developer', $jobs[2]['name']);
- $this->assertEquals('Accountant', $jobs[3]['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
deleted file mode 100644
index 877b5d8c0..000000000
--- a/tests/codeigniter/database/query_builder/select_test.php
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-
-class Select_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_select_only_one_collumn()
- {
- $jobs_name = $this->db->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]));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_select_min()
- {
- $job_min = $this->db->select_min('id')
- ->get('job')
- ->row();
-
- // Minimum id was 1
- $this->assertEquals('1', $job_min->id);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_select_max()
- {
- $job_max = $this->db->select_max('id')
- ->get('job')
- ->row();
-
- // Maximum id was 4
- $this->assertEquals('4', $job_max->id);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_select_avg()
- {
- $job_avg = $this->db->select_avg('id')
- ->get('job')
- ->row();
-
- // Average should be 2.5
- $this->assertEquals('2.5', $job_avg->id);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_select_sum()
- {
- $job_sum = $this->db->select_sum('id')
- ->get('job')
- ->row();
-
- // Sum of ids should be 10
- $this->assertEquals('10', $job_sum->id);
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/truncate_test.php b/tests/codeigniter/database/query_builder/truncate_test.php
deleted file mode 100644
index 09923c7f1..000000000
--- a/tests/codeigniter/database/query_builder/truncate_test.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-
-class Truncate_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_truncate()
- {
- // Check initial record
- $jobs = $this->db->get('job')->result_array();
- $this->assertEquals(4, count($jobs));
-
- // Do the empty
- $this->db->truncate('job');
-
- // Check the record
- $jobs = $this->db->get('job');
- $this->assertEmpty($jobs->result_array());
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_truncate_with_from()
- {
- // Check initial record
- $users = $this->db->get('user')->result_array();
- $this->assertEquals(4, count($users));
-
- // Do the empty
- $this->db->from('user')->truncate();
-
- // Check the record
- $users = $this->db->get('user');
- $this->assertEmpty($users->result_array());
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/update_test.php b/tests/codeigniter/database/query_builder/update_test.php
deleted file mode 100644
index 27a647c45..000000000
--- a/tests/codeigniter/database/query_builder/update_test.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-class Update_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_update()
- {
- // Check initial record
- $job1 = $this->db->where('id', 1)->get('job')->row();
- $this->assertEquals('Developer', $job1->name);
-
- // Do the update
- $this->db->where('id', 1)->update('job', array('name' => 'Programmer'));
-
- // Check updated record
- $job1 = $this->db->where('id', 1)->get('job')->row();
- $this->assertEquals('Programmer', $job1->name);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_update_with_set()
- {
- // Check initial record
- $job1 = $this->db->where('id', 4)->get('job')->row();
- $this->assertEquals('Musician', $job1->name);
-
- // Do the update
- $this->db->set('name', 'Vocalist');
- $this->db->update('job', NULL, 'id = 4');
-
- // Check updated record
- $job1 = $this->db->where('id', 4)->get('job')->row();
- $this->assertEquals('Vocalist', $job1->name);
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/where_test.php b/tests/codeigniter/database/query_builder/where_test.php
deleted file mode 100644
index 46a7fa2eb..000000000
--- a/tests/codeigniter/database/query_builder/where_test.php
+++ /dev/null
@@ -1,134 +0,0 @@
-<?php
-
-class Where_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_where_simple_key_value()
- {
- $job1 = $this->db->where('id', 1)->get('job')->row();
-
- $this->assertEquals('1', $job1->id);
- $this->assertEquals('Developer', $job1->name);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_custom_key_value()
- {
- $jobs = $this->db->where('id !=', 1)->get('job')->result_array();
- $this->assertEquals(3, count($jobs));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_associative_array()
- {
- $where = array('id >' => 2, 'name !=' => 'Accountant');
- $jobs = $this->db->where($where)->get('job')->result_array();
-
- $this->assertEquals(1, count($jobs));
-
- // Should be Musician
- $job = current($jobs);
- $this->assertEquals('Musician', $job['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_custom_string()
- {
- $where = "id > 2 AND name != 'Accountant'";
- $jobs = $this->db->where($where)->get('job')->result_array();
-
- $this->assertEquals(1, count($jobs));
-
- // Should be Musician
- $job = current($jobs);
- $this->assertEquals('Musician', $job['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_or()
- {
- $jobs = $this->db->where('name !=', 'Accountant')
- ->or_where('id >', 3)
- ->get('job')
- ->result_array();
-
- $this->assertEquals(3, count($jobs));
- $this->assertEquals('Developer', $jobs[0]['name']);
- $this->assertEquals('Politician', $jobs[1]['name']);
- $this->assertEquals('Musician', $jobs[2]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_in()
- {
- $jobs = $this->db->where_in('name', array('Politician', 'Accountant'))
- ->get('job')
- ->result_array();
-
- $this->assertEquals(2, count($jobs));
- $this->assertEquals('Politician', $jobs[0]['name']);
- $this->assertEquals('Accountant', $jobs[1]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_not_in()
- {
- $jobs = $this->db->where_not_in('name', array('Politician', 'Accountant'))
- ->get('job')
- ->result_array();
-
- $this->assertEquals(2, count($jobs));
- $this->assertEquals('Developer', $jobs[0]['name']);
- $this->assertEquals('Musician', $jobs[1]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- public function test_issue4093()
- {
- $input = 'bar and baz or qux';
- $sql = $this->db->where('foo', $input)->get_compiled_select('dummy');
- $this->assertEquals("'".$input."'", substr($sql, -20));
- }
-} \ No newline at end of file