summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/database
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2018-01-13 12:57:11 +0100
committerAndrey Andreev <narf@devilix.net>2018-01-13 12:57:11 +0100
commit02a0518e1c56ba3506f370362ac5ebdb8a138312 (patch)
tree8b4684192b403dcae17d298eb4fc9e7ab001acad /tests/codeigniter/database
parentf0b9735d5857e6c07c8f5824b13cff4828db3cfe (diff)
[ci skip] 3.1.7 release
Diffstat (limited to 'tests/codeigniter/database')
-rw-r--r--tests/codeigniter/database/DB_driver_test.php39
-rw-r--r--tests/codeigniter/database/DB_test.php61
-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.php50
-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
19 files changed, 0 insertions, 1222 deletions
diff --git a/tests/codeigniter/database/DB_driver_test.php b/tests/codeigniter/database/DB_driver_test.php
deleted file mode 100644
index 26416d3fc..000000000
--- a/tests/codeigniter/database/DB_driver_test.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-class DB_driver_test extends CI_TestCase {
-
- public function test_initialize()
- {
- $config = Mock_Database_DB::config(DB_DRIVER);
- sscanf(DB_DRIVER, '%[^/]/', $driver_name);
- $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 mysqli($config)
- {
- return new Mock_Database_Drivers_Mysqli($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/DB_test.php b/tests/codeigniter/database/DB_test.php
deleted file mode 100644
index 9d53fd6f2..000000000
--- a/tests/codeigniter/database/DB_test.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-class DB_test extends CI_TestCase {
-
- public function test_db_invalid()
- {
- $connection = new Mock_Database_DB(array(
- 'undefined' => array(
- 'dsn' => '',
- 'hostname' => 'undefined',
- 'username' => 'undefined',
- 'password' => 'undefined',
- 'database' => 'undefined',
- 'dbdriver' => 'undefined',
- ),
- ));
-
- $this->setExpectedException('RuntimeException', 'CI Error: Invalid DB driver');
-
- Mock_Database_DB::DB($connection->set_dsn('undefined'), TRUE);
- }
-
- // ------------------------------------------------------------------------
-
- public function test_db_valid()
- {
- $config = Mock_Database_DB::config(DB_DRIVER);
- $connection = new Mock_Database_DB($config);
-
- // E_DEPRECATED notices thrown by mysql_connect(), mysql_pconnect()
- // on PHP 5.5+ cause the tests to fail
- if (DB_DRIVER === 'mysql' && version_compare(PHP_VERSION, '5.5', '>='))
- {
- error_reporting(E_ALL & ~E_DEPRECATED);
- }
-
- $db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER), TRUE);
-
- $this->assertInstanceOf('CI_DB', $db);
- $this->assertInstanceOf('CI_DB_Driver', $db);
- }
-
- // ------------------------------------------------------------------------
-
-/*
- This test is unusable, because whoever wrote it apparently thought that
- an E_WARNING should equal an Exception and based the whole test suite
- around that bogus assumption.
-
- public function test_db_failover()
- {
- $config = Mock_Database_DB::config(DB_DRIVER);
- $connection = new Mock_Database_DB($config);
- $db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER.'_failover'), TRUE);
-
- $this->assertInstanceOf('CI_DB', $db);
- $this->assertInstanceOf('CI_DB_Driver', $db);
- }
-*/
-
-}
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 81fabe448..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->assertCount(3, $users);
- }
-
-}
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 3f63a60f5..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->assertCount(4, $jobs);
-
- // Do the empty
- $this->db->empty_table('job');
-
- // Check the record
- $jobs = $this->db->get('job');
-
- $this->assertEmpty($jobs->result_array());
- }
-
-}
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 de6cd0a9d..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->assertCount(1, $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->assertCount(2, $res);
- }
-
-}
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 5a4ac690d..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->assertCount(4, $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);
- }
-
-}
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 b40e5e507..000000000
--- a/tests/codeigniter/database/query_builder/group_test.php
+++ /dev/null
@@ -1,50 +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->assertCount(4, $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->assertCount(2, $jobs);
- }
-}
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 3672afae3..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->assertCount(3, $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->assertCount(3, $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->assertCount(3, $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->assertCount(1, $spaces);
- $this->assertCount(1, $tabs);
- }
-
-}
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 a1976d457..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->assertCount(2, $jobs);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_limit_and_offset()
- {
- $jobs = $this->db->limit(2, 2)
- ->get('job')
- ->result_array();
-
- $this->assertCount(2, $jobs);
- $this->assertEquals('Accountant', $jobs[0]['name']);
- $this->assertEquals('Musician', $jobs[1]['name']);
- }
-
-}
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 ff5bc543d..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->assertCount(4, $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->assertCount(4, $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']);
- }
-
-}
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 93b5c3d46..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->assertArrayNotHasKey('id', $jobs_name[0]);
- $this->assertArrayNotHasKey('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);
- }
-
-}
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 64abe2872..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->assertCount(4, $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->assertCount(4, $users);
-
- // Do the empty
- $this->db->from('user')->truncate();
-
- // Check the record
- $users = $this->db->get('user');
- $this->assertEmpty($users->result_array());
- }
-
-}
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 8a7a09ddb..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->assertCount(3, $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->assertCount(1, $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->assertCount(1, $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->assertCount(3, $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->assertCount(2, $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->assertCount(2, $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));
- }
-}