Fix test errors in Loader_test.php and URI_test.php
Change exceptions from Exception to RuntimeException since PHPUnit 3.6
doesn't like you to expect generic exceptions. The error it gives is:
InvalidArgumentException: You must not expect the generic exception class
travis-ci.org/#!/tiyowan/CodeIgniter/builds/832518
This issue addressed by using exceptions that are more specific.
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index 9ba870b..b86fd34 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -104,7 +104,7 @@
public function test_non_existent_model()
{
$this->setExpectedException(
- 'Exception',
+ 'RuntimeException',
'CI Error: Unable to locate the model you have specified: ci_test_nonexistent_model.php'
);
@@ -170,7 +170,7 @@
public function test_non_existent_view()
{
$this->setExpectedException(
- 'Exception',
+ 'RuntimeException',
'CI Error: Unable to load the requested file: ci_test_nonexistent_view.php'
);
@@ -192,7 +192,7 @@
$this->assertEquals($content, $load);
$this->setExpectedException(
- 'Exception',
+ 'RuntimeException',
'CI Error: Unable to load the requested file: ci_test_file_not_exists'
);
@@ -219,7 +219,7 @@
$this->assertEquals(NULL, $this->load->helper('array'));
$this->setExpectedException(
- 'Exception',
+ 'RuntimeException',
'CI Error: Unable to load the requested file: helpers/bad_helper.php'
);
@@ -256,7 +256,7 @@
$this->_setup_config_mock();
$this->setExpectedException(
- 'Exception',
+ 'RuntimeException',
'CI Error: The configuration file foobar.php does not exist.'
);
@@ -268,4 +268,4 @@
-}
\ No newline at end of file
+}
diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php
index 87d921b..40252aa 100644
--- a/tests/codeigniter/core/URI_test.php
+++ b/tests/codeigniter/core/URI_test.php
@@ -189,7 +189,7 @@
public function test_filter_uri_throws_error()
{
- $this->setExpectedException('Exception');
+ $this->setExpectedException('RuntimeException');
$this->uri->config->set_item('enable_query_strings', FALSE);
$this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-');
@@ -341,4 +341,4 @@
// END URI_test Class
/* End of file URI_test.php */
-/* Location: ./tests/core/URI_test.php */
\ No newline at end of file
+/* Location: ./tests/core/URI_test.php */
diff --git a/tests/lib/common.php b/tests/lib/common.php
index 6d29eb0..4a83258 100644
--- a/tests/lib/common.php
+++ b/tests/lib/common.php
@@ -87,17 +87,17 @@
function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
{
- throw new Exception('CI Error: '.$message);
+ throw new RuntimeException('CI Error: '.$message);
}
function show_404($page = '', $log_error = TRUE)
{
- throw new Exception('CI Error: 404');
+ throw new RuntimeException('CI Error: 404');
}
function _exception_handler($severity, $message, $filepath, $line)
{
- throw new Exception('CI Exception: '.$message.' | '.$filepath.' | '.$line);
+ throw new RuntimeException('CI Exception: '.$message.' | '.$filepath.' | '.$line);
}
@@ -129,4 +129,4 @@
return TRUE;
}
-// EOF
\ No newline at end of file
+// EOF