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/core/Benchmark_test.php b/tests/codeigniter/core/Benchmark_test.php
index 63b0e3d..33bd742 100644
--- a/tests/codeigniter/core/Benchmark_test.php
+++ b/tests/codeigniter/core/Benchmark_test.php
@@ -15,7 +15,7 @@
 
 		$this->benchmark->mark('code_start');
 
-		$this->assertEquals(1, count($this->benchmark->marker));
+		$this->assertCount(1, $this->benchmark->marker);
 		$this->assertArrayHasKey('code_start', $this->benchmark->marker);
 	}
 
@@ -64,4 +64,4 @@
 		$this->assertEquals('{memory_usage}', $this->benchmark->memory_usage());
 	}
 
-}
\ No newline at end of file
+}
diff --git a/tests/codeigniter/core/Common_test.php b/tests/codeigniter/core/Common_test.php
index ca19e5d..effae50 100644
--- a/tests/codeigniter/core/Common_test.php
+++ b/tests/codeigniter/core/Common_test.php
@@ -4,8 +4,8 @@
 
 	public function test_is_php()
 	{
-		$this->assertEquals(TRUE, is_php('1.2.0'));
-		$this->assertEquals(FALSE, is_php('9999.9.9'));
+		$this->assertTrue(is_php('1.2.0'));
+		$this->assertFalse(is_php('9999.9.9'));
 	}
 
 	// ------------------------------------------------------------------------
@@ -66,4 +66,4 @@
 		$removed_string = 'Here is a string containing url_encoded invisible text.';
 		$this->assertEquals($removed_string, remove_invisible_characters($raw_string));
 	}
-}
\ No newline at end of file
+}
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
index e1f4011..976941d 100644
--- a/tests/codeigniter/core/Input_test.php
+++ b/tests/codeigniter/core/Input_test.php
@@ -24,8 +24,8 @@
 
 	public function test_get_not_exists()
 	{
-		$this->assertTrue($this->input->get() === array());
-		$this->assertTrue($this->input->get('foo') === NULL);
+		$this->assertSame(array(), $this->input->get());
+		$this->assertNull($this->input->get('foo'));
 	}
 
 	// --------------------------------------------------------------------
@@ -55,8 +55,8 @@
 
 	public function test_post_not_exists()
 	{
-		$this->assertTrue($this->input->post() === array());
-		$this->assertTrue($this->input->post('foo') === NULL);
+		$this->assertSame(array(), $this->input->post());
+		$this->assertNull($this->input->post('foo'));
 	}
 
 	// --------------------------------------------------------------------
diff --git a/tests/codeigniter/core/Log_test.php b/tests/codeigniter/core/Log_test.php
index d5a6fcb..103af34 100644
--- a/tests/codeigniter/core/Log_test.php
+++ b/tests/codeigniter/core/Log_test.php
@@ -28,7 +28,7 @@
 		$this->assertEquals($date_fmt->getValue($instance), 'd.m.Y');
 		$this->assertEquals($file_ext->getValue($instance), 'php');
 		$this->assertEquals($file_perms->getValue($instance), 0644);
-		$this->assertEquals($enabled->getValue($instance), FALSE);
+		$this->assertFalse($enabled->getValue($instance));
 
 		$this->ci_set_config('log_path', '');
 		$this->ci_set_config('log_threshold', '0');
@@ -60,4 +60,4 @@
 			"LEVEL - Timestamp --> Message\n"
 		);
 	}
-}
\ No newline at end of file
+}
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
index 4c54ec9..c3113ad 100644
--- a/tests/codeigniter/core/Security_test.php
+++ b/tests/codeigniter/core/Security_test.php
@@ -252,7 +252,7 @@
 		// Perform hash
 		$this->security->xss_hash();
 
-		$this->assertTrue(preg_match('#^[0-9a-f]{32}$#iS', $this->security->xss_hash) === 1);
+		$this->assertRegExp('#^[0-9a-f]{32}$#iS', $this->security->xss_hash);
 	}
 
 	// --------------------------------------------------------------------
diff --git a/tests/codeigniter/core/Utf8_test.php b/tests/codeigniter/core/Utf8_test.php
index 7e6ffd9..a0327db 100644
--- a/tests/codeigniter/core/Utf8_test.php
+++ b/tests/codeigniter/core/Utf8_test.php
@@ -61,7 +61,7 @@
 		elseif (ICONV_ENABLED)
 		{
 			// This is a known issue, iconv doesn't always work with //IGNORE
-			$this->assertTrue(in_array($this->utf8->clean_string($illegal_utf8), array('тест', ''), TRUE));
+			$this->assertContains($utf8->clean_string($illegal_utf8), array('тест', ''));
 		}
 		else
 		{
@@ -88,4 +88,4 @@
 		}
 	}
 
-}
\ No newline at end of file
+}
diff --git a/tests/codeigniter/core/compat/password_test.php b/tests/codeigniter/core/compat/password_test.php
index 77f5eba..b6dbcfa 100644
--- a/tests/codeigniter/core/compat/password_test.php
+++ b/tests/codeigniter/core/compat/password_test.php
@@ -156,4 +156,4 @@
 		$this->assertTrue(password_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi'));
 	}
 
-}
\ No newline at end of file
+}
diff --git a/tests/codeigniter/database/DB_test.php b/tests/codeigniter/database/DB_test.php
index dc4fae9..9d53fd6 100644
--- a/tests/codeigniter/database/DB_test.php
+++ b/tests/codeigniter/database/DB_test.php
@@ -36,8 +36,8 @@
 
 		$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 @@
 		$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 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
+}
diff --git a/tests/codeigniter/helpers/array_helper_test.php b/tests/codeigniter/helpers/array_helper_test.php
index 5a99589..b2409c3 100644
--- a/tests/codeigniter/helpers/array_helper_test.php
+++ b/tests/codeigniter/helpers/array_helper_test.php
@@ -31,15 +31,15 @@
 		$this->assertEquals('my string', random_element('my string'));
 
 		// Test sending an array
-		$this->assertEquals(TRUE, in_array(random_element($this->my_array), $this->my_array));
+		$this->assertContains(random_element($this->my_array), $this->my_array);
 	}
 
 	// ------------------------------------------------------------------------
 
 	public function test_elements()
 	{
-		$this->assertEquals(TRUE, is_array(elements('test', $this->my_array)));
-		$this->assertEquals(TRUE, is_array(elements('foo', $this->my_array)));
+		$this->assertInternalType('array', elements('test', $this->my_array));
+		$this->assertInternalType('array', elements('foo', $this->my_array));
 	}
 
-}
\ No newline at end of file
+}
diff --git a/tests/codeigniter/libraries/Encryption_test.php b/tests/codeigniter/libraries/Encryption_test.php
index 99c5d4b..8e411d9 100644
--- a/tests/codeigniter/libraries/Encryption_test.php
+++ b/tests/codeigniter/libraries/Encryption_test.php
@@ -151,7 +151,7 @@
 			'hmac_key' => str_repeat("\x0", 16)
 		);
 
-		$this->assertTrue(is_array($this->encryption->__get_params($params)));
+		$this->assertInternalType('array', $this->encryption->__get_params($params));
 
 		$params['base64'] = TRUE;
 		$params['hmac_digest'] = 'sha512';
@@ -257,7 +257,7 @@
 			return $this->markTestSkipped('ext/mcrypt is deprecated since PHP 7.1 and will generate notices here.');
 		}
 
-		$this->assertTrue(is_resource($this->encryption->__driver_get_handle('mcrypt', 'rijndael-128', 'cbc')));
+		$this->assertInternalType('resource', $this->encryption->__driver_get_handle('mcrypt', 'rijndael-128', 'cbc'));
 	}
 
 	// --------------------------------------------------------------------
diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php
index fa9e86c..3280f5b 100644
--- a/tests/codeigniter/libraries/Form_validation_test.php
+++ b/tests/codeigniter/libraries/Form_validation_test.php
@@ -358,7 +358,7 @@
 		$this->form_validation->run();
 		$error_msg = $this->form_validation->error('foo');
 
-		$this->assertTrue(strrpos($error_msg, $prefix) === 0);
+		$this->assertStringStartsWith($prefix, $error_msg);
 		$this->assertTrue(strrpos($error_msg, $suffix, -strlen($suffix)) === (strlen($error_msg) - strlen($suffix)));
 
 		$_POST = array();
diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php
index 8e74524..f505a43 100644
--- a/tests/codeigniter/libraries/Table_test.php
+++ b/tests/codeigniter/libraries/Table_test.php
@@ -67,7 +67,7 @@
 		$this->table->add_row('your', 'pony', 'stinks');
 		$this->table->add_row('my pony', '>', 'your pony');
 
-		$this->assertEquals(count($this->table->rows), 3);
+		$this->assertCount(3, $this->table->rows);
 
 		$this->assertEquals(
 			array(
@@ -188,8 +188,8 @@
 		}
 
 		$this->assertFalse($this->table->auto_heading);
-		$this->assertEquals(count($this->table->heading), 3);
-		$this->assertEquals(count($this->table->rows), 2);
+		$this->assertCount(3, $this->table->heading);
+		$this->assertCount(2, $this->table->rows);
 
 		$this->table->clear();
 
@@ -213,7 +213,7 @@
 		$this->table->clear();
 
 		$this->table->set_from_array($data);
-		$this->assertEquals(count($this->table->rows), 2);
+		$this->assertCount(2, $this->table->rows);
 
 		$expected = array(
 			array('data' => 'name'),
@@ -270,14 +270,14 @@
 		$table = $this->table->generate($data);
 
 		// Test the table header
-		$this->assertTrue(strpos($table, '<th>Name</th>') !== FALSE);
-		$this->assertTrue(strpos($table, '<th>Color</th>') !== FALSE);
-		$this->assertTrue(strpos($table, '<th>Size</th>') !== FALSE);
+		$this->assertContains('<th>Name</th>', $table);
+		$this->assertContains('<th>Color</th>', $table);
+		$this->assertContains('<th>Size</th>', $table);
 
 		// Test the first entry
-		$this->assertTrue(strpos($table, '<td>Fred</td>') !== FALSE);
-		$this->assertTrue(strpos($table, '<td>Blue</td>') !== FALSE);
-		$this->assertTrue(strpos($table, '<td>Small</td>') !== FALSE);
+		$this->assertContains('<td>Fred</td>', $table);
+		$this->assertContains('<td>Blue</td>', $table);
+		$this->assertContains('<td>Small</td>', $table);
 	}
 
 }
@@ -297,4 +297,4 @@
 			array('name' => 'Foo Bar', 'email' => 'foo@bar.com')
 		);
 	}
-}
\ No newline at end of file
+}