Merge pull request #5354 from carusogabriel/refactoring-tests
Refactoring tests
Conflicts resolved:
tests/codeigniter/core/Utf8_test.php
tests/codeigniter/database/query_builder/group_test.php
tests/codeigniter/libraries/Form_validation_test.php
diff --git a/tests/codeigniter/database/query_builder/distinct_test.php b/tests/codeigniter/database/query_builder/distinct_test.php
index cc98009..81fabe4 100644
--- a/tests/codeigniter/database/query_builder/distinct_test.php
+++ b/tests/codeigniter/database/query_builder/distinct_test.php
@@ -27,7 +27,7 @@
->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 d1f5628..3f63a60 100644
--- a/tests/codeigniter/database/query_builder/empty_test.php
+++ b/tests/codeigniter/database/query_builder/empty_test.php
@@ -25,7 +25,7 @@
// 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 @@
$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 27e678f..de6cd0a 100644
--- a/tests/codeigniter/database/query_builder/escape_test.php
+++ b/tests/codeigniter/database/query_builder/escape_test.php
@@ -37,7 +37,7 @@
$res = $this->db->query($sql)->result_array();
// Check the result
- $this->assertEquals(1, count($res));
+ $this->assertCount(1, $res);
}
// ------------------------------------------------------------------------
@@ -62,7 +62,7 @@
$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 7aaae34..5a4ac69 100644
--- a/tests/codeigniter/database/query_builder/from_test.php
+++ b/tests/codeigniter/database/query_builder/from_test.php
@@ -26,7 +26,7 @@
->get()
->result_array();
- $this->assertEquals(4, count($jobs));
+ $this->assertCount(4, $jobs);
}
// ------------------------------------------------------------------------
@@ -46,4 +46,4 @@
$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 5249f7c..b40e5e5 100644
--- a/tests/codeigniter/database/query_builder/group_test.php
+++ b/tests/codeigniter/database/query_builder/group_test.php
@@ -28,7 +28,7 @@
->get()
->result_array();
- $this->assertEquals(4, count($jobs));
+ $this->assertCount(4, $jobs);
}
// ------------------------------------------------------------------------
@@ -45,7 +45,6 @@
->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 2736fbe..3672afa 100644
--- a/tests/codeigniter/database/query_builder/like_test.php
+++ b/tests/codeigniter/database/query_builder/like_test.php
@@ -44,7 +44,7 @@
->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 @@
->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 @@
->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,8 @@
$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
+}
diff --git a/tests/codeigniter/database/query_builder/limit_test.php b/tests/codeigniter/database/query_builder/limit_test.php
index a0954c7..a1976d4 100644
--- a/tests/codeigniter/database/query_builder/limit_test.php
+++ b/tests/codeigniter/database/query_builder/limit_test.php
@@ -26,7 +26,7 @@
->get('job')
->result_array();
- $this->assertEquals(2, count($jobs));
+ $this->assertCount(2, $jobs);
}
// ------------------------------------------------------------------------
@@ -40,9 +40,9 @@
->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 46f452b..ff5bc54 100644
--- a/tests/codeigniter/database/query_builder/order_test.php
+++ b/tests/codeigniter/database/query_builder/order_test.php
@@ -27,7 +27,7 @@
->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 @@
->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 877b5d8..93b5c3d 100644
--- a/tests/codeigniter/database/query_builder/select_test.php
+++ b/tests/codeigniter/database/query_builder/select_test.php
@@ -28,8 +28,8 @@
// 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 @@
$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 09923c7..64abe28 100644
--- a/tests/codeigniter/database/query_builder/truncate_test.php
+++ b/tests/codeigniter/database/query_builder/truncate_test.php
@@ -24,7 +24,7 @@
{
// 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 @@
{
// 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 @@
$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 46a7fa2..8a7a09d 100644
--- a/tests/codeigniter/database/query_builder/where_test.php
+++ b/tests/codeigniter/database/query_builder/where_test.php
@@ -36,7 +36,7 @@
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 @@
$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 @@
$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 @@
->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 @@
->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 @@
->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 @@
$sql = $this->db->where('foo', $input)->get_compiled_select('dummy');
$this->assertEquals("'".$input."'", substr($sql, -20));
}
-}
\ No newline at end of file
+}