From c576995304fc3609cca0b7b92d1b2cd611ec82f5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 16 Jan 2019 17:49:35 +0200 Subject: [ci skip] 3.1.10 release --- tests/mocks/autoloader.php | 119 --------- tests/mocks/ci_testcase.php | 384 ----------------------------- tests/mocks/ci_testconfig.php | 20 -- tests/mocks/core/common.php | 153 ------------ tests/mocks/core/input.php | 49 ---- tests/mocks/core/security.php | 35 --- tests/mocks/core/uri.php | 32 --- tests/mocks/core/utf8.php | 19 -- tests/mocks/database/ci_test.sqlite | Bin 19456 -> 0 bytes tests/mocks/database/config/mysql.php | 34 --- tests/mocks/database/config/mysqli.php | 34 --- tests/mocks/database/config/pdo/mysql.php | 37 --- tests/mocks/database/config/pdo/pgsql.php | 37 --- tests/mocks/database/config/pdo/sqlite.php | 37 --- tests/mocks/database/config/pgsql.php | 34 --- tests/mocks/database/config/sqlite.php | 34 --- tests/mocks/database/db.php | 142 ----------- tests/mocks/database/db/driver.php | 40 --- tests/mocks/database/drivers/mysql.php | 16 -- tests/mocks/database/drivers/mysqli.php | 16 -- tests/mocks/database/drivers/pdo.php | 15 -- tests/mocks/database/drivers/postgre.php | 16 -- tests/mocks/database/drivers/sqlite.php | 16 -- tests/mocks/database/schema/skeleton.php | 155 ------------ tests/mocks/libraries/driver.php | 27 -- tests/mocks/libraries/encrypt.php | 16 -- tests/mocks/libraries/encryption.php | 39 --- tests/mocks/libraries/session.php | 38 --- tests/mocks/libraries/table.php | 16 -- tests/mocks/uploads/ci_logo.gif | Bin 3270 -> 0 bytes 30 files changed, 1610 deletions(-) delete mode 100644 tests/mocks/autoloader.php delete mode 100644 tests/mocks/ci_testcase.php delete mode 100644 tests/mocks/ci_testconfig.php delete mode 100644 tests/mocks/core/common.php delete mode 100644 tests/mocks/core/input.php delete mode 100644 tests/mocks/core/security.php delete mode 100644 tests/mocks/core/uri.php delete mode 100644 tests/mocks/core/utf8.php delete mode 100755 tests/mocks/database/ci_test.sqlite delete mode 100644 tests/mocks/database/config/mysql.php delete mode 100644 tests/mocks/database/config/mysqli.php delete mode 100644 tests/mocks/database/config/pdo/mysql.php delete mode 100644 tests/mocks/database/config/pdo/pgsql.php delete mode 100644 tests/mocks/database/config/pdo/sqlite.php delete mode 100644 tests/mocks/database/config/pgsql.php delete mode 100644 tests/mocks/database/config/sqlite.php delete mode 100644 tests/mocks/database/db.php delete mode 100644 tests/mocks/database/db/driver.php delete mode 100644 tests/mocks/database/drivers/mysql.php delete mode 100644 tests/mocks/database/drivers/mysqli.php delete mode 100644 tests/mocks/database/drivers/pdo.php delete mode 100644 tests/mocks/database/drivers/postgre.php delete mode 100644 tests/mocks/database/drivers/sqlite.php delete mode 100644 tests/mocks/database/schema/skeleton.php delete mode 100644 tests/mocks/libraries/driver.php delete mode 100644 tests/mocks/libraries/encrypt.php delete mode 100644 tests/mocks/libraries/encryption.php delete mode 100644 tests/mocks/libraries/session.php delete mode 100644 tests/mocks/libraries/table.php delete mode 100644 tests/mocks/uploads/ci_logo.gif (limited to 'tests/mocks') diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php deleted file mode 100644 index 11825de2c..000000000 --- a/tests/mocks/autoloader.php +++ /dev/null @@ -1,119 +0,0 @@ - 'bm', - 'config' => 'cfg', - 'hooks' => 'ext', - 'utf8' => 'uni', - 'router' => 'rtr', - 'output' => 'out', - 'security' => 'sec', - 'input' => 'in', - 'lang' => 'lang', - 'loader' => 'load', - 'model' => 'model' - ); - - // -------------------------------------------------------------------- - - public function __construct($name = null, array $data = array(), $dataName = '') - { - parent::__construct($name, $data, $dataName); - $this->ci_instance = new stdClass(); - } - - // -------------------------------------------------------------------- - - public function setUp() - { - // Setup VFS with base directories - $this->ci_vfs_root = vfsStream::setup(); - $this->ci_app_root = vfsStream::newDirectory('application')->at($this->ci_vfs_root); - $this->ci_base_root = vfsStream::newDirectory('system')->at($this->ci_vfs_root); - $this->ci_view_root = vfsStream::newDirectory('views')->at($this->ci_app_root); - - if (method_exists($this, 'set_up')) - { - $this->set_up(); - } - } - - // -------------------------------------------------------------------- - - public function tearDown() - { - if (method_exists($this, 'tear_down')) - { - $this->tear_down(); - } - } - - // -------------------------------------------------------------------- - - public static function instance() - { - return self::$ci_test_instance; - } - - // -------------------------------------------------------------------- - - public function ci_set_config($key = '', $val = '') - { - // Add test config - if ( ! isset($this->ci_instance->config)) - { - $this->ci_instance->config = new CI_TestConfig(); - } - - // Empty key means just do setup above - if ($key === '') - { - return; - } - - if (is_array($key)) - { - $this->ci_instance->config->config = $key; - } - else - { - $this->ci_instance->config->config[$key] = $val; - } - } - - // -------------------------------------------------------------------- - - public function ci_get_config() - { - return isset($this->ci_instance->config) ? $this->ci_instance->config->config : array(); - } - - // -------------------------------------------------------------------- - - public function ci_instance($obj = FALSE) - { - if ( ! is_object($obj)) - { - return $this->ci_instance; - } - - $this->ci_instance = $obj; - } - - // -------------------------------------------------------------------- - - public function ci_instance_var($name, $obj = FALSE) - { - if ( ! is_object($obj)) - { - return $this->ci_instance->$name; - } - - $this->ci_instance->$name =& $obj; - } - - // -------------------------------------------------------------------- - - /** - * Grab a core class - * - * Loads the correct core class without extensions - * and returns a reference to the class name in the - * globals array with the correct key. This way the - * test can modify the variable it assigns to and - * still maintain the global. - */ - public function &ci_core_class($name) - { - $name = strtolower($name); - - if (isset($this->global_map[$name])) - { - $class_name = ucfirst($name); - $global_name = $this->global_map[$name]; - } - elseif (in_array($name, $this->global_map)) - { - $class_name = ucfirst(array_search($name, $this->global_map)); - $global_name = $name; - } - else - { - throw new Exception('Not a valid core class.'); - } - - if ( ! class_exists('CI_'.$class_name)) - { - require_once SYSTEM_PATH.'core/'.$class_name.'.php'; - } - - $GLOBALS[strtoupper($global_name)] = 'CI_'.$class_name; - return $GLOBALS[strtoupper($global_name)]; - } - - // -------------------------------------------------------------------- - - // convenience function for global mocks - public function ci_set_core_class($name, $obj) - { - $orig =& $this->ci_core_class($name); - $orig = $obj; - } - - /** - * Create VFS directory - * - * @param string Directory name - * @param object Optional root to create in - * @return object New directory object - */ - public function ci_vfs_mkdir($name, $root = NULL) - { - // Check for root - if ( ! $root) - { - $root = $this->ci_vfs_root; - } - - // Return new directory object - return vfsStream::newDirectory($name)->at($root); - } - - // -------------------------------------------------------------------- - - /** - * Create VFS content - * - * @param string File name - * @param string File content - * @param object VFS directory object - * @param mixed Optional subdirectory path or array of subs - * @return void - */ - public function ci_vfs_create($file, $content = '', $root = NULL, $path = NULL) - { - // Check for array - if (is_array($file)) - { - foreach ($file as $name => $content) - { - $this->ci_vfs_create($name, $content, $root, $path); - } - return; - } - - // Assert .php extension if none given - if (pathinfo($file, PATHINFO_EXTENSION) == '') - { - $file .= '.php'; - } - - // Build content - $tree = array($file => $content); - - // Check for path - $subs = array(); - if ($path) - { - // Explode if not array - $subs = is_array($path) ? $path : explode('/', trim($path, '/')); - } - - // Check for root - if ( ! $root) - { - // Use base VFS root - $root = $this->ci_vfs_root; - } - - // Handle subdirectories - while (($dir = array_shift($subs))) - { - // See if subdir exists under current root - $dir_root = $root->getChild($dir); - if ($dir_root) - { - // Yes - recurse into subdir - $root = $dir_root; - } - else - { - // No - put subdirectory back and quit - array_unshift($subs, $dir); - break; - } - } - - // Create any remaining subdirectories - if ($subs) - { - foreach (array_reverse($subs) as $dir) - { - // Wrap content in subdirectory for creation - $tree = array($dir => $tree); - } - } - - // Create tree - vfsStream::create($tree, $root); - } - - // -------------------------------------------------------------------- - - /** - * Clone a real file into VFS - * - * @param string Path from base directory - * @return bool TRUE on success, otherwise FALSE - */ - public function ci_vfs_clone($path, $dest='') - { - // Check for array - if (is_array($path)) - { - foreach ($path as $file) - { - $this->ci_vfs_clone($file, $dest); - } - return; - } - - // Get real file contents - $content = file_get_contents(PROJECT_BASE.$path); - if ($content === FALSE) - { - // Couldn't find file to clone - return FALSE; - } - - if (empty($dest)) - { - $dest = dirname($path); - } - - $this->ci_vfs_create(basename($path), $content, NULL, $dest); - return TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Helper to get a VFS URL path - * - * @param string Path - * @param string Optional base path - * @return string Path URL - */ - public function ci_vfs_path($path, $base = '') - { - // Check for base path - if ($base) - { - // Prepend to path - $path = rtrim($base, '/').'/'.ltrim($path, '/'); - - // Is it already in URL form? - if (strpos($path, '://') !== FALSE) - { - // Done - return path - return $path; - } - } - - // Trim leading slash and return URL - return vfsStream::url(ltrim($path, '/')); - } - - // -------------------------------------------------------------------- - // Internals - // -------------------------------------------------------------------- - - /** - * Overwrite runBare - * - * PHPUnit instantiates the test classes before - * running them individually. So right before a test - * runs we set our instance. Normally this step would - * happen in setUp, but someone is bound to forget to - * call the parent method and debugging this is no fun. - */ - public function runBare() - { - self::$ci_test_instance = $this; - parent::runBare(); - } - - // -------------------------------------------------------------------- - - public function helper($name) - { - require_once(SYSTEM_PATH.'helpers/'.$name.'_helper.php'); - } - - // -------------------------------------------------------------------- - - public function lang($name) - { - require(SYSTEM_PATH.'language/english/'.$name.'_lang.php'); - return $lang; - } - - // -------------------------------------------------------------------- - - /** - * This overload is useful to create a stub, that need to have a specific method. - */ - public function __call($method, $args) - { - if ($this->{$method} instanceof Closure) - { - return call_user_func_array($this->{$method},$args); - } - - return parent::__call($method, $args); - } - -} diff --git a/tests/mocks/ci_testconfig.php b/tests/mocks/ci_testconfig.php deleted file mode 100644 index afdb71001..000000000 --- a/tests/mocks/ci_testconfig.php +++ /dev/null @@ -1,20 +0,0 @@ -config[$key]) ? $this->config[$key] : FALSE; - } - - public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) - { - $this->loaded[] = $file; - return TRUE; - } - -} diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php deleted file mode 100644 index 2e8265b15..000000000 --- a/tests/mocks/core/common.php +++ /dev/null @@ -1,153 +0,0 @@ -ci_instance(); - return $test; - } -} - -// -------------------------------------------------------------------- - -if ( ! function_exists('get_config')) -{ - function &get_config() - { - $test = CI_TestCase::instance(); - $config = $test->ci_get_config(); - return $config; - } -} - -if ( ! function_exists('config_item')) -{ - function config_item($item) - { - $config =& get_config(); - - if ( ! isset($config[$item])) - { - return NULL; - } - - return $config[$item]; - } -} - -if ( ! function_exists('get_mimes')) -{ - /** - * Returns the MIME types array from config/mimes.php - * - * @return array - */ - function &get_mimes() - { - static $_mimes = array(); - - if (empty($_mimes)) - { - $path = realpath(PROJECT_BASE.'application/config/mimes.php'); - if (is_file($path)) - { - $_mimes = include($path); - } - } - - return $_mimes; - } -} - -// -------------------------------------------------------------------- - -/* -if ( ! function_exists('load_class')) -{ - function load_class($class, $directory = 'libraries', $prefix = 'CI_') - { - if ($directory !== 'core' OR $prefix !== 'CI_') - { - 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); - } - - return $obj; - } -} -*/ - -// Clean up error messages -// -------------------------------------------------------------------- - -if ( ! function_exists('show_error')) -{ - function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered') - { - throw new RuntimeException('CI Error: '.$message); - } -} - -if ( ! function_exists('show_404')) -{ - function show_404($page = '', $log_error = TRUE) - { - throw new RuntimeException('CI Error: 404'); - } -} - -if ( ! function_exists('_exception_handler')) -{ - function _exception_handler($severity, $message, $filepath, $line) - { - throw new RuntimeException('CI Exception: '.$message.' | '.$filepath.' | '.$line); - } -} - -// We assume a few things about our environment ... -// -------------------------------------------------------------------- -if ( ! function_exists('is_loaded')) -{ - function &is_loaded() - { - $loaded = array(); - return $loaded; - } -} - -if ( ! function_exists('log_message')) -{ - function log_message($level, $message) - { - return TRUE; - } -} - -if ( ! function_exists('set_status_header')) -{ - function set_status_header($code = 200, $text = '') - { - return TRUE; - } -} - -if ( ! function_exists('is_cli')) -{ - // In order to test HTTP functionality, we need to lie about this - function is_cli() - { - return FALSE; - } -} \ No newline at end of file diff --git a/tests/mocks/core/input.php b/tests/mocks/core/input.php deleted file mode 100644 index 40e27441f..000000000 --- a/tests/mocks/core/input.php +++ /dev/null @@ -1,49 +0,0 @@ -_allow_get_array = (config_item('allow_get_array') === TRUE); - $this->_enable_xss = (config_item('global_xss_filtering') === TRUE); - $this->_enable_csrf = (config_item('csrf_protection') === TRUE); - - // Assign Security and Utf8 classes - $this->security = $security; - $this->uni = $utf8; - - // Sanitize global arrays - $this->_sanitize_globals(); - } - - public function fetch_from_array($array, $index = '', $xss_clean = FALSE) - { - return parent::_fetch_from_array($array, $index, $xss_clean); - } - - /** - * Lie about being a CLI request - * - * We take advantage of this in libraries/Session_test - */ - public function is_cli_request() - { - return FALSE; - } - - public function __set($name, $value) - { - if ($name === 'ip_address') - { - $this->ip_address = $value; - } - } - -} \ No newline at end of file diff --git a/tests/mocks/core/security.php b/tests/mocks/core/security.php deleted file mode 100644 index 6cff85860..000000000 --- a/tests/mocks/core/security.php +++ /dev/null @@ -1,35 +0,0 @@ -{'_'.$property}) ? $this->{'_'.$property} : NULL; - } - - public function remove_evil_attributes($str, $is_image) - { - return $this->_remove_evil_attributes($str, $is_image); - } - - // Override inaccessible protected method - public function __call($method, $params) - { - if (is_callable(array($this, '_'.$method))) - { - return call_user_func_array(array($this, '_'.$method), $params); - } - - throw new BadMethodCallException('Method '.$method.' was not found'); - } - -} diff --git a/tests/mocks/core/uri.php b/tests/mocks/core/uri.php deleted file mode 100644 index 96ec5afa1..000000000 --- a/tests/mocks/core/uri.php +++ /dev/null @@ -1,32 +0,0 @@ -ci_core_class('cfg'); - - // set predictable config values - $test->ci_set_config(array( - 'index_page' => 'index.php', - 'base_url' => 'http://example.com/', - 'subclass_prefix' => 'MY_', - 'enable_query_strings' => FALSE, - 'permitted_uri_chars' => 'a-z 0-9~%.:_\-' - )); - - $this->config = new $cls; - - if ($this->config->item('enable_query_strings') !== TRUE OR is_cli()) - { - $this->_permitted_uri_chars = $this->config->item('permitted_uri_chars'); - } - } - - public function _set_permitted_uri_chars($value) - { - $this->_permitted_uri_chars = $value; - } - -} \ No newline at end of file diff --git a/tests/mocks/core/utf8.php b/tests/mocks/core/utf8.php deleted file mode 100644 index 3a6282e1d..000000000 --- a/tests/mocks/core/utf8.php +++ /dev/null @@ -1,19 +0,0 @@ - array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'travis', - 'password' => '', - 'database' => 'ci_test', - 'dbdriver' => 'mysql' - ), - - // Database configuration with failover - 'mysql_failover' => array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'not_travis', - 'password' => 'wrong password', - 'database' => 'not_ci_test', - 'dbdriver' => 'mysql', - 'failover' => array( - array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'travis', - 'password' => '', - 'database' => 'ci_test', - 'dbdriver' => 'mysql', - ) - ) - ) -); \ No newline at end of file diff --git a/tests/mocks/database/config/mysqli.php b/tests/mocks/database/config/mysqli.php deleted file mode 100644 index 5dd08abb2..000000000 --- a/tests/mocks/database/config/mysqli.php +++ /dev/null @@ -1,34 +0,0 @@ - array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'travis', - 'password' => '', - 'database' => 'ci_test', - 'dbdriver' => 'mysqli' - ), - - // Database configuration with failover - 'mysqli_failover' => array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'not_travis', - 'password' => 'wrong password', - 'database' => 'not_ci_test', - 'dbdriver' => 'mysqli', - 'failover' => array( - array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'travis', - 'password' => '', - 'database' => 'ci_test', - 'dbdriver' => 'mysqli', - ) - ) - ) -); \ No newline at end of file diff --git a/tests/mocks/database/config/pdo/mysql.php b/tests/mocks/database/config/pdo/mysql.php deleted file mode 100644 index 96608f787..000000000 --- a/tests/mocks/database/config/pdo/mysql.php +++ /dev/null @@ -1,37 +0,0 @@ - array( - 'dsn' => 'mysql:host=localhost;dbname=ci_test', - 'hostname' => 'localhost', - 'username' => 'travis', - 'password' => '', - 'database' => 'ci_test', - 'dbdriver' => 'pdo', - 'subdriver' => 'mysql' - ), - - // Database configuration with failover - 'pdo/mysql_failover' => array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'not_travis', - 'password' => 'wrong password', - 'database' => 'not_ci_test', - 'dbdriver' => 'pdo', - 'subdriver' => 'mysql', - 'failover' => array( - array( - 'dsn' => 'mysql:host=localhost;dbname=ci_test', - 'hostname' => 'localhost', - 'username' => 'travis', - 'password' => '', - 'database' => 'ci_test', - 'dbdriver' => 'pdo', - 'subdriver' => 'mysql' - ) - ) - ) -); \ No newline at end of file diff --git a/tests/mocks/database/config/pdo/pgsql.php b/tests/mocks/database/config/pdo/pgsql.php deleted file mode 100644 index e55e3ea77..000000000 --- a/tests/mocks/database/config/pdo/pgsql.php +++ /dev/null @@ -1,37 +0,0 @@ - array( - 'dsn' => 'pgsql:host=localhost;port=5432;dbname=ci_test;', - 'hostname' => 'localhost', - 'username' => 'postgres', - 'password' => '', - 'database' => 'ci_test', - 'dbdriver' => 'pdo', - 'subdriver' => 'pgsql' - ), - - // Database configuration with failover - 'pdo/pgsql_failover' => array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'not_travis', - 'password' => 'wrong password', - 'database' => 'not_ci_test', - 'dbdriver' => 'pdo', - 'subdriver' => 'pgsql', - 'failover' => array( - array( - 'dsn' => 'pgsql:host=localhost;port=5432;dbname=ci_test;', - 'hostname' => 'localhost', - 'username' => 'postgres', - 'password' => '', - 'database' => 'ci_test', - 'dbdriver' => 'pdo', - 'subdriver' => 'pgsql' - ) - ) - ) -); \ No newline at end of file diff --git a/tests/mocks/database/config/pdo/sqlite.php b/tests/mocks/database/config/pdo/sqlite.php deleted file mode 100644 index 1bf56b3ac..000000000 --- a/tests/mocks/database/config/pdo/sqlite.php +++ /dev/null @@ -1,37 +0,0 @@ - array( - 'dsn' => 'sqlite:/'.realpath(__DIR__.'/../..').'/ci_test.sqlite', - 'hostname' => 'localhost', - 'username' => 'sqlite', - 'password' => 'sqlite', - 'database' => 'sqlite', - 'dbdriver' => 'pdo', - 'subdriver' => 'sqlite' - ), - - // Database configuration with failover - 'pdo/sqlite_failover' => array( - 'dsn' => 'sqlite:not_exists.sqlite', - 'hostname' => 'localhost', - 'username' => 'sqlite', - 'password' => 'sqlite', - 'database' => 'sqlite', - 'dbdriver' => 'pdo', - 'subdriver' => 'sqlite', - 'failover' => array( - array( - 'dsn' => 'sqlite:/'.realpath(__DIR__.'/../..').'/ci_test.sqlite', - 'hostname' => 'localhost', - 'username' => 'sqlite', - 'password' => 'sqlite', - 'database' => 'sqlite', - 'dbdriver' => 'pdo', - 'subdriver' => 'sqlite' - ) - ) - ) -); \ No newline at end of file diff --git a/tests/mocks/database/config/pgsql.php b/tests/mocks/database/config/pgsql.php deleted file mode 100644 index 1444b0066..000000000 --- a/tests/mocks/database/config/pgsql.php +++ /dev/null @@ -1,34 +0,0 @@ - array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'postgres', - 'password' => '', - 'database' => 'ci_test', - 'dbdriver' => 'postgre' - ), - - // Database configuration with failover - 'pgsql_failover' => array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'not_travis', - 'password' => 'wrong password', - 'database' => 'not_ci_test', - 'dbdriver' => 'postgre', - 'failover' => array( - array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'postgres', - 'password' => '', - 'database' => 'ci_test', - 'dbdriver' => 'postgre', - ) - ) - ) -); \ No newline at end of file diff --git a/tests/mocks/database/config/sqlite.php b/tests/mocks/database/config/sqlite.php deleted file mode 100644 index d37ee4871..000000000 --- a/tests/mocks/database/config/sqlite.php +++ /dev/null @@ -1,34 +0,0 @@ - array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'sqlite', - 'password' => 'sqlite', - 'database' => realpath(__DIR__.'/..').'/ci_test.sqlite', - 'dbdriver' => 'sqlite3' - ), - - // Database configuration with failover - 'sqlite_failover' => array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'sqlite', - 'password' => 'sqlite', - 'database' => '../not_exists.sqlite', - 'dbdriver' => 'sqlite3', - 'failover' => array( - array( - 'dsn' => '', - 'hostname' => 'localhost', - 'username' => 'sqlite', - 'password' => 'sqlite', - 'database' => realpath(__DIR__.'/..').'/ci_test.sqlite', - 'dbdriver' => 'sqlite3' - ) - ) - ) -); \ No newline at end of file diff --git a/tests/mocks/database/db.php b/tests/mocks/database/db.php deleted file mode 100644 index 00dd884b0..000000000 --- a/tests/mocks/database/db.php +++ /dev/null @@ -1,142 +0,0 @@ -config = $config; - } - - /** - * Build DSN connection string for DB driver instantiate process - * - * @param string Group name - * @return string DSN Connection string - */ - public function set_dsn($group = 'default') - { - if ( ! isset($this->config[$group])) - { - throw new InvalidArgumentException('Group '.$group.' not exists'); - } - - self::$dbdriver = $this->config[$group]['dbdriver']; - if (isset($this->config[$group]['subdriver'])) - { - self::$subdriver = $this->config[$group]['subdriver']; - } - - $params = array( - 'dbprefix' => '', - 'pconnect' => FALSE, - 'db_debug' => FALSE, - 'cache_on' => FALSE, - 'cachedir' => '', - 'char_set' => 'utf8', - 'dbcollat' => 'utf8_general_ci', - 'swap_pre' => '', - 'stricton' => FALSE - ); - - $config = array_merge($this->config[$group], $params); - $dsnstring = empty($config['dsn']) ? FALSE : $config['dsn']; - $subdriver = empty($config['subdriver']) ? FALSE: $config['subdriver']; - $failover = empty($config['failover']) ? FALSE : $config['failover']; - - $dsn = $config['dbdriver'].'://'.$config['username'].':'.$config['password'] - .'@'.$config['hostname'].'/'.$config['database']; - - // Build the parameter - $other_params = array_slice($config, 6); - if ($dsnstring) $other_params['dsn'] = $dsnstring; - if ($subdriver) $other_params['subdriver'] = $subdriver; - if ($failover) $other_params['failover'] = $failover; - - return $dsn.'?'.http_build_query($other_params); - } - - /** - * Return a database config array - * - * @see ./config - * @param string Driver based configuration - * @return array - */ - public static function config($driver) - { - $dir = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR; - return include($dir.'config'.DIRECTORY_SEPARATOR.$driver.'.php'); - } - - /** - * Main DB method wrapper - * - * @param string Group or DSN string - * @param bool - * @return object - */ - public static function DB($group, $query_builder = FALSE) - { - // Create dummy driver and builder files to "load" - the mocks have - // already triggered autoloading of the real files - $case = CI_TestCase::instance(); - $driver = self::$dbdriver; - $subdriver = self::$subdriver; - $case->ci_vfs_create(array( - 'DB_driver.php' => '', - 'DB_result.php' => '', - 'DB_forge.php' => '', - 'DB_query_builder.php' => '' - ), '', $case->ci_base_root, 'database'); - if (file_exists(SYSTEM_PATH.'database/drivers/'.$driver.'/'.$driver.'_driver.php')) - { - $case->ci_vfs_create(array( - $driver.'_driver.php' => '', - $driver.'_result.php' => '', - $driver.'_forge.php' => '' - ), '', $case->ci_base_root, 'database/drivers/'.$driver); - } - if ($subdriver) - { - $case->ci_vfs_create(array( - $driver.'_'.$subdriver.'_driver.php' => '', - $driver.'_'.$subdriver.'_forge.php' => '' - ), '', $case->ci_base_root, 'database/drivers/'.$driver.'/subdrivers'); - } - - include_once(SYSTEM_PATH.'database/DB.php'); - - try - { - $db = DB($group, $query_builder); - } - catch (Exception $e) - { - throw new RuntimeException($e->getMessage()); - } - - return $db; - } - -} \ No newline at end of file diff --git a/tests/mocks/database/db/driver.php b/tests/mocks/database/db/driver.php deleted file mode 100644 index 86f7efd54..000000000 --- a/tests/mocks/database/db/driver.php +++ /dev/null @@ -1,40 +0,0 @@ -ci_db_driver = new $driver_class($config); - } - } - - /** - * Overloading method, emulate the actual driver method (multiple inheritance workaround) - */ - public function __call($method, $arguments) - { - if ( ! is_callable(array($this->ci_db_driver, $method))) - { - throw new BadMethodCallException($method. ' not exists or not implemented'); - } - - return call_user_func_array(array($this->ci_db_driver, $method), $arguments); - } - -} - -class CI_DB extends CI_DB_query_builder {} \ No newline at end of file diff --git a/tests/mocks/database/drivers/mysql.php b/tests/mocks/database/drivers/mysql.php deleted file mode 100644 index b7718ebaf..000000000 --- a/tests/mocks/database/drivers/mysql.php +++ /dev/null @@ -1,16 +0,0 @@ -=')) - { - error_reporting(E_ALL & ~E_DEPRECATED); - } - - $config = Mock_Database_DB::config($driver); - $connection = new Mock_Database_DB($config); - $db = Mock_Database_DB::DB($connection->set_dsn($driver), TRUE); - - CI_TestCase::instance()->ci_instance_var('db', $db); - - $loader = new CI_Loader(); - $loader->dbforge(); - $forge = CI_TestCase::instance()->ci_instance_var('dbforge'); - - self::$db = $db; - self::$forge = $forge; - self::$driver = $driver; - } - - return self::$db; - } - - /** - * Create the dummy tables - * - * @return void - */ - public static function create_tables() - { - // User Table - self::$forge->add_field(array( - 'id' => array( - 'type' => 'INTEGER', - 'constraint' => 3 - ), - 'name' => array( - 'type' => 'VARCHAR', - 'constraint' => 40 - ), - 'email' => array( - 'type' => 'VARCHAR', - 'constraint' => 100 - ), - 'country' => array( - 'type' => 'VARCHAR', - 'constraint' => 40 - ) - )); - self::$forge->add_key('id', TRUE); - self::$forge->create_table('user', TRUE); - - // Job Table - self::$forge->add_field(array( - 'id' => array( - 'type' => 'INTEGER', - 'constraint' => 3 - ), - 'name' => array( - 'type' => 'VARCHAR', - 'constraint' => 40 - ), - 'description' => array( - 'type' => 'TEXT' - ) - )); - self::$forge->add_key('id', TRUE); - self::$forge->create_table('job', TRUE); - - // Misc Table - self::$forge->add_field(array( - 'id' => array( - 'type' => 'INTEGER', - 'constraint' => 3 - ), - 'key' => array( - 'type' => 'VARCHAR', - 'constraint' => 40 - ), - 'value' => array( - 'type' => 'TEXT' - ) - )); - self::$forge->add_key('id', TRUE); - self::$forge->create_table('misc', TRUE); - } - - /** - * Create the dummy datas - * - * @return void - */ - public static function create_data() - { - // Job Data - $data = array( - 'user' => array( - array('id' => 1, 'name' => 'Derek Jones', 'email' => 'derek@world.com', 'country' => 'US'), - array('id' => 2, 'name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com', 'country' => 'Iran'), - array('id' => 3, 'name' => 'Richard A Causey', 'email' => 'richard@world.com', 'country' => 'US'), - array('id' => 4, 'name' => 'Chris Martin', 'email' => 'chris@world.com', 'country' => 'UK') - ), - 'job' => array( - array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'), - array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'), - array('id' => 3, 'name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'), - array('id' => 4, 'name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician') - ), - 'misc' => array( - array('id' => 1, 'key' => '\\xxxfoo456', 'value' => 'Entry with \\xxx'), - array('id' => 2, 'key' => '\\%foo456', 'value' => 'Entry with \\%'), - array('id' => 3, 'key' => 'spaces and tabs', 'value' => ' One two three tab') - ) - ); - - foreach ($data as $table => $dummy_data) - { - self::$db->truncate($table); - - foreach ($dummy_data as $single_dummy_data) - { - self::$db->insert($table, $single_dummy_data); - } - } - } - -} diff --git a/tests/mocks/libraries/driver.php b/tests/mocks/libraries/driver.php deleted file mode 100644 index 633194345..000000000 --- a/tests/mocks/libraries/driver.php +++ /dev/null @@ -1,27 +0,0 @@ -valid_drivers; - } - - $this->valid_drivers = (array) $drivers; - } - - /** - * Get library name - */ - public function get_name() - { - return $this->lib_name; - } -} \ No newline at end of file diff --git a/tests/mocks/libraries/encrypt.php b/tests/mocks/libraries/encrypt.php deleted file mode 100644 index c14d1e02f..000000000 --- a/tests/mocks/libraries/encrypt.php +++ /dev/null @@ -1,16 +0,0 @@ -_get_params($params); - } - - // -------------------------------------------------------------------- - - /** - * get_key() - * - * Allows checking for key changes. - */ - public function get_key() - { - return $this->_key; - } - - // -------------------------------------------------------------------- - - /** - * __driver_get_handle() - * - * Allows checking for _mcrypt_get_handle(), _openssl_get_handle() - */ - public function __driver_get_handle($driver, $cipher, $mode) - { - return $this->{'_'.$driver.'_get_handle'}($cipher, $mode); - } - -} \ No newline at end of file diff --git a/tests/mocks/libraries/session.php b/tests/mocks/libraries/session.php deleted file mode 100644 index adbecb329..000000000 --- a/tests/mocks/libraries/session.php +++ /dev/null @@ -1,38 +0,0 @@ -_flashdata_sweep(); - $this->_flashdata_mark(); - $this->_tempdata_sweep(); - } -} - -/** - * Mock cookie driver to overload cookie setting - */ -class Mock_Libraries_Session_cookie extends CI_Session_cookie { - /** - * Overload _setcookie to manage $_COOKIE values, since actual cookies can't be set in unit testing - */ - protected function _setcookie($name, $value = '', $expire = 0, $path = '', $domain = '', $secure = FALSE, $httponly = FALSE) - { - if (empty($value) OR $expire <= time()) - { - unset($_COOKIE[$name]); - } - else - { - $_COOKIE[$name] = $value; - } - } -} - -class Mock_Libraries_Session_native extends CI_Session_native {} \ No newline at end of file diff --git a/tests/mocks/libraries/table.php b/tests/mocks/libraries/table.php deleted file mode 100644 index 08f80072a..000000000 --- a/tests/mocks/libraries/table.php +++ /dev/null @@ -1,16 +0,0 @@ -