diff options
author | Andrey Andreev <narf@devilix.net> | 2018-06-12 15:46:16 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2018-06-12 15:46:16 +0200 |
commit | bb451aa0e4853f9afd4263769eeea1d9aad3a600 (patch) | |
tree | aa3770006128ab46d570e6b6aad756e4e92299d9 /tests/codeigniter/database | |
parent | e76217041ddcae80f11b50b44a7d409b6722ad40 (diff) | |
parent | a9da3dd2f16a8f97d7bc4ff5572b28e4bb84c813 (diff) |
Merge branch '3.1-stable'
Diffstat (limited to 'tests/codeigniter/database')
12 files changed, 65 insertions, 43 deletions
diff --git a/tests/codeigniter/database/DB_test.php b/tests/codeigniter/database/DB_test.php index dc4fae986..9d53fd6f2 100644 --- a/tests/codeigniter/database/DB_test.php +++ b/tests/codeigniter/database/DB_test.php @@ -36,8 +36,8 @@ class DB_test extends CI_TestCase { $db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER), TRUE); - $this->assertTrue($db instanceof CI_DB); - $this->assertTrue($db instanceof CI_DB_Driver); + $this->assertInstanceOf('CI_DB', $db); + $this->assertInstanceOf('CI_DB_Driver', $db); } // ------------------------------------------------------------------------ @@ -53,9 +53,9 @@ class DB_test extends CI_TestCase { $connection = new Mock_Database_DB($config); $db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER.'_failover'), TRUE); - $this->assertTrue($db instanceof CI_DB); - $this->assertTrue($db instanceof CI_DB_Driver); + $this->assertInstanceOf('CI_DB', $db); + $this->assertInstanceOf('CI_DB_Driver', $db); } */ -}
\ 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 index cc98009ce..81fabe448 100644 --- a/tests/codeigniter/database/query_builder/distinct_test.php +++ b/tests/codeigniter/database/query_builder/distinct_test.php @@ -27,7 +27,7 @@ class Distinct_test extends CI_TestCase { ->get('user') ->result_array(); - $this->assertEquals(3, count($users)); + $this->assertCount(3, $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 index d1f56285f..3f63a60f5 100644 --- a/tests/codeigniter/database/query_builder/empty_test.php +++ b/tests/codeigniter/database/query_builder/empty_test.php @@ -25,7 +25,7 @@ class Empty_test extends CI_TestCase { // Check initial record $jobs = $this->db->get('job')->result_array(); - $this->assertEquals(4, count($jobs)); + $this->assertCount(4, $jobs); // Do the empty $this->db->empty_table('job'); @@ -36,4 +36,4 @@ class Empty_test extends CI_TestCase { $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 index 27e678f22..de6cd0a9d 100644 --- a/tests/codeigniter/database/query_builder/escape_test.php +++ b/tests/codeigniter/database/query_builder/escape_test.php @@ -37,7 +37,7 @@ class Escape_test extends CI_TestCase { $res = $this->db->query($sql)->result_array(); // Check the result - $this->assertEquals(1, count($res)); + $this->assertCount(1, $res); } // ------------------------------------------------------------------------ @@ -62,7 +62,7 @@ class Escape_test extends CI_TestCase { $res = $this->db->query($sql)->result_array(); // Check the result - $this->assertEquals(2, count($res)); + $this->assertCount(2, $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 index 7aaae348d..5a4ac690d 100644 --- a/tests/codeigniter/database/query_builder/from_test.php +++ b/tests/codeigniter/database/query_builder/from_test.php @@ -26,7 +26,7 @@ class From_test extends CI_TestCase { ->get() ->result_array(); - $this->assertEquals(4, count($jobs)); + $this->assertCount(4, $jobs); } // ------------------------------------------------------------------------ @@ -46,4 +46,4 @@ class From_test extends CI_TestCase { $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/group_test.php b/tests/codeigniter/database/query_builder/group_test.php index 5249f7c87..b40e5e507 100644 --- a/tests/codeigniter/database/query_builder/group_test.php +++ b/tests/codeigniter/database/query_builder/group_test.php @@ -28,7 +28,7 @@ class Group_test extends CI_TestCase { ->get() ->result_array(); - $this->assertEquals(4, count($jobs)); + $this->assertCount(4, $jobs); } // ------------------------------------------------------------------------ @@ -45,7 +45,6 @@ class Group_test extends CI_TestCase { ->get() ->result_array(); - $this->assertEquals(2, count($jobs)); + $this->assertCount(2, $jobs); } - -}
\ 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 index 2736fbe0b..4d8673d99 100644 --- a/tests/codeigniter/database/query_builder/like_test.php +++ b/tests/codeigniter/database/query_builder/like_test.php @@ -44,7 +44,7 @@ class Like_test extends CI_TestCase { ->result_array(); // Check the result - $this->assertEquals(3, count($jobs)); + $this->assertCount(3, $jobs); $this->assertEquals('Developer', $jobs[0]['name']); $this->assertEquals('Politician', $jobs[1]['name']); $this->assertEquals('Musician', $jobs[2]['name']); @@ -62,7 +62,7 @@ class Like_test extends CI_TestCase { ->result_array(); // Check the result - $this->assertEquals(3, count($jobs)); + $this->assertCount(3, $jobs); $this->assertEquals('Politician', $jobs[0]['name']); $this->assertEquals('Accountant', $jobs[1]['name']); $this->assertEquals('Musician', $jobs[2]['name']); @@ -81,7 +81,7 @@ class Like_test extends CI_TestCase { ->result_array(); // Check the result - $this->assertEquals(3, count($jobs)); + $this->assertCount(3, $jobs); $this->assertEquals('Politician', $jobs[0]['name']); $this->assertEquals('Accountant', $jobs[1]['name']); $this->assertEquals('Musician', $jobs[2]['name']); @@ -99,8 +99,31 @@ class Like_test extends CI_TestCase { $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)); + $this->assertCount(1, $spaces); + $this->assertCount(1, $tabs); } -}
\ No newline at end of file + /** + * GitHub issue #5462 + * + * @see ./mocks/schema/skeleton.php + * + * @dataProvider like_set_side_provider + */ + public function test_like_set_side($str, $side, $expected_name) + { + $actual = $this->db->like('name', $str, $side)->get('job')->result_array(); + $this->assertCount(1, $actual); + $this->assertEquals($expected_name, $actual[0]['name']); + } + + public function like_set_side_provider() + { + return array( + array('Developer', 'none', 'Developer'), + array('tician', 'before', 'Politician'), + array('Accou', 'after', 'Accountant'), + array('usicia', 'both', 'Musician'), + ); + } +} diff --git a/tests/codeigniter/database/query_builder/limit_test.php b/tests/codeigniter/database/query_builder/limit_test.php index a0954c7ab..a1976d457 100644 --- a/tests/codeigniter/database/query_builder/limit_test.php +++ b/tests/codeigniter/database/query_builder/limit_test.php @@ -26,7 +26,7 @@ class Limit_test extends CI_TestCase { ->get('job') ->result_array(); - $this->assertEquals(2, count($jobs)); + $this->assertCount(2, $jobs); } // ------------------------------------------------------------------------ @@ -40,9 +40,9 @@ class Limit_test extends CI_TestCase { ->get('job') ->result_array(); - $this->assertEquals(2, count($jobs)); + $this->assertCount(2, $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 index 46f452bae..ff5bc543d 100644 --- a/tests/codeigniter/database/query_builder/order_test.php +++ b/tests/codeigniter/database/query_builder/order_test.php @@ -27,7 +27,7 @@ class Order_test extends CI_TestCase { ->result_array(); // Check the result - $this->assertEquals(4, count($jobs)); + $this->assertCount(4, $jobs); $this->assertEquals('Accountant', $jobs[0]['name']); $this->assertEquals('Developer', $jobs[1]['name']); $this->assertEquals('Musician', $jobs[2]['name']); @@ -45,11 +45,11 @@ class Order_test extends CI_TestCase { ->get('job') ->result_array(); - $this->assertEquals(4, count($jobs)); + $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']); } -}
\ 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 index 877b5d8c0..93b5c3d46 100644 --- a/tests/codeigniter/database/query_builder/select_test.php +++ b/tests/codeigniter/database/query_builder/select_test.php @@ -28,8 +28,8 @@ class Select_test extends CI_TestCase { // 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])); + $this->assertArrayNotHasKey('id', $jobs_name[0]); + $this->assertArrayNotHasKey('description', $jobs_name[0]); } // ------------------------------------------------------------------------ @@ -92,4 +92,4 @@ class Select_test extends CI_TestCase { $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 index 09923c7f1..64abe2872 100644 --- a/tests/codeigniter/database/query_builder/truncate_test.php +++ b/tests/codeigniter/database/query_builder/truncate_test.php @@ -24,7 +24,7 @@ class Truncate_test extends CI_TestCase { { // Check initial record $jobs = $this->db->get('job')->result_array(); - $this->assertEquals(4, count($jobs)); + $this->assertCount(4, $jobs); // Do the empty $this->db->truncate('job'); @@ -43,7 +43,7 @@ class Truncate_test extends CI_TestCase { { // Check initial record $users = $this->db->get('user')->result_array(); - $this->assertEquals(4, count($users)); + $this->assertCount(4, $users); // Do the empty $this->db->from('user')->truncate(); @@ -53,4 +53,4 @@ class Truncate_test extends CI_TestCase { $this->assertEmpty($users->result_array()); } -}
\ 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 index 46a7fa2eb..8a7a09ddb 100644 --- a/tests/codeigniter/database/query_builder/where_test.php +++ b/tests/codeigniter/database/query_builder/where_test.php @@ -36,7 +36,7 @@ class Where_test extends CI_TestCase { public function test_where_custom_key_value() { $jobs = $this->db->where('id !=', 1)->get('job')->result_array(); - $this->assertEquals(3, count($jobs)); + $this->assertCount(3, $jobs); } // ------------------------------------------------------------------------ @@ -49,7 +49,7 @@ class Where_test extends CI_TestCase { $where = array('id >' => 2, 'name !=' => 'Accountant'); $jobs = $this->db->where($where)->get('job')->result_array(); - $this->assertEquals(1, count($jobs)); + $this->assertCount(1, $jobs); // Should be Musician $job = current($jobs); @@ -66,7 +66,7 @@ class Where_test extends CI_TestCase { $where = "id > 2 AND name != 'Accountant'"; $jobs = $this->db->where($where)->get('job')->result_array(); - $this->assertEquals(1, count($jobs)); + $this->assertCount(1, $jobs); // Should be Musician $job = current($jobs); @@ -85,7 +85,7 @@ class Where_test extends CI_TestCase { ->get('job') ->result_array(); - $this->assertEquals(3, count($jobs)); + $this->assertCount(3, $jobs); $this->assertEquals('Developer', $jobs[0]['name']); $this->assertEquals('Politician', $jobs[1]['name']); $this->assertEquals('Musician', $jobs[2]['name']); @@ -102,7 +102,7 @@ class Where_test extends CI_TestCase { ->get('job') ->result_array(); - $this->assertEquals(2, count($jobs)); + $this->assertCount(2, $jobs); $this->assertEquals('Politician', $jobs[0]['name']); $this->assertEquals('Accountant', $jobs[1]['name']); } @@ -118,7 +118,7 @@ class Where_test extends CI_TestCase { ->get('job') ->result_array(); - $this->assertEquals(2, count($jobs)); + $this->assertCount(2, $jobs); $this->assertEquals('Developer', $jobs[0]['name']); $this->assertEquals('Musician', $jobs[1]['name']); } @@ -131,4 +131,4 @@ class Where_test extends CI_TestCase { $sql = $this->db->where('foo', $input)->get_compiled_select('dummy'); $this->assertEquals("'".$input."'", substr($sql, -20)); } -}
\ No newline at end of file +} |