From f243ce13b4baf5bf8bebf36586514bb243dfc355 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 9 Jun 2012 23:34:21 +0300 Subject: Cleanup/optimize tests/mocks/ --- tests/mocks/core/common.php | 36 ++++++++++++++++-------------------- tests/mocks/core/input.php | 6 +++--- tests/mocks/core/loader.php | 7 ++++--- tests/mocks/core/security.php | 2 +- tests/mocks/core/uri.php | 9 +++++---- tests/mocks/core/utf8.php | 11 +++++------ 6 files changed, 34 insertions(+), 37 deletions(-) (limited to 'tests/mocks/core') diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php index e1c493aa0..8466e47f8 100644 --- a/tests/mocks/core/common.php +++ b/tests/mocks/core/common.php @@ -4,11 +4,10 @@ if ( ! function_exists('get_instance')) { - function &get_instance() + function &get_instance() { $test = CI_TestCase::instance(); - $instance = $test->ci_instance(); - return $instance; + return $test->ci_instance(); } } @@ -16,11 +15,10 @@ if ( ! function_exists('get_instance')) if ( ! function_exists('get_config')) { - function &get_config() { + function &get_config() + { $test = CI_TestCase::instance(); - $config = $test->ci_get_config(); - - return $config; + return $test->ci_get_config(); } } @@ -29,12 +27,12 @@ if ( ! function_exists('config_item')) function config_item($item) { $config =& get_config(); - + if ( ! isset($config[$item])) { return FALSE; } - + return $config[$item]; } } @@ -49,16 +47,16 @@ if ( ! function_exists('load_class')) { throw new Exception('Not Implemented: Non-core load_class()'); } - + $test = CI_TestCase::instance(); - + $obj =& $test->ci_core_class($class); - + if (is_string($obj)) { - throw new Exception('Bad Isolation: Use ci_set_core_class to set '.$class.''); + throw new Exception('Bad Isolation: Use ci_set_core_class to set '.$class); } - + return $obj; } } @@ -74,16 +72,16 @@ if ( ! function_exists('remove_invisible_characters')) function remove_invisible_characters($str, $url_encoded = TRUE) { $non_displayables = array(); - + // every control character except newline (dec 10) // carriage return (dec 13), and horizontal tab (dec 09) - + if ($url_encoded) { $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15 $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31 } - + $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 do @@ -166,6 +164,4 @@ if ( ! function_exists('set_status_header')) { return TRUE; } -} - -// EOF \ No newline at end of file +} \ No newline at end of file diff --git a/tests/mocks/core/input.php b/tests/mocks/core/input.php index 8a337d2ef..2a4aa4997 100644 --- a/tests/mocks/core/input.php +++ b/tests/mocks/core/input.php @@ -1,10 +1,10 @@ models_dir = vfsStream::newDirectory('models')->at(vfsStreamWrapper::getRoot()); $this->libs_dir = vfsStream::newDirectory('libraries')->at(vfsStreamWrapper::getRoot()); $this->helpers_dir = vfsStream::newDirectory('helpers')->at(vfsStreamWrapper::getRoot()); $this->views_dir = vfsStream::newDirectory('views')->at(vfsStreamWrapper::getRoot()); - + $this->_ci_ob_level = ob_get_level(); $this->_ci_library_paths = array(vfsStream::url('application').'/', BASEPATH); $this->_ci_helper_paths = array(vfsStream::url('application').'/', BASEPATH); $this->_ci_model_paths = array(vfsStream::url('application').'/'); $this->_ci_view_paths = array(vfsStream::url('application').'/views/' => TRUE); } + } \ No newline at end of file diff --git a/tests/mocks/core/security.php b/tests/mocks/core/security.php index d7ea0e6bd..e19a8b20b 100644 --- a/tests/mocks/core/security.php +++ b/tests/mocks/core/security.php @@ -1,7 +1,7 @@ ci_core_class('cfg'); - + // set predictable config values $test->ci_set_config(array( 'index_page' => 'index.php', @@ -14,12 +14,13 @@ class Mock_Core_URI extends CI_URI { 'subclass_prefix' => 'MY_' )); - $this->config = new $cls; + $this->config = new $cls; } - + protected function _is_cli_request() { return FALSE; } + } \ No newline at end of file diff --git a/tests/mocks/core/utf8.php b/tests/mocks/core/utf8.php index b77d717e7..068e74ac1 100644 --- a/tests/mocks/core/utf8.php +++ b/tests/mocks/core/utf8.php @@ -1,27 +1,26 @@