summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2017-06-19 10:33:58 +0200
committerAndrey Andreev <narf@devilix.net>2017-06-19 10:33:58 +0200
commit6c7a4266410070d30f8f6bcdf9c9e67f3d6478e3 (patch)
treef0aab8f6f5e781d5947b1a5553b6648eb7b7a4ab /tests
parent2459285b91d6fc4f5099f9f597529cce1059cb33 (diff)
[ci skip] 3.1.5 release
Diffstat (limited to 'tests')
-rw-r--r--tests/Bootstrap.php76
-rw-r--r--tests/README.md226
-rw-r--r--tests/codeigniter/Setup_test.php13
-rw-r--r--tests/codeigniter/core/Benchmark_test.php67
-rw-r--r--tests/codeigniter/core/Common_test.php69
-rw-r--r--tests/codeigniter/core/Config_test.php240
-rw-r--r--tests/codeigniter/core/Input_test.php281
-rw-r--r--tests/codeigniter/core/Lang_test.php101
-rw-r--r--tests/codeigniter/core/Loader_test.php583
-rw-r--r--tests/codeigniter/core/Log_test.php63
-rw-r--r--tests/codeigniter/core/Model_test.php37
-rw-r--r--tests/codeigniter/core/Output_test.php63
-rw-r--r--tests/codeigniter/core/Security_test.php353
-rw-r--r--tests/codeigniter/core/URI_test.php254
-rw-r--r--tests/codeigniter/core/Utf8_test.php91
-rw-r--r--tests/codeigniter/core/compat/hash_test.php77
-rw-r--r--tests/codeigniter/core/compat/mbstring_test.php54
-rw-r--r--tests/codeigniter/core/compat/password_test.php159
-rw-r--r--tests/codeigniter/core/compat/standard_test.php378
-rw-r--r--tests/codeigniter/database/DB_driver_test.php39
-rw-r--r--tests/codeigniter/database/DB_test.php61
-rw-r--r--tests/codeigniter/database/query_builder/count_test.php48
-rw-r--r--tests/codeigniter/database/query_builder/delete_test.php64
-rw-r--r--tests/codeigniter/database/query_builder/distinct_test.php33
-rw-r--r--tests/codeigniter/database/query_builder/empty_test.php39
-rw-r--r--tests/codeigniter/database/query_builder/escape_test.php68
-rw-r--r--tests/codeigniter/database/query_builder/from_test.php49
-rw-r--r--tests/codeigniter/database/query_builder/get_test.php53
-rw-r--r--tests/codeigniter/database/query_builder/group_test.php51
-rw-r--r--tests/codeigniter/database/query_builder/insert_test.php66
-rw-r--r--tests/codeigniter/database/query_builder/join_test.php101
-rw-r--r--tests/codeigniter/database/query_builder/like_test.php106
-rw-r--r--tests/codeigniter/database/query_builder/limit_test.php48
-rw-r--r--tests/codeigniter/database/query_builder/order_test.php55
-rw-r--r--tests/codeigniter/database/query_builder/select_test.php95
-rw-r--r--tests/codeigniter/database/query_builder/truncate_test.php56
-rw-r--r--tests/codeigniter/database/query_builder/update_test.php57
-rw-r--r--tests/codeigniter/database/query_builder/where_test.php134
-rw-r--r--tests/codeigniter/helpers/array_helper_test.php45
-rw-r--r--tests/codeigniter/helpers/captcha_helper_test.php10
-rw-r--r--tests/codeigniter/helpers/cookie_helper_test.php59
-rw-r--r--tests/codeigniter/helpers/date_helper_test.php325
-rw-r--r--tests/codeigniter/helpers/directory_helper_test.php59
-rw-r--r--tests/codeigniter/helpers/download_helper_test.php10
-rw-r--r--tests/codeigniter/helpers/email_helper_test.php24
-rw-r--r--tests/codeigniter/helpers/file_helper_test.php147
-rw-r--r--tests/codeigniter/helpers/form_helper_test.php290
-rw-r--r--tests/codeigniter/helpers/html_helper_test.php106
-rw-r--r--tests/codeigniter/helpers/inflector_helper_test.php96
-rw-r--r--tests/codeigniter/helpers/language_helper_test.php16
-rw-r--r--tests/codeigniter/helpers/number_helper_test.php63
-rw-r--r--tests/codeigniter/helpers/path_helper_test.php30
-rw-r--r--tests/codeigniter/helpers/security_helper_test.php64
-rw-r--r--tests/codeigniter/helpers/string_helper_test.php148
-rw-r--r--tests/codeigniter/helpers/text_helper_test.php174
-rw-r--r--tests/codeigniter/helpers/url_helper_test.php79
-rw-r--r--tests/codeigniter/helpers/xml_helper_test.php15
-rw-r--r--tests/codeigniter/libraries/Calendar_test.php222
-rw-r--r--tests/codeigniter/libraries/Driver_test.php178
-rw-r--r--tests/codeigniter/libraries/Encrypt_test.php79
-rw-r--r--tests/codeigniter/libraries/Encryption_test.php400
-rw-r--r--tests/codeigniter/libraries/Form_validation_test.php624
-rw-r--r--tests/codeigniter/libraries/Parser_test.php95
-rw-r--r--tests/codeigniter/libraries/Session_test.php440
-rw-r--r--tests/codeigniter/libraries/Table_test.php300
-rw-r--r--tests/codeigniter/libraries/Typography_test.php182
-rw-r--r--tests/codeigniter/libraries/Upload_test.php299
-rw-r--r--tests/codeigniter/libraries/Useragent_test.php125
-rw-r--r--tests/mocks/autoloader.php119
-rw-r--r--tests/mocks/ci_testcase.php386
-rw-r--r--tests/mocks/ci_testconfig.php20
-rw-r--r--tests/mocks/core/common.php153
-rw-r--r--tests/mocks/core/input.php49
-rw-r--r--tests/mocks/core/security.php35
-rw-r--r--tests/mocks/core/uri.php32
-rw-r--r--tests/mocks/core/utf8.php19
-rwxr-xr-xtests/mocks/database/ci_test.sqlitebin19456 -> 0 bytes
-rw-r--r--tests/mocks/database/config/mysql.php34
-rw-r--r--tests/mocks/database/config/mysqli.php34
-rw-r--r--tests/mocks/database/config/pdo/mysql.php37
-rw-r--r--tests/mocks/database/config/pdo/pgsql.php37
-rw-r--r--tests/mocks/database/config/pdo/sqlite.php37
-rw-r--r--tests/mocks/database/config/pgsql.php34
-rw-r--r--tests/mocks/database/config/sqlite.php34
-rw-r--r--tests/mocks/database/db.php142
-rw-r--r--tests/mocks/database/db/driver.php40
-rw-r--r--tests/mocks/database/drivers/mysql.php16
-rw-r--r--tests/mocks/database/drivers/mysqli.php16
-rw-r--r--tests/mocks/database/drivers/pdo.php15
-rw-r--r--tests/mocks/database/drivers/postgre.php16
-rw-r--r--tests/mocks/database/drivers/sqlite.php16
-rw-r--r--tests/mocks/database/schema/skeleton.php155
-rw-r--r--tests/mocks/libraries/driver.php27
-rw-r--r--tests/mocks/libraries/encrypt.php16
-rw-r--r--tests/mocks/libraries/encryption.php39
-rw-r--r--tests/mocks/libraries/session.php38
-rw-r--r--tests/mocks/libraries/table.php16
-rw-r--r--tests/mocks/uploads/ci_logo.gifbin3270 -> 0 bytes
-rw-r--r--tests/phpunit.xml24
-rw-r--r--tests/travis/mysql.phpunit.xml25
-rw-r--r--tests/travis/mysqli.phpunit.xml25
-rw-r--r--tests/travis/pdo/mysql.phpunit.xml25
-rw-r--r--tests/travis/pdo/pgsql.phpunit.xml25
-rw-r--r--tests/travis/pdo/sqlite.phpunit.xml25
-rw-r--r--tests/travis/pgsql.phpunit.xml25
-rw-r--r--tests/travis/sqlite.phpunit.xml25
106 files changed, 0 insertions, 10923 deletions
diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php
deleted file mode 100644
index b4e56bdae..000000000
--- a/tests/Bootstrap.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-// Errors on full!
-ini_set('display_errors', 1);
-error_reporting(E_ALL | E_STRICT);
-
-$dir = realpath(dirname(__FILE__));
-
-// Path constants
-defined('PROJECT_BASE') OR define('PROJECT_BASE', realpath($dir.'/../').'/');
-defined('SYSTEM_PATH') OR define('SYSTEM_PATH', PROJECT_BASE.'system/');
-
-// Get vfsStream either via PEAR or composer
-foreach (explode(PATH_SEPARATOR, get_include_path()) as $path)
-{
- if (file_exists($path.DIRECTORY_SEPARATOR.'vfsStream/vfsStream.php'))
- {
- require_once 'vfsStream/vfsStream.php';
- break;
- }
-}
-
-if ( ! class_exists('vfsStream') && file_exists(PROJECT_BASE.'vendor/autoload.php'))
-{
- include_once PROJECT_BASE.'vendor/autoload.php';
- class_alias('org\bovigo\vfs\vfsStream', 'vfsStream');
- class_alias('org\bovigo\vfs\vfsStreamDirectory', 'vfsStreamDirectory');
- class_alias('org\bovigo\vfs\vfsStreamWrapper', 'vfsStreamWrapper');
-}
-
-// Define CI path constants to VFS (filesystem setup in CI_TestCase::setUp)
-defined('BASEPATH') OR define('BASEPATH', vfsStream::url('system/'));
-defined('APPPATH') OR define('APPPATH', vfsStream::url('application/'));
-defined('VIEWPATH') OR define('VIEWPATH', APPPATH.'views/');
-defined('ENVIRONMENT') OR define('ENVIRONMENT', 'development');
-
-// Set localhost "remote" IP
-isset($_SERVER['REMOTE_ADDR']) OR $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
-
-// Prep our test environment
-include_once $dir.'/mocks/core/common.php';
-include_once SYSTEM_PATH.'core/Common.php';
-
-ini_set('default_charset', 'UTF-8');
-
-if (extension_loaded('mbstring'))
-{
- defined('MB_ENABLED') OR define('MB_ENABLED', TRUE);
- @ini_set('mbstring.internal_encoding', 'UTF-8');
- mb_substitute_character('none');
-}
-else
-{
- defined('MB_ENABLED') OR define('MB_ENABLED', FALSE);
-}
-
-if (extension_loaded('iconv'))
-{
- defined('ICONV_ENABLED') OR define('ICONV_ENABLED', TRUE);
- @ini_set('iconv.internal_encoding', 'UTF-8');
-}
-else
-{
- defined('ICONV_ENABLED') OR define('ICONV_ENABLED', FALSE);
-}
-
-is_php('5.6') && ini_set('php.internal_encoding', 'UTF-8');
-
-include_once SYSTEM_PATH.'core/compat/mbstring.php';
-include_once SYSTEM_PATH.'core/compat/hash.php';
-include_once SYSTEM_PATH.'core/compat/password.php';
-include_once SYSTEM_PATH.'core/compat/standard.php';
-
-include_once $dir.'/mocks/autoloader.php';
-spl_autoload_register('autoload');
-
-unset($dir); \ No newline at end of file
diff --git a/tests/README.md b/tests/README.md
deleted file mode 100644
index 04dfbc3d8..000000000
--- a/tests/README.md
+++ /dev/null
@@ -1,226 +0,0 @@
-# CodeIgniter Unit Tests #
-
-Status : [![Build Status](https://secure.travis-ci.org/bcit-ci/CodeIgniter.png?branch=develop)](http://travis-ci.org/bcit-ci/CodeIgniter)
-
-### Introduction:
-
-This is the preliminary CodeIgniter testing documentation. It
-will cover both internal as well as external APIs and the reasoning
-behind their implementation, where appropriate. As with all CodeIgniter
-documentation, this file should maintain a mostly human readable
-format to facilitate clean api design. [see http://arrenbrecht.ch/testing/]
-
-*First public draft: everything is subject to change*
-
-### Requirements
-
-PHP Unit >= 3.5.6
-
- pear channel-discover pear.phpunit.de
- pear channel-discover pear.symfony.com
- pear install phpunit/PHPUnit
-
-vfsStream
-
- pear channel-discover pear.bovigo.org
- pear install bovigo/vfsStream-beta
-
-#### Installation of PEAR and PHPUnit on Ubuntu
-
- Installation on Ubuntu requires a few steps. Depending on your setup you may
- need to use 'sudo' to install these. Mileage may vary but these steps are a
- good start.
-
- # Install the PEAR package
- sudo apt-get install php-pear
-
- # Add a few sources to PEAR
- pear channel-discover pear.phpunit.de
- pear channel-discover pear.symfony-project.com
- pear channel-discover components.ez.no
- pear channel-discover pear.bovigo.org
-
- # Finally install PHPUnit and vfsStream (including dependencies)
- pear install --alldeps phpunit/PHPUnit
- pear install --alldeps bovigo/vfsStream-beta
-
- # Finally, run 'phpunit' from within the ./tests directory
- # and you should be on your way!
-
-## Test Suites:
-
-CodeIgniter bootstraps a request very directly, with very flat class
-hierarchy. As a result, there is no main CodeIgniter class until the
-controller is instantiated.
-
-This has forced the core classes to be relatively decoupled, which is
-a good thing. However, it makes that portion of code relatively hard
-to test.
-
-Right now that means we'll probably have two core test suites, along
-with a base for application and package tests. That gives us:
-
-1. Bootstrap Test - test common.php and sanity check codeigniter.php [in planning]
-2. System Test - test core components in relative isolation [in development]
-3. Application Test - bootstrapping for application/tests [not started]
-4. Package Test - bootstrapping for <package>/tests [not started]
-
-### Test Environment:
-
-The test/Bootstrap.php file establishes global constants such as BASEPATH,
-APPPATH, and VIEWPATH, initializing them to point to VFS locations. The
-test case class employs vfsStream to make a clean virtual filesystem with
-the necessary paths for every individual test.
-
-Within each test case, VFS directory objects are available to use as arguments
-to the VFS convenience functions (see below):
-
-- ci_vfs_root: VFS filesystem root
-- ci_app_root: Application directory
-- ci_base_root: System directory
-- ci_view_root: Views directory
-
-Classes being instantiated for testing are read from the actual filesystem
-by the unit test autoloader, as are mockups created in tests/mocks. If you
-need access to the real system directory, the SYSTEM_PATH constant always
-points to it.
-
-Any other resources which need to be read from the path constants must be
-created or cloned within your test. Functions for doing so are outlined
-below.
-
-### CI_TestCase Documentation
-
-Test cases should extend CI_TestCase. This internally extends
-PHPUnit\_Framework\_TestCase, so you have access to all of your
-usual PHPUnit methods.
-
-We need to provide a simple way to modify the globals and the
-common function output. We also need to be able to mock up
-the super object as we please.
-
-Current API is *not stable*. Names and implementations will change.
-
- $this->ci_set_config($key, $val)
-
-Set the global config variables in a mock Config object. If key is an array,
-it will replace the entire config array. They are _not_ merged. If called
-without any parameters, it will create the mock object but not set any values.
-The mock Config object also provides rudimentary item() and load() stubs for
-delivering configured values to classes being tested and handling config load
-calls, respectively. The load() stub does _not_ actually load any files, it
-only records the filename provided. Check the config->loaded array to verify
-calls made.
-
- $this->ci_instance($obj)
-
-Set the object to use as the "super object", in a lot
-of cases this will be a simple stdClass with the attributes
-you need it to have. If no parameter, will return the instance.
-
- $this->ci_instance_var($name, $val)
-
-Add an attribute to the super object. This is useful if you
-set up a simple instance in setUp and then need to add different
-class mockups to your super object.
-
- $this->ci_core_class($name)
-
-Get the _class name_ of a core class, so that you can instantiate
-it. The variable is returned by reference and is tied to the correct
-$GLOBALS key. For example:
-
- $cfg =& $this->ci_core_class('cfg'); // returns 'CI_Config'
- $cfg = new $cfg; // instantiates config and overwrites the CFG global
-
- $this->ci_set_core_class($name, $obj)
-
-An alternative way to set one of the core globals.
-
- $this->ci_vfs_mkdir($name, $root)
-
-Creates a new directory in the test VFS. Pass a directory object to be the
-parent directory or none to create a root-level directory. Returns the new
-directory object.
-
- $this->ci_vfs_create($file, $content, $root, $path)
-
-Creates a new VFS file. '.php' is automatically appended to the filename if
-it has no extension. Pass a directory object as the root, and an optional path
-to recurse and/or create for containing the file. Path may be a string (such
-as 'models/subdir') or an array (e.g. - array('models', 'subdir') ). Existing
-directories in the VFS root will be recursed until a new directory is
-identified - all others in the path will be created, so you can mix-and-match
-old and new directories. If $file is an array (key = name, value = content),
-multiple files will be created in the same path.
-
- $this->ci_vfs_clone($path)
-
-Clones an existing file from the real filesystem to exist in the same path of
-the VFS. Path must be relative to the project root (i.e. - starting with
-'system' or 'application').
-
- $this->ci_vfs_path($path, $base)
-
-Creates a VFS file path string suitable for use with PHP file operations. Path
-may be absolute from the VFS root, or relative to a base path. It is often
-useful to use APPPATH or BASEPATH as the base.
-
- $this->helper($name)
-
-Loads a helper from the real filesystem.
-
- $this->lang($name)
-
-Loads a language file from the real filesystem and returns the $lang array.
-
- $this->ci_get_config() __internal__
-
-Returns the global config array. Internal as you shouldn't need to
-call this (you're setting it, after all). Used internally to make
-CI's get_config() work.
-
- CI_TestCase::instance() __internal__
-
-Returns an instance of the current test case. We force phpunit to
-run with backup-globals enabled, so this will always be the instance
-of the currently running test class.
-
-### Going forward
-
-#### 1. Bootstrap Test
-
-Testing common.php should be pretty simple. Include the file, and test the
-functions. May require some tweaking so that we can grab the statics from all
-methods (see is_loaded()). Testing the actual CodeIgniter.php file will most
-likely be an output test for the default view, with some object checking after
-the file runs. Needs consideration.
-
-#### 2. System Test
-
-Testing the core system relies on being able to isolate the core components
-as much as possible. A few of them access other core classes as globals. These
-should be mocked up and easy to manipulate.
-
-All functions in common.php should be a minimal implementation, or and mapped
-to a method in the test's parent class to gives us full control of their output.
-
-#### 3. Application Test:
-
-Not sure yet, needs to handle:
-
-- Libraries
-- Helpers
-- Models
-- MY_* files
-- Controllers (uh...?)
-- Views? (watir, selenium, cucumber?)
-- Database Testing
-
-#### 4. Package Test:
-
-I don't have a clue how this will work.
-
-Needs to be able to handle packages
-that are used multiple times within the application (i.e. EE/Pyro modules)
-as well as packages that are used by multiple applications (library distributions) \ No newline at end of file
diff --git a/tests/codeigniter/Setup_test.php b/tests/codeigniter/Setup_test.php
deleted file mode 100644
index 5317c56c7..000000000
--- a/tests/codeigniter/Setup_test.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-class Setup_test extends PHPUnit_Framework_TestCase {
-
- public function test_bootstrap_constants()
- {
- $this->assertTrue(defined('PROJECT_BASE'));
- $this->assertTrue(defined('BASEPATH'));
- $this->assertTrue(defined('APPPATH'));
- $this->assertTrue(defined('VIEWPATH'));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/core/Benchmark_test.php b/tests/codeigniter/core/Benchmark_test.php
deleted file mode 100644
index 63b0e3d5a..000000000
--- a/tests/codeigniter/core/Benchmark_test.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-
-class Benchmark_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->benchmark = new CI_Benchmark();
- }
-
- // --------------------------------------------------------------------
-
- public function test_mark()
- {
- $this->assertEmpty($this->benchmark->marker);
-
- $this->benchmark->mark('code_start');
-
- $this->assertEquals(1, count($this->benchmark->marker));
- $this->assertArrayHasKey('code_start', $this->benchmark->marker);
- }
-
- // --------------------------------------------------------------------
-
- public function test_elapsed_time()
- {
- $this->assertEquals('{elapsed_time}', $this->benchmark->elapsed_time());
- $this->assertEmpty($this->benchmark->elapsed_time('undefined_point'));
-
- $this->benchmark->mark('code_start');
- $this->benchmark->mark('code_end');
-
- // Override values, because time isn't testable, but make sure the markers were set
- if (isset($this->benchmark->marker['code_start']) && is_float($this->benchmark->marker['code_start']))
- {
- $this->benchmark->marker['code_start'] = 1389956144.1944;
- }
-
- if (isset($this->benchmark->marker['code_end']) && is_float($this->benchmark->marker['code_end']))
- {
- $this->benchmark->marker['code_end'] = 1389956145.1946;
- }
-
- $this->assertEquals('1', $this->benchmark->elapsed_time('code_start', 'code_end', 0));
- $this->assertEquals('1.0', $this->benchmark->elapsed_time('code_start', 'code_end', 1));
- $this->assertEquals('1.00', $this->benchmark->elapsed_time('code_start', 'code_end', 2));
- $this->assertEquals('1.000', $this->benchmark->elapsed_time('code_start', 'code_end', 3));
- $this->assertEquals('1.0002', $this->benchmark->elapsed_time('code_start', 'code_end', 4));
- $this->assertEquals('1.0002', $this->benchmark->elapsed_time('code_start', 'code_end'));
-
- // Test with non-existing 2nd marker, but again - we need to override the value
- $this->benchmark->elapsed_time('code_start', 'code_end2');
- if (isset($this->benchmark->marker['code_end2']) && is_float($this->benchmark->marker['code_end2']))
- {
- $this->benchmark->marker['code_end2'] = 1389956146.2046;
- }
-
- $this->assertEquals('2.0102', $this->benchmark->elapsed_time('code_start', 'code_end2'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_memory_usage()
- {
- $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
deleted file mode 100644
index ca19e5de0..000000000
--- a/tests/codeigniter/core/Common_test.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-
-class Common_test extends CI_TestCase {
-
- public function test_is_php()
- {
- $this->assertEquals(TRUE, is_php('1.2.0'));
- $this->assertEquals(FALSE, is_php('9999.9.9'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_stringify_attributes()
- {
- $this->assertEquals(' class="foo" id="bar"', _stringify_attributes(array('class' => 'foo', 'id' => 'bar')));
-
- $atts = new stdClass;
- $atts->class = 'foo';
- $atts->id = 'bar';
- $this->assertEquals(' class="foo" id="bar"', _stringify_attributes($atts));
-
- $atts = new stdClass;
- $this->assertEquals('', _stringify_attributes($atts));
-
- $this->assertEquals(' class="foo" id="bar"', _stringify_attributes('class="foo" id="bar"'));
-
- $this->assertEquals('', _stringify_attributes(array()));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_stringify_js_attributes()
- {
- $this->assertEquals('width=800,height=600', _stringify_attributes(array('width' => '800', 'height' => '600'), TRUE));
-
- $atts = new stdClass;
- $atts->width = 800;
- $atts->height = 600;
- $this->assertEquals('width=800,height=600', _stringify_attributes($atts, TRUE));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_html_escape()
- {
- $this->assertEquals(
- html_escape('Here is a string containing "quoted" text.'),
- 'Here is a string containing &quot;quoted&quot; text.'
- );
-
- $this->assertEquals(
- html_escape(array('associative' => 'and', array('multi' => 'dimentional'))),
- array('associative' => 'and', array('multi' => 'dimentional'))
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_remove_invisible_characters()
- {
- $raw_string = 'Here is a string containing invisible'.chr(0x08).' text %0e.';
- $removed_string = 'Here is a string containing invisible text %0e.';
- $this->assertEquals($removed_string, remove_invisible_characters($raw_string, FALSE));
-
- $raw_string = 'Here is a string %0econtaining url_encoded invisible%1F text.';
- $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/Config_test.php b/tests/codeigniter/core/Config_test.php
deleted file mode 100644
index b5c9e849d..000000000
--- a/tests/codeigniter/core/Config_test.php
+++ /dev/null
@@ -1,240 +0,0 @@
-<?php
-
-class Config_test extends CI_TestCase {
-
- public function set_up()
- {
- $cls =& $this->ci_core_class('cfg');
-
- // set predictable config values
- $this->cfg = array(
- 'index_page' => 'index.php',
- 'base_url' => 'http://example.com/',
- 'subclass_prefix' => 'MY_'
- );
- $this->ci_set_config($this->cfg);
-
- $this->config = new $cls;
- }
-
- // --------------------------------------------------------------------
-
- public function test_item()
- {
- $this->assertEquals($this->cfg['base_url'], $this->config->item('base_url'));
-
- // Bad Config value
- $this->assertNull($this->config->item('no_good_item'));
-
- // Index
- $this->assertNull($this->config->item('no_good_item', 'bad_index'));
- $this->assertNull($this->config->item('no_good_item', 'default'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_set_item()
- {
- $this->assertNull($this->config->item('not_yet_set'));
-
- $this->config->set_item('not_yet_set', 'is set');
- $this->assertEquals('is set', $this->config->item('not_yet_set'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_slash_item()
- {
- // Bad Config value
- $this->assertNull($this->config->slash_item('no_good_item'));
-
- $this->assertEquals($this->cfg['base_url'], $this->config->slash_item('base_url'));
- $this->assertEquals($this->cfg['subclass_prefix'].'/', $this->config->slash_item('subclass_prefix'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_base_url()
- {
- // Test regular base URL
- $base_url = $this->cfg['base_url'];
- $this->assertEquals($base_url, $this->config->base_url());
-
- // Test with URI
- $uri = 'test';
- $this->assertEquals($base_url.$uri, $this->config->base_url($uri));
-
- // Clear base_url
- $this->ci_set_config('base_url', '');
-
- // Rerun constructor
- $cls =& $this->ci_core_class('cfg');
- $this->config = new $cls;
-
- // Test default base
- $this->assertEquals('http://localhost/', $this->config->base_url());
-
- // Capture server vars
- $old_host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : NULL;
- $old_script_name = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : NULL;
- $old_script_filename = $_SERVER['SCRIPT_FILENAME'];
- $old_https = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : NULL;
- $old_server_addr = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : NULL;
-
- // The 'Host' header is user input and must not be trusted
- $_SERVER['HTTP_HOST'] = 'test.com';
- $this->config = new $cls;
- $this->assertEquals('http://localhost/', $this->config->base_url());
-
- // However, we may fallback to the server's IP address
- $_SERVER['SERVER_ADDR'] = '127.0.0.1';
- $_SERVER['SCRIPT_NAME'] = '/base_test.php';
- $_SERVER['SCRIPT_FILENAME'] = '/foo/bar/base_test.php';
- $this->config = new $cls;
- $this->assertEquals('http://127.0.0.1/', $this->config->base_url());
-
- // Making sure that HTTPS and URI path are also detected
- $_SERVER['HTTPS'] = 'on';
- $_SERVER['SCRIPT_NAME'] = '/path/base_test.php';
- $_SERVER['SCRIPT_FILENAME'] = '/foo/bar/path/base_test.php';
- $this->config = new $cls;
- $this->assertEquals('https://127.0.0.1/path/', $this->config->base_url());
-
- // Restore server vars
- $_SERVER['HTTP_HOST'] = $old_host;
- $_SERVER['SCRIPT_NAME'] = $old_script_name;
- $_SERVER['SCRIPT_FILENAME'] = $old_script_filename;
- $_SERVER['HTTPS'] = $old_https;
- $_SERVER['SERVER_ADDR'] = $old_server_addr;
- }
-
- // --------------------------------------------------------------------
-
- public function test_site_url()
- {
- $base_url = $this->cfg['base_url'];
- $index_page = $this->cfg['index_page'];
- $this->assertEquals($base_url.$index_page, $this->config->site_url());
-
- $old_base = $this->config->item('base_url');
- $this->config->set_item('base_url', '');
-
- $q_string = $this->config->item('enable_query_strings');
- $this->config->set_item('enable_query_strings', FALSE);
-
- $uri = 'test';
- $uri2 = '1';
- $this->assertEquals($index_page.'/'.$uri, $this->config->site_url($uri));
- $this->assertEquals($index_page.'/'.$uri.'/'.$uri2, $this->config->site_url(array($uri, $uri2)));
-
- $this->assertEquals($index_page.'/test/', $this->config->site_url('test/'));
-
- $suffix = 'ing';
- $this->config->set_item('url_suffix', $suffix);
-
- $arg = 'pass';
- $this->assertEquals($index_page.'/'.$uri.$suffix, $this->config->site_url($uri));
- $this->assertEquals($index_page.'/'.$uri.$suffix.'?'.$arg, $this->config->site_url($uri.'?'.$arg));
-
- $this->config->set_item('url_suffix', FALSE);
- $this->config->set_item('enable_query_strings', TRUE);
-
- $this->assertEquals($index_page.'?'.$uri, $this->config->site_url($uri));
- $this->assertEquals($index_page.'?0='.$uri.'&1='.$uri2, $this->config->site_url(array($uri, $uri2)));
-
- $this->config->set_item('base_url', $old_base);
-
- $this->assertEquals($base_url.$index_page.'?'.$uri, $this->config->site_url($uri));
-
- // back to home base
- $this->config->set_item('enable_query_strings', $q_string);
- }
-
- // --------------------------------------------------------------------
-
- public function test_system_url()
- {
- $this->assertEquals($this->cfg['base_url'].'system/', $this->config->system_url());
- }
-
- // --------------------------------------------------------------------
-
- public function test_load()
- {
- // Test regular load
- $file = 'test.php';
- $key = 'testconfig';
- $val = 'my_value';
- $cfg = array($key => $val);
- $this->ci_vfs_create($file, '<?php $config = '.var_export($cfg, TRUE).';', $this->ci_app_root, 'config');
- $this->assertTrue($this->config->load($file));
- $this->assertEquals($val, $this->config->item($key));
-
- // Test reload - value should not change
- $val2 = 'new_value';
- $cfg = array($key => $val2);
- $this->ci_vfs_create($file, '<?php $config = '.var_export($cfg, TRUE).';', $this->ci_app_root, 'config');
- $this->assertTrue($this->config->load($file));
- $this->assertEquals($val, $this->config->item($key));
-
- // Test section load
- $file = 'secttest';
- $cfg = array(
- 'one' => 'prime',
- 'two' => 2,
- 'three' => TRUE
- );
- $this->ci_vfs_create($file.'.php', '<?php $config = '.var_export($cfg, TRUE).';', $this->ci_app_root, 'config');
- $this->assertTrue($this->config->load($file, TRUE));
- $this->assertEquals($cfg, $this->config->item($file));
-
- // Test section merge
- $cfg2 = array(
- 'three' => 'tres',
- 'number' => 42,
- 'letter' => 'Z'
- );
-
- $pkg_dir = 'package';
- $this->ci_vfs_create(
- $file.'.php',
- '<?php $config = '.var_export($cfg2, TRUE).';',
- $this->ci_app_root,
- array($pkg_dir, 'config')
- );
- array_unshift($this->config->_config_paths, $this->ci_vfs_path($pkg_dir.'/', APPPATH));
- $this->assertTrue($this->config->load($file, TRUE));
- $this->assertEquals(array_merge($cfg, $cfg2), $this->config->item($file));
- array_shift($this->config->_config_paths);
-
- // Test graceful fail of invalid file
- $file = 'badfile';
- $this->ci_vfs_create($file, '', $this->ci_app_root, 'config');
- $this->assertFalse($this->config->load($file, FALSE, TRUE));
-
- // Test regular fail of invalid file
- $this->setExpectedException(
- 'RuntimeException',
- 'CI Error: Your '.$this->ci_vfs_path('config/'.$file.'.php', APPPATH).
- ' file does not appear to contain a valid configuration array.'
- );
- $this->assertNull($this->config->load($file));
- }
-
- // --------------------------------------------------------------------
-
- public function test_load_nonexistent()
- {
- // Test graceful fail of nonexistent file
- $this->assertFalse($this->config->load('not_config_file', FALSE, TRUE));
-
- // Test regular fail
- $file = 'absentia';
- $this->setExpectedException(
- 'RuntimeException',
- 'CI Error: The configuration file '.$file.'.php does not exist.'
- );
- $this->assertNull($this->config->load($file));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
deleted file mode 100644
index e1f4011b5..000000000
--- a/tests/codeigniter/core/Input_test.php
+++ /dev/null
@@ -1,281 +0,0 @@
-<?php
-
-class Input_test extends CI_TestCase {
-
- public function set_up()
- {
- // Set server variable to GET as default, since this will leave unset in STDIN env
- $_SERVER['REQUEST_METHOD'] = 'GET';
-
- // Set config for Input class
- $this->ci_set_config('allow_get_array', TRUE);
- $this->ci_set_config('global_xss_filtering', FALSE);
- $this->ci_set_config('csrf_protection', FALSE);
-
- $security = new Mock_Core_Security();
-
- $this->ci_set_config('charset', 'UTF-8');
- $utf8 = new Mock_Core_Utf8();
-
- $this->input = new Mock_Core_Input($security, $utf8);
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_not_exists()
- {
- $this->assertTrue($this->input->get() === array());
- $this->assertTrue($this->input->get('foo') === NULL);
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_exist()
- {
- $_SERVER['REQUEST_METHOD'] = 'GET';
- $_GET['foo'] = 'bar';
-
- $this->assertArrayHasKey('foo', $this->input->get());
- $this->assertEquals('bar', $this->input->get('foo'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_exist_with_xss_clean()
- {
- $_SERVER['REQUEST_METHOD'] = 'GET';
- $_GET['harm'] = "Hello, i try to <script>alert('Hack');</script> your site";
-
- $this->assertArrayHasKey('harm', $this->input->get());
- $this->assertEquals("Hello, i try to <script>alert('Hack');</script> your site", $this->input->get('harm'));
- $this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", $this->input->get('harm', TRUE));
- }
-
- // --------------------------------------------------------------------
-
- public function test_post_not_exists()
- {
- $this->assertTrue($this->input->post() === array());
- $this->assertTrue($this->input->post('foo') === NULL);
- }
-
- // --------------------------------------------------------------------
-
- public function test_post_exist()
- {
- $_SERVER['REQUEST_METHOD'] = 'POST';
- $_POST['foo'] = 'bar';
-
- $this->assertArrayHasKey('foo', $this->input->post());
- $this->assertEquals('bar', $this->input->post('foo'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_post_exist_with_xss_clean()
- {
- $_SERVER['REQUEST_METHOD'] = 'POST';
- $_POST['harm'] = "Hello, i try to <script>alert('Hack');</script> your site";
-
- $this->assertArrayHasKey('harm', $this->input->post());
- $this->assertEquals("Hello, i try to <script>alert('Hack');</script> your site", $this->input->post('harm'));
- $this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", $this->input->post('harm', TRUE));
- }
-
- // --------------------------------------------------------------------
-
- public function test_post_get()
- {
- $_SERVER['REQUEST_METHOD'] = 'POST';
- $_POST['foo'] = 'bar';
-
- $this->assertEquals('bar', $this->input->post_get('foo'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_post()
- {
- $_SERVER['REQUEST_METHOD'] = 'GET';
- $_GET['foo'] = 'bar';
-
- $this->assertEquals('bar', $this->input->get_post('foo'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_cookie()
- {
- $_COOKIE['foo'] = 'bar';
- $this->assertEquals('bar', $this->input->cookie('foo'));
- $this->assertNull($this->input->cookie('bar'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_server()
- {
- $this->assertEquals('GET', $this->input->server('REQUEST_METHOD'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_fetch_from_array()
- {
- $data = array(
- 'foo' => 'bar',
- 'harm' => 'Hello, i try to <script>alert(\'Hack\');</script> your site',
- );
-
- $foo = $this->input->fetch_from_array($data, 'foo');
- $harm = $this->input->fetch_from_array($data, 'harm');
- $harmless = $this->input->fetch_from_array($data, 'harm', TRUE);
-
- $this->assertEquals('bar', $foo);
- $this->assertEquals("Hello, i try to <script>alert('Hack');</script> your site", $harm);
- $this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", $harmless);
-
- $_SERVER['REQUEST_METHOD'] = 'POST';
- $_POST['foo']['bar'] = 'baz';
- $barArray = array('bar' => 'baz');
-
- $this->assertEquals('baz', $this->input->post('foo[bar]'));
- $this->assertEquals($barArray, $this->input->post('foo[]'));
- $this->assertNull($this->input->post('foo[baz]'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_valid_ip()
- {
- $this->assertTrue($this->input->valid_ip('192.18.0.1'));
- $this->assertTrue($this->input->valid_ip('192.18.0.1', 'ipv4'));
- $this->assertFalse($this->input->valid_ip('555.0.0.0'));
- $this->assertFalse($this->input->valid_ip('2001:db8:0:85a3::ac1f:8001', 'ipv4'));
-
- // v6 tests
- $this->assertFalse($this->input->valid_ip('192.18.0.1', 'ipv6'));
-
- $ip_v6 = array(
- '2001:0db8:0000:85a3:0000:0000:ac1f:8001',
- '2001:db8:0:85a3:0:0:ac1f:8001',
- '2001:db8:0:85a3::ac1f:8001'
- );
-
- foreach ($ip_v6 as $ip)
- {
- $this->assertTrue($this->input->valid_ip($ip));
- $this->assertTrue($this->input->valid_ip($ip, 'ipv6'));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_method()
- {
- $_SERVER['REQUEST_METHOD'] = 'GET';
- $this->assertEquals('get', $this->input->method());
- $this->assertEquals('GET', $this->input->method(TRUE));
- $_SERVER['REQUEST_METHOD'] = 'POST';
- $this->assertEquals('post', $this->input->method());
- $this->assertEquals('POST', $this->input->method(TRUE));
- }
-
- // --------------------------------------------------------------------
-
- public function test_is_ajax_request()
- {
- $this->assertFalse($this->input->is_ajax_request());
- $_SERVER['HTTP_X_REQUESTED_WITH'] = 'test';
- $this->assertFalse($this->input->is_ajax_request());
- $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
- $this->assertTrue($this->input->is_ajax_request());
- }
-
- // --------------------------------------------------------------------
-
- public function test_input_stream()
- {
- $this->markTestSkipped('TODO: Find a way to test input://');
- }
-
- // --------------------------------------------------------------------
-
- public function test_set_cookie()
- {
- $this->markTestSkipped('TODO: Find a way to test HTTP headers');
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_request_header()
- {
- $this->markTestSkipped('TODO: Find a way to test HTTP headers');
- }
-
- // --------------------------------------------------------------------
-
- public function test_ip_address()
- {
- $this->input->ip_address = '127.0.0.1';
- $this->assertEquals('127.0.0.1', $this->input->ip_address());
-
- // 127.0.0.1 is set in our Bootstrap file
- $this->input->ip_address = FALSE;
- $this->assertEquals('127.0.0.1', $this->input->ip_address());
-
- // Invalid
- $_SERVER['REMOTE_ADDR'] = 'invalid_ip_address';
- $this->input->ip_address = FALSE; // reset cached value
- $this->assertEquals('0.0.0.0', $this->input->ip_address());
-
- $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
-
- // Proxy_ips tests
- $this->input->ip_address = FALSE;
- $this->ci_set_config('proxy_ips', '127.0.0.3, 127.0.0.4, 127.0.0.2');
- $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2';
- $this->assertEquals('127.0.0.1', $this->input->ip_address());
-
- // Invalid spoof
- $this->input->ip_address = FALSE;
- $this->ci_set_config('proxy_ips', 'invalid_ip_address');
- $_SERVER['HTTP_CLIENT_IP'] = 'invalid_ip_address';
- $this->assertEquals('127.0.0.1', $this->input->ip_address());
-
- $this->input->ip_address = FALSE;
- $this->ci_set_config('proxy_ips', 'http://foo/bar/baz, 127.0.0.1/1');
- $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.1';
- $this->assertEquals('127.0.0.1', $this->input->ip_address());
-
- $this->input->ip_address = FALSE;
- $this->ci_set_config('proxy_ips', 'http://foo/bar/baz, 127.0.0.2');
- $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2';
- $_SERVER['REMOTE_ADDR'] = '127.0.0.2';
- $this->assertEquals('127.0.0.2', $this->input->ip_address());
-
- //IPv6
- $this->input->ip_address = FALSE;
- $this->ci_set_config('proxy_ips', 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329/1, FE80:0000:0000:0000:0202:B3FF:FE1E:8300/2');
- $_SERVER['HTTP_CLIENT_IP'] = 'FE80:0000:0000:0000:0202:B3FF:FE1E:8300';
- $_SERVER['REMOTE_ADDR'] = 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329';
- $this->assertEquals('FE80:0000:0000:0000:0202:B3FF:FE1E:8300', $this->input->ip_address());
-
- $this->input->ip_address = FALSE;
- $this->ci_set_config('proxy_ips', '0::/32');
- $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.7';
- $_SERVER['REMOTE_ADDR'] = '0000:0000:0000:0000:0000:0000:0000:0001';
- $this->assertEquals('127.0.0.7', $this->input->ip_address());
-
- $this->input->ip_address = FALSE;
- $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // back to reality
- }
-
- // --------------------------------------------------------------------
-
- public function test_user_agent()
- {
- $_SERVER['HTTP_USER_AGENT'] = 'test';
- $this->assertEquals('test', $this->input->user_agent());
- }
-}
diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php
deleted file mode 100644
index 4958f42e1..000000000
--- a/tests/codeigniter/core/Lang_test.php
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-
-class Lang_test extends CI_TestCase {
-
- protected $lang;
-
- public function set_up()
- {
- $loader_cls = $this->ci_core_class('load');
- $this->ci_instance_var('load', new $loader_cls);
- $cls = $this->ci_core_class('lang');
- $this->lang = new $cls;
- }
-
- // --------------------------------------------------------------------
-
- public function test_load()
- {
- // Regular usage
- $this->ci_vfs_clone('system/language/english/profiler_lang.php');
- $this->assertTrue($this->lang->load('profiler', 'english'));
- $this->assertEquals('URI STRING', $this->lang->language['profiler_uri_string']);
-
- // Already loaded file
- $this->assertNull($this->lang->load('profiler', 'english'));
-
- // Unspecified language (defaults to english)
- $this->ci_vfs_clone('system/language/english/date_lang.php');
- $this->assertTrue($this->lang->load('date'));
- $this->assertEquals('Year', $this->lang->language['date_year']);
-
- // A language other than english
- $this->ci_vfs_clone('system/language/english/email_lang.php', 'system/language/german/');
- $this->assertTrue($this->lang->load('email', 'german'));
- $this->assertEquals('german', $this->lang->is_loaded['email_lang.php']);
-
- // Non-existent file
- $this->setExpectedException(
- 'RuntimeException',
- 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php'
- );
- $this->lang->load('nonexistent');
- }
-
- // --------------------------------------------------------------------
-
- public function test_non_alpha_idiom()
- {
- // Non-alpha idiom (should act the same as unspecified language)
- // test with existing file
- $this->ci_vfs_clone('system/language/english/number_lang.php');
- $this->ci_vfs_clone('system/language/english/number_lang.php', 'system/language/123funny/');
- $this->assertTrue($this->lang->load('number', '123funny'));
- $this->assertEquals('Bytes', $this->lang->language['bytes']);
-
- // test without existing file
- $this->ci_vfs_clone('system/language/english/email_lang.php');
- $this->assertTrue($this->lang->load('email', '456funny'));
- $this->assertEquals('You did not specify a SMTP hostname.', $this->lang->language['email_no_hostname']);
- }
-
- // --------------------------------------------------------------------
-
- public function test_multiple_file_load()
- {
- // Multiple files
- $this->ci_vfs_clone('system/language/english/profiler_lang.php');
- $files = array(
- 0 => 'profiler',
- 1 => 'nonexistent'
- );
- $this->setExpectedException(
- 'RuntimeException',
- 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php'
- );
- $this->lang->load($files, 'english');
- }
-
- // --------------------------------------------------------------------
-
- public function test_alternative_path_load()
- {
- // Alternative Path
- $this->ci_vfs_clone('system/language/english/profiler_lang.php');
- $this->assertTrue($this->lang->load('profiler', 'english', FALSE, TRUE, 'vfs://system/'));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * @depends test_load
- */
- public function test_line()
- {
- $this->ci_vfs_clone('system/language/english/profiler_lang.php');
- $this->lang->load('profiler', 'english');
- $this->assertEquals('URI STRING', $this->lang->line('profiler_uri_string'));
- $this->assertFalse($this->lang->line('nonexistent_string'));
- $this->assertFalse($this->lang->line(NULL));
- }
-}
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
deleted file mode 100644
index 241c415b3..000000000
--- a/tests/codeigniter/core/Loader_test.php
+++ /dev/null
@@ -1,583 +0,0 @@
-<?php
-
-class Loader_test extends CI_TestCase {
-
- private $ci_obj;
-
- public function set_up()
- {
- // Instantiate a new loader
- $loader = $this->ci_core_class('loader');
- $this->load = new $loader();
-
- // Get CI instance
- $this->ci_obj = $this->ci_instance();
-
- // Set subclass prefix
- $this->prefix = 'MY_';
- $this->ci_set_config('subclass_prefix', $this->prefix);
- }
-
- // --------------------------------------------------------------------
-
- public function test_library()
- {
- // Test getting CI_Loader object
- $this->assertInstanceOf('CI_Loader', $this->load->library(NULL));
-
- // Create library in VFS
- $lib = 'unit_test_lib';
- $class = 'CI_'.ucfirst($lib);
- $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_base_root, 'libraries');
-
- // Test is_loaded fail
- $this->assertFalse($this->load->is_loaded(ucfirst($lib)));
-
- // Test loading as an array.
- $this->assertInstanceOf('CI_Loader', $this->load->library(array($lib)));
- $this->assertTrue(class_exists($class), $class.' does not exist');
- $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj);
-
- // Create library in VFS
- $lib = array('unit_test_lib' => 'unit_test_lib');
-
- // Test loading as an array (int).
- $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
- $this->assertTrue(class_exists($class), $class.' does not exist');
-
- // Test a string given to params
- $this->assertInstanceOf('CI_Loader', $this->load->library($lib, ' '));
-
- // test non existent lib
- $lib = 'non_existent_test_lib';
-
- $this->setExpectedException(
- 'RuntimeException',
- 'CI Error: Unable to load the requested class: '.ucfirst($lib)
- );
- $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
- }
-
- // --------------------------------------------------------------------
-
- public function test_bad_library()
- {
- $lib = 'bad_test_lib';
- $this->ci_vfs_create(ucfirst($lib), '', $this->ci_app_root, 'libraries');
- $this->setExpectedException(
- 'RuntimeException',
- 'CI Error: Non-existent class: '.ucfirst($lib)
- );
- $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
- }
-
- // --------------------------------------------------------------------
-
- public function test_library_extension()
- {
- // Create library and extension in VFS
- $name = 'ext_test_lib';
- $lib = ucfirst($name);
- $class = 'CI_'.$lib;
- $ext = $this->prefix.$lib;
- $this->ci_vfs_create($lib, '<?php class '.$class.' { }', $this->ci_base_root, 'libraries');
- $this->ci_vfs_create($ext, '<?php class '.$ext.' extends '.$class.' { }', $this->ci_app_root, 'libraries');
-
- // Test loading with extension
- $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
- $this->assertTrue(class_exists($class), $class.' does not exist');
- $this->assertTrue(class_exists($ext), $ext.' does not exist');
- $this->assertAttributeInstanceOf($class, $name, $this->ci_obj);
- $this->assertAttributeInstanceOf($ext, $name, $this->ci_obj);
-
- // Test reloading with object name
- $obj = 'exttest';
- $this->assertInstanceOf('CI_Loader', $this->load->library($lib, NULL, $obj));
- $this->assertAttributeInstanceOf($class, $obj, $this->ci_obj);
- $this->assertAttributeInstanceOf($ext, $obj, $this->ci_obj);
-
- // Test reloading
- unset($this->ci_obj->$name);
- $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
- $this->assertObjectNotHasAttribute($name, $this->ci_obj);
-
- // Create baseless library
- $name = 'ext_baseless_lib';
- $lib = ucfirst($name);
- $class = $this->prefix.$lib;
- $this->ci_vfs_create($class, '<?php class '.$class.' { }', $this->ci_app_root, 'libraries');
-
- // Test missing base class
- $this->setExpectedException(
- 'RuntimeException',
- 'CI Error: Unable to load the requested class: '.$lib
- );
- $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
- }
-
- // --------------------------------------------------------------------
-
- public function test_library_config()
- {
- // Create library in VFS
- $lib = 'unit_test_config_lib';
- $class = 'CI_'.ucfirst($lib);
- $content = '<?php class '.$class.' { public function __construct($params) { $this->config = $params; } }';
- $this->ci_vfs_create(ucfirst($lib), $content, $this->ci_base_root, 'libraries');
-
- // Create config file
- $cfg = array(
- 'foo' => 'bar',
- 'bar' => 'baz',
- 'baz' => false
- );
- $this->ci_vfs_create($lib, '<?php $config = '.var_export($cfg, TRUE).';', $this->ci_app_root, 'config');
-
- // Test object name and config
- $obj = 'testy';
- $this->assertInstanceOf('CI_Loader', $this->load->library($lib, NULL, $obj));
- $this->assertTrue(class_exists($class), $class.' does not exist');
- $this->assertAttributeInstanceOf($class, $obj, $this->ci_obj);
- $this->assertEquals($cfg, $this->ci_obj->$obj->config);
-
- // Test is_loaded
- $this->assertEquals($obj, $this->load->is_loaded(ucfirst($lib)));
-
- // Test to load another class with the same object name
- $lib = 'another_test_lib';
- $class = ucfirst($lib);
- $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, 'libraries');
- $this->setExpectedException(
- 'RuntimeException',
- "CI Error: Resource '".$obj."' already exists and is not a ".$class." instance."
- );
- $this->load->library($lib, NULL, $obj);
- }
-
- // --------------------------------------------------------------------
-
- public function test_load_library_in_application_dir()
- {
- // Create library in VFS
- $lib = 'super_test_library';
- $class = ucfirst($lib);
- $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, 'libraries');
-
- // Load library
- $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
-
- // Was the model class instantiated.
- $this->assertTrue(class_exists($class), $class.' does not exist');
- $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj);
- }
-
- // --------------------------------------------------------------------
-
- public function test_driver()
- {
- // Call the autoloader, to include system/libraries/Driver.php
- class_exists('CI_Driver_Library', TRUE);
-
- // Create driver in VFS
- $driver = 'unit_test_driver';
- $dir = ucfirst($driver);
- $class = 'CI_'.$dir;
- $content = '<?php class '.$class.' { } ';
- $this->ci_vfs_create(ucfirst($driver), $content, $this->ci_base_root, 'libraries/'.$dir);
-
- // Test loading as an array.
- $this->assertInstanceOf('CI_Loader', $this->load->driver(array($driver)));
- $this->assertTrue(class_exists($class), $class.' does not exist');
- $this->assertAttributeInstanceOf($class, $driver, $this->ci_obj);
-
- // Test loading as a library with a name
- $obj = 'testdrive';
- $this->assertInstanceOf('CI_Loader', $this->load->library($driver, NULL, $obj));
- $this->assertAttributeInstanceOf($class, $obj, $this->ci_obj);
-
- // Test a string given to params
- $this->assertInstanceOf('CI_Loader', $this->load->driver($driver, ' '));
- }
-
- // --------------------------------------------------------------------
-
- public function test_models()
- {
- $this->ci_set_core_class('model', 'CI_Model');
-
- // Create model in VFS
- $model = 'Unit_test_model';
- $content = '<?php class '.$model.' extends CI_Model {} ';
- $this->ci_vfs_create($model, $content, $this->ci_app_root, 'models');
-
- // Load model
- $this->assertInstanceOf('CI_Loader', $this->load->model($model));
-
- // Was the model class instantiated.
- $this->assertTrue(class_exists($model));
- $this->assertObjectHasAttribute($model, $this->ci_obj);
-
- // Test no model given
- $this->assertInstanceOf('CI_Loader', $this->load->model(''));
- }
-
- // --------------------------------------------------------------------
-
- public function test_model_subdir()
- {
- // Make sure base class is loaded - we'll test _ci_include later
- $this->ci_core_class('model');
-
- // Create modelin VFS
- $model = 'Test_sub_model';
- $base = 'CI_Model';
- $subdir = 'cars';
- $this->ci_vfs_create($model, '<?php class '.$model.' extends '.$base.' { }', $this->ci_app_root,
- array('models', $subdir));
-
- // Load model
- $name = 'testors';
- $this->assertInstanceOf('CI_Loader', $this->load->model($subdir.'/'.$model, $name));
-
- // Was the model class instantiated?
- $this->assertTrue(class_exists($model));
- $this->assertObjectHasAttribute($name, $this->ci_obj);
- $this->assertAttributeInstanceOf($base, $name, $this->ci_obj);
- $this->assertAttributeInstanceOf($model, $name, $this->ci_obj);
-
- // Test name conflict
- $obj = 'conflict';
- $this->ci_obj->$obj = new stdClass();
- $this->setExpectedException(
- 'RuntimeException',
- 'The model name you are loading is the name of a resource that is already being used: '.$obj
- );
- $this->load->model('not_real', $obj);
- }
-
- // --------------------------------------------------------------------
-
- public function test_non_existent_model()
- {
- $this->setExpectedException(
- 'RuntimeException',
- 'Unable to locate the model you have specified: Ci_test_nonexistent_model.php'
- );
-
- $this->load->model('ci_test_nonexistent_model.php');
- }
-
- // --------------------------------------------------------------------
-
- // public function testDatabase()
- // {
- // $this->assertInstanceOf('CI_Loader', $this->load->database());
- // $this->assertInstanceOf('CI_Loader', $this->load->dbutil());
- // }
-
- // --------------------------------------------------------------------
-
- public function test_load_view()
- {
- // Create view in VFS
- $view = 'unit_test_view';
- $var = 'hello';
- $value = 'World!';
- $content = 'This is my test page. ';
- $this->ci_vfs_create($view, $content.'<?php echo $'.$var.';', $this->ci_app_root, 'views');
-
- // Test returning view
- $out = $this->load->view($view, array($var => $value), TRUE);
- $this->assertEquals($content.$value, $out);
-
- // Mock output class
- $output = $this->getMockBuilder('CI_Output')->setMethods(array('append_output'))->getMock();
- $output->expects($this->once())->method('append_output')->with($content.$value);
- $this->ci_instance_var('output', $output);
-
- // Test view output and $vars as an object
- $vars = new stdClass();
- $vars->$var = $value;
- $this->assertInstanceOf('CI_Loader', $this->load->view($view, $vars));
- }
-
- // --------------------------------------------------------------------
-
- public function test_non_existent_view()
- {
- $this->setExpectedException(
- 'RuntimeException',
- 'CI Error: Unable to load the requested file: ci_test_nonexistent_view.php'
- );
-
- $this->load->view('ci_test_nonexistent_view', array('foo' => 'bar'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_file()
- {
- // Create view in VFS
- $dir = 'views';
- $file = 'ci_test_mock_file';
- $content = 'Here is a test file, which we will load now.';
- $this->ci_vfs_create($file, $content, $this->ci_app_root, $dir);
-
- // Just like load->view(), take the output class out of the mix here.
- $out = $this->load->file(APPPATH.$dir.'/'.$file.'.php', TRUE);
- $this->assertEquals($content, $out);
-
- // Test non-existent file
- $this->setExpectedException(
- 'RuntimeException',
- 'CI Error: Unable to load the requested file: ci_test_file_not_exists'
- );
-
- $this->load->file('ci_test_file_not_exists', TRUE);
- }
-
- // --------------------------------------------------------------------
-
- public function test_vars()
- {
- $key1 = 'foo';
- $val1 = 'bar';
- $key2 = 'boo';
- $val2 = 'hoo';
- $this->assertInstanceOf('CI_Loader', $this->load->vars(array($key1 => $val1)));
- $this->assertInstanceOf('CI_Loader', $this->load->vars($key2, $val2));
- $this->assertEquals($val1, $this->load->get_var($key1));
- $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars());
- }
-
- // --------------------------------------------------------------------
-
- public function test_clear_vars()
- {
- $key1 = 'foo';
- $val1 = 'bar';
- $key2 = 'boo';
- $val2 = 'hoo';
- $this->assertInstanceOf('CI_Loader', $this->load->vars(array($key1 => $val1)));
- $this->assertInstanceOf('CI_Loader', $this->load->vars($key2, $val2));
- $this->assertEquals($val1, $this->load->get_var($key1));
- $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars());
-
- $this->assertInstanceOf('CI_Loader', $this->load->clear_vars());
- $this->assertEquals('', $this->load->get_var($key1));
- $this->assertEquals('', $this->load->get_var($key2));
- }
-
- // --------------------------------------------------------------------
-
- public function test_helper()
- {
- // Create helper in VFS
- $helper = 'test';
- $func = '_my_helper_test_func';
- $content = '<?php function '.$func.'() { return TRUE; } ';
- $this->ci_vfs_create($helper.'_helper', $content, $this->ci_base_root, 'helpers');
-
- // Create helper extension
- $exfunc = '_my_extension_func';
- $content = '<?php function '.$exfunc.'() { return TRUE; } ';
- $this->ci_vfs_create($this->prefix.$helper.'_helper', $content, $this->ci_app_root, 'helpers');
-
- // Load helper
- $this->assertInstanceOf('CI_Loader', $this->load->helper($helper));
- $this->assertTrue(function_exists($func), $func.' does not exist');
- $this->assertTrue(function_exists($exfunc), $exfunc.' does not exist');
-
- // Create baseless extension
- $ext = 'bad_ext';
- $this->ci_vfs_create($this->prefix.$ext.'_helper', '', $this->ci_app_root, 'helpers');
-
- // Test bad extension
- $this->setExpectedException(
- 'RuntimeException',
- 'CI Error: Unable to load the requested file: helpers/'.$ext.'_helper.php'
- );
- $this->load->helper($ext);
- }
-
- // --------------------------------------------------------------------
-
- public function test_non_existent_helper()
- {
- $this->setExpectedException(
- 'RuntimeException',
- 'CI Error: Unable to load the requested file: helpers/bad_helper.php'
- );
- $this->load->helper('bad');
- }
-
- // --------------------------------------------------------------------
-
- public function test_loading_multiple_helpers()
- {
- // Create helpers in VFS
- $helpers = array();
- $funcs = array();
- $files = array();
- for ($i = 1; $i <= 3; ++$i) {
- $helper = 'test'.$i;
- $helpers[] = $helper;
- $func = '_my_helper_test_func'.$i;
- $funcs[] = $func;
- $files[$helper.'_helper'] = '<?php function '.$func.'() { return TRUE; } ';
- }
- $this->ci_vfs_create($files, NULL, $this->ci_base_root, 'helpers');
-
- // Load helpers
- $this->assertInstanceOf('CI_Loader', $this->load->helpers($helpers));
-
- // Verify helper existence
- foreach ($funcs as $func) {
- $this->assertTrue(function_exists($func), $func.' does not exist');
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_language()
- {
- // Mock lang class and test load call
- $file = 'test';
- $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
- $lang->expects($this->once())->method('load')->with($file);
- $this->ci_instance_var('lang', $lang);
- $this->assertInstanceOf('CI_Loader', $this->load->language($file));
- }
-
- // --------------------------------------------------------------------
-
- public function test_packages()
- {
- // Create model in VFS package path
- $dir = 'third-party';
- $lib = 'unit_test_package';
- $class = ucfirst($lib);
- $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, array($dir, 'libraries'));
-
- // Get paths
- $paths = $this->load->get_package_paths(TRUE);
-
- // Test failed load without path
- $this->setExpectedException(
- 'RuntimeException',
- 'CI Error: Unable to load the requested class: '.ucfirst($lib)
- );
- $this->load->library($lib);
-
- // Add path and verify
- $path = APPPATH.$dir.'/';
- $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path));
- $this->assertContains($path, $this->load->get_package_paths(TRUE));
-
- // Test successful load
- $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
- $this->assertTrue(class_exists($class), $class.' does not exist');
-
- // Add another path
- $path2 = APPPATH.'another/';
- $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path2));
- $this->assertContains($path2, $this->load->get_package_paths(TRUE));
-
- // Remove last path
- $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path());
- $this->assertNotContains($path2, $this->load->get_package_paths(TRUE));
-
- // Remove path and verify restored paths
- $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path($path));
- $this->assertEquals($paths, $this->load->get_package_paths(TRUE));
- }
-
- // --------------------------------------------------------------------
-
- public function test_remove_package_path()
- {
- $dir = 'third-party';
- $path = APPPATH.$dir.'/';
- $path2 = APPPATH.'another/';
- $paths = $this->load->get_package_paths(TRUE);
-
- $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path));
- $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path($path));
- $this->assertEquals($paths, $this->load->get_package_paths(TRUE));
-
- $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path2));
- $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path());
- $this->assertNotContains($path2, $this->load->get_package_paths(TRUE));
- }
-
- // --------------------------------------------------------------------
-
- public function test_load_config()
- {
- $cfg = 'someconfig';
- $this->assertTrue($this->load->config($cfg, FALSE));
- $this->assertContains($cfg, $this->ci_obj->config->loaded);
- }
-
- // --------------------------------------------------------------------
-
- public function test_initialize()
- {
- // Create helper in VFS
- $helper = 'autohelp';
- $hlp_func = '_autohelp_test_func';
- $content = '<?php function '.$hlp_func.'() { return TRUE; }';
- $this->ci_vfs_create($helper.'_helper', $content, $this->ci_app_root, 'helpers');
-
- // Create library in VFS
- $lib = 'autolib';
- $lib_class = 'CI_'.ucfirst($lib);
- $this->ci_vfs_create(ucfirst($lib), '<?php class '.$lib_class.' { }', $this->ci_base_root, 'libraries');
-
- // Create driver in VFS
- $drv = 'autodrv';
- $subdir = ucfirst($drv);
- $drv_class = 'CI_'.$subdir;
- $this->ci_vfs_create(ucfirst($drv), '<?php class '.$drv_class.' { }', $this->ci_base_root, array('libraries', $subdir));
-
- // Create model in VFS package path
- $dir = 'testdir';
- $path = APPPATH.$dir.'/';
- $model = 'Automod';
- $this->ci_vfs_create($model, '<?php class '.$model.' { }', $this->ci_app_root, array($dir, 'models'));
-
- // Create autoloader config
- $cfg = array(
- 'packages' => array($path),
- 'helper' => array($helper),
- 'libraries' => array($lib),
- 'drivers' => array($drv),
- 'model' => array($model),
- 'config' => array('config1', 'config2')
- );
- $this->ci_vfs_create('autoload', '<?php $autoload = '.var_export($cfg, TRUE).';', $this->ci_app_root, 'config');
-
- $this->load->initialize();
-
- // Verify path
- $this->assertContains($path, $this->load->get_package_paths());
-
- // Verify helper
- $this->assertTrue(function_exists($hlp_func), $hlp_func.' does not exist');
-
- // Verify library
- $this->assertTrue(class_exists($lib_class), $lib_class.' does not exist');
- $this->assertAttributeInstanceOf($lib_class, $lib, $this->ci_obj);
-
- // Verify driver
- $this->assertTrue(class_exists($drv_class), $drv_class.' does not exist');
- $this->assertAttributeInstanceOf($drv_class, $drv, $this->ci_obj);
-
- // Verify model
- $this->assertTrue(class_exists($model), $model.' does not exist');
- $this->assertAttributeInstanceOf($model, $model, $this->ci_obj);
-
- // Verify config calls
- $this->assertEquals($cfg['config'], $this->ci_obj->config->loaded);
- }
-}
diff --git a/tests/codeigniter/core/Log_test.php b/tests/codeigniter/core/Log_test.php
deleted file mode 100644
index d5a6fcb6b..000000000
--- a/tests/codeigniter/core/Log_test.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-class Log_test extends CI_TestCase {
-
- public function test_configuration()
- {
- $path = new ReflectionProperty('CI_Log', '_log_path');
- $path->setAccessible(TRUE);
- $threshold = new ReflectionProperty('CI_Log', '_threshold');
- $threshold->setAccessible(TRUE);
- $date_fmt = new ReflectionProperty('CI_Log', '_date_fmt');
- $date_fmt->setAccessible(TRUE);
- $file_ext = new ReflectionProperty('CI_Log', '_file_ext');
- $file_ext->setAccessible(TRUE);
- $file_perms = new ReflectionProperty('CI_Log', '_file_permissions');
- $file_perms->setAccessible(TRUE);
- $enabled = new ReflectionProperty('CI_Log', '_enabled');
- $enabled->setAccessible(TRUE);
-
- $this->ci_set_config('log_path', '/root/');
- $this->ci_set_config('log_threshold', 'z');
- $this->ci_set_config('log_date_format', 'd.m.Y');
- $this->ci_set_config('log_file_extension', '');
- $this->ci_set_config('log_file_permissions', '');
- $instance = new CI_Log();
-
- $this->assertEquals($path->getValue($instance), '/root/');
- $this->assertEquals($threshold->getValue($instance), 1);
- $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->ci_set_config('log_path', '');
- $this->ci_set_config('log_threshold', '0');
- $this->ci_set_config('log_date_format', '');
- $this->ci_set_config('log_file_extension', '.log');
- $this->ci_set_config('log_file_permissions', 0600);
- $instance = new CI_Log();
-
- $this->assertEquals($path->getValue($instance), APPPATH.'logs/');
- $this->assertEquals($threshold->getValue($instance), 0);
- $this->assertEquals($date_fmt->getValue($instance), 'Y-m-d H:i:s');
- $this->assertEquals($file_ext->getValue($instance), 'log');
- $this->assertEquals($file_perms->getValue($instance), 0600);
- $this->assertEquals($enabled->getValue($instance), TRUE);
- }
-
- // --------------------------------------------------------------------
-
- public function test_format_line()
- {
- $this->ci_set_config('log_path', '');
- $this->ci_set_config('log_threshold', 0);
- $instance = new CI_Log();
-
- $format_line = new ReflectionMethod($instance, '_format_line');
- $format_line->setAccessible(TRUE);
- $this->assertEquals(
- $format_line->invoke($instance, 'LEVEL', 'Timestamp', 'Message'),
- "LEVEL - Timestamp --> Message\n"
- );
- }
-} \ No newline at end of file
diff --git a/tests/codeigniter/core/Model_test.php b/tests/codeigniter/core/Model_test.php
deleted file mode 100644
index 80dc97b3b..000000000
--- a/tests/codeigniter/core/Model_test.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-class Model_test extends CI_TestCase {
-
- private $ci_obj;
-
- public function set_up()
- {
- $loader = $this->ci_core_class('loader');
- $this->load = new $loader();
- $this->ci_obj = $this->ci_instance();
- $this->ci_set_core_class('model', 'CI_Model');
-
- $model_code =<<<MODEL
-<?php
-class Test_model extends CI_Model {
-
- public \$property = 'foo';
-
-}
-MODEL;
-
- $this->ci_vfs_create('Test_model', $model_code, $this->ci_app_root, 'models');
- $this->load->model('test_model');
- }
-
- // --------------------------------------------------------------------
-
- public function test__get()
- {
- $this->assertEquals('foo', $this->ci_obj->test_model->property);
-
- $this->ci_obj->controller_property = 'bar';
- $this->assertEquals('bar', $this->ci_obj->test_model->controller_property);
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/core/Output_test.php b/tests/codeigniter/core/Output_test.php
deleted file mode 100644
index 887c077d7..000000000
--- a/tests/codeigniter/core/Output_test.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-
-class Output_test extends CI_TestCase {
-
- public $output;
- protected $_output_data = '';
-
- public function set_up()
- {
- $this->_output_data =<<<HTML
- <html>
- <head>
- <title>Basic HTML</title>
- </head>
- <body>
- Test
- </body>
- </html>
-HTML;
- $this->ci_set_config('charset', 'UTF-8');
- $output = $this->ci_core_class('output');
- $this->output = new $output();
- }
-
- // --------------------------------------------------------------------
-
- public function test_set_get_append_output()
- {
- $append = "<!-- comment /-->\n";
-
- $this->assertEquals(
- $this->_output_data.$append,
- $this->output
- ->set_output($this->_output_data)
- ->append_output("<!-- comment /-->\n")
- ->get_output()
- );
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_content_type()
- {
- $this->assertEquals('text/html', $this->output->get_content_type());
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_header()
- {
- $this->assertNull($this->output->get_header('Non-Existent-Header'));
-
- // TODO: Find a way to test header() values as well. Currently,
- // PHPUnit prevents this by not using output buffering.
-
- $this->output->set_content_type('text/plain', 'WINDOWS-1251');
- $this->assertEquals(
- 'text/plain; charset=WINDOWS-1251',
- $this->output->get_header('content-type')
- );
- }
-
-}
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
deleted file mode 100644
index 4c54ec9fa..000000000
--- a/tests/codeigniter/core/Security_test.php
+++ /dev/null
@@ -1,353 +0,0 @@
-<?php
-
-class Security_test extends CI_TestCase {
-
- public function set_up()
- {
- // Set cookie for security test
- $_COOKIE['ci_csrf_cookie'] = md5(uniqid(mt_rand(), TRUE));
-
- // Set config for Security class
- $this->ci_set_config('csrf_protection', TRUE);
- $this->ci_set_config('csrf_token_name', 'ci_csrf_token');
- $this->ci_set_config('csrf_cookie_name', 'ci_csrf_cookie');
-
- $this->security = new Mock_Core_Security();
- }
-
- // --------------------------------------------------------------------
-
- public function test_csrf_verify()
- {
- $_SERVER['REQUEST_METHOD'] = 'GET';
-
- $this->assertInstanceOf('CI_Security', $this->security->csrf_verify());
- }
-
- // --------------------------------------------------------------------
-
- public function test_csrf_verify_invalid()
- {
- // Without issuing $_POST[csrf_token_name], this request will triggering CSRF error
- $_SERVER['REQUEST_METHOD'] = 'POST';
-
- $this->setExpectedException('RuntimeException', 'CI Error: The action you have requested is not allowed');
-
- $this->security->csrf_verify();
- }
-
- // --------------------------------------------------------------------
-
- public function test_csrf_verify_valid()
- {
- $_SERVER['REQUEST_METHOD'] = 'POST';
- $_POST[$this->security->csrf_token_name] = $this->security->csrf_hash;
-
- $this->assertInstanceOf('CI_Security', $this->security->csrf_verify());
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_csrf_hash()
- {
- $this->assertEquals($this->security->csrf_hash, $this->security->get_csrf_hash());
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_csrf_token_name()
- {
- $this->assertEquals('ci_csrf_token', $this->security->get_csrf_token_name());
- }
-
- // --------------------------------------------------------------------
-
- public function test_xss_clean()
- {
- $harm_string = "Hello, i try to <script>alert('Hack');</script> your site";
-
- $harmless_string = $this->security->xss_clean($harm_string);
-
- $this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", $harmless_string);
- }
-
- // --------------------------------------------------------------------
-
- public function test_xss_clean_string_array()
- {
- $harm_strings = array(
- "Hello, i try to <script>alert('Hack');</script> your site",
- "Simple clean string",
- "Hello, i try to <script>alert('Hack');</script> your site"
- );
-
- $harmless_strings = $this->security->xss_clean($harm_strings);
-
- $this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", $harmless_strings[0]);
- $this->assertEquals("Simple clean string", $harmless_strings[1]);
- $this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", $harmless_strings[2]);
- }
-
- // --------------------------------------------------------------------
-
- public function test_xss_clean_image_valid()
- {
- $harm_string = '<img src="test.png">';
-
- $xss_clean_return = $this->security->xss_clean($harm_string, TRUE);
-
-// $this->assertTrue($xss_clean_return);
- }
-
- // --------------------------------------------------------------------
-
- public function test_xss_clean_image_invalid()
- {
- $harm_string = '<img src=javascript:alert(String.fromCharCode(88,83,83))>';
-
- $xss_clean_return = $this->security->xss_clean($harm_string, TRUE);
-
- $this->assertFalse($xss_clean_return);
- }
-
- // --------------------------------------------------------------------
-
- public function test_xss_clean_entity_double_encoded()
- {
- $input = '<a href="&#38&#35&#49&#48&#54&#38&#35&#57&#55&#38&#35&#49&#49&#56&#38&#35&#57&#55&#38&#35&#49&#49&#53&#38&#35&#57&#57&#38&#35&#49&#49&#52&#38&#35&#49&#48&#53&#38&#35&#49&#49&#50&#38&#35&#49&#49&#54&#38&#35&#53&#56&#38&#35&#57&#57&#38&#35&#49&#49&#49&#38&#35&#49&#49&#48&#38&#35&#49&#48&#50&#38&#35&#49&#48&#53&#38&#35&#49&#49&#52&#38&#35&#49&#48&#57&#38&#35&#52&#48&#38&#35&#52&#57&#38&#35&#52&#49">Clickhere</a>';
- $this->assertEquals('<a>Clickhere</a>', $this->security->xss_clean($input));
- }
-
- // --------------------------------------------------------------------
-
- public function text_xss_clean_js_link_removal()
- {
- // This one is to prevent a false positive
- $this->assertEquals(
- "<a href=\"javascrip\n<t\n:alert\n&#40;1&#41;\"\n>",
- $this->security->xss_clean("<a href=\"javascrip\n<t\n:alert\n(1)\"\n>")
- );
- }
-
- // --------------------------------------------------------------------
-
- public function test_xss_clean_js_img_removal()
- {
- $input = '<img src="&#38&#35&#49&#48&#54&#38&#35&#57&#55&#38&#35&#49&#49&#56&#38&#35&#57&#55&#38&#35&#49&#49&#53&#38&#35&#57&#57&#38&#35&#49&#49&#52&#38&#35&#49&#48&#53&#38&#35&#49&#49&#50&#38&#35&#49&#49&#54&#38&#35&#53&#56&#38&#35&#57&#57&#38&#35&#49&#49&#49&#38&#35&#49&#49&#48&#38&#35&#49&#48&#50&#38&#35&#49&#48&#53&#38&#35&#49&#49&#52&#38&#35&#49&#48&#57&#38&#35&#52&#48&#38&#35&#52&#57&#38&#35&#52&#49">Clickhere';
- $this->assertEquals('<img>', $this->security->xss_clean($input));
- }
-
- // --------------------------------------------------------------------
-
- public function test_xss_clean_sanitize_naughty_html_tags()
- {
- $this->assertEquals('&lt;unclosedTag', $this->security->xss_clean('<unclosedTag'));
- $this->assertEquals('&lt;blink&gt;', $this->security->xss_clean('<blink>'));
- $this->assertEquals('<fubar>', $this->security->xss_clean('<fubar>'));
-
- $this->assertEquals(
- '<img svg=""> src="x">',
- $this->security->xss_clean('<img <svg=""> src="x">')
- );
-
- $this->assertEquals(
- '<img src="b on=">on=">"x onerror="alert&#40;1&#41;">',
- $this->security->xss_clean('<img src="b on="<x">on=">"x onerror="alert(1)">')
- );
-
- $this->assertEquals(
- "\n>&lt;!-\n<b d=\"'e><iframe onload=alert&#40;1&#41; src=x>\n<a HREF=\">\n",
- $this->security->xss_clean("\n><!-\n<b\n<c d=\"'e><iframe onload=alert(1) src=x>\n<a HREF=\"\">\n")
- );
- }
-
- // --------------------------------------------------------------------
-
- public function test_xss_clean_sanitize_naughty_html_attributes()
- {
- $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo onAttribute="bar">'));
- $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo onAttributeNoQuotes=bar>'));
- $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo onAttributeWithSpaces = bar>'));
- $this->assertEquals('<foo prefixOnAttribute="bar">', $this->security->xss_clean('<foo prefixOnAttribute="bar">'));
- $this->assertEquals('<foo>onOutsideOfTag=test</foo>', $this->security->xss_clean('<foo>onOutsideOfTag=test</foo>'));
- $this->assertEquals('onNoTagAtAll = true', $this->security->xss_clean('onNoTagAtAll = true'));
- $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo fscommand=case-insensitive>'));
- $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo seekSegmentTime=whatever>'));
-
- $this->assertEquals(
- '<foo bar=">" baz=\'>\' xss=removed>',
- $this->security->xss_clean('<foo bar=">" baz=\'>\' onAfterGreaterThan="quotes">')
- );
- $this->assertEquals(
- '<foo bar=">" baz=\'>\' xss=removed>',
- $this->security->xss_clean('<foo bar=">" baz=\'>\' onAfterGreaterThan=noQuotes>')
- );
-
- $this->assertEquals(
- '<img src="x" on=""> on=&lt;svg&gt; onerror=alert&#40;1&#41;>',
- $this->security->xss_clean('<img src="x" on=""> on=<svg> onerror=alert(1)>')
- );
-
- $this->assertEquals(
- '<img src="on=\'">"&lt;svg&gt; onerror=alert&#40;1&#41; onmouseover=alert&#40;1&#41;>',
- $this->security->xss_clean('<img src="on=\'">"<svg> onerror=alert(1) onmouseover=alert(1)>')
- );
-
- $this->assertEquals(
- '<img src="x"> on=\'x\' onerror=``,alert&#40;1&#41;>',
- $this->security->xss_clean('<img src="x"> on=\'x\' onerror=``,alert(1)>')
- );
-
- $this->assertEquals(
- '<a xss=removed>',
- $this->security->xss_clean('<a< onmouseover="alert(1)">')
- );
-
- $this->assertEquals(
- '<img src="x"> on=\'x\' onerror=,xssm()>',
- $this->security->xss_clean('<img src="x"> on=\'x\' onerror=,xssm()>')
- );
-
- $this->assertEquals(
- '<image src="<>" xss=removed>',
- $this->security->xss_clean('<image src="<>" onerror=\'alert(1)\'>')
- );
-
- $this->assertEquals(
- '<b xss=removed>',
- $this->security->xss_clean('<b "=<= onmouseover=alert(1)>')
- );
-
- $this->assertEquals(
- '<b xss=removed xss=removed>1">',
- $this->security->xss_clean('<b a=<=" onmouseover="alert(1),1>1">')
- );
-
- $this->assertEquals(
- '<b x=" onmouseover=alert&#40;1&#41;//">',
- $this->security->xss_clean('<b "="< x=" onmouseover=alert(1)//">')
- );
- }
-
- // --------------------------------------------------------------------
-
- /**
- * @depends test_xss_clean_sanitize_naughty_html_tags
- * @depends test_xss_clean_sanitize_naughty_html_attributes
- */
- public function test_naughty_html_plus_evil_attributes()
- {
- $this->assertEquals(
- '&lt;svg<img src="x" xss=removed>',
- $this->security->xss_clean('<svg<img > src="x" onerror="location=/javascript/.source+/:alert/.source+/(1)/.source">')
- );
- }
-
- // --------------------------------------------------------------------
-
- public function test_xss_hash()
- {
- $this->assertEmpty($this->security->xss_hash);
-
- // Perform hash
- $this->security->xss_hash();
-
- $this->assertTrue(preg_match('#^[0-9a-f]{32}$#iS', $this->security->xss_hash) === 1);
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_random_bytes()
- {
- $length = "invalid";
- $this->assertFalse($this->security->get_random_bytes($length));
-
- $length = 10;
- $this->assertNotEmpty($this->security->get_random_bytes($length));
- }
-
- // --------------------------------------------------------------------
-
- public function test_entity_decode()
- {
- $encoded = '&lt;div&gt;Hello &lt;b&gt;Booya&lt;/b&gt;&lt;/div&gt;';
- $decoded = $this->security->entity_decode($encoded);
-
- $this->assertEquals('<div>Hello <b>Booya</b></div>', $decoded);
-
- $this->assertEquals('colon:', $this->security->entity_decode('colon&colon;'));
- $this->assertEquals("NewLine\n", $this->security->entity_decode('NewLine&NewLine;'));
- $this->assertEquals("Tab\t", $this->security->entity_decode('Tab&Tab;'));
- $this->assertEquals("lpar(", $this->security->entity_decode('lpar&lpar;'));
- $this->assertEquals("rpar)", $this->security->entity_decode('rpar&rpar;'));
-
- // Issue #3057 (https://github.com/bcit-ci/CodeIgniter/issues/3057)
- $this->assertEquals(
- '&foo should not include a semicolon',
- $this->security->entity_decode('&foo should not include a semicolon')
- );
- }
-
- // --------------------------------------------------------------------
-
- public function test_sanitize_filename()
- {
- $filename = './<!--foo-->';
- $safe_filename = $this->security->sanitize_filename($filename);
-
- $this->assertEquals('foo', $safe_filename);
- }
-
- // --------------------------------------------------------------------
-
- public function test_strip_image_tags()
- {
- $imgtags = array(
- '<img src="smiley.gif" alt="Smiley face" height="42" width="42">',
- '<img alt="Smiley face" height="42" width="42" src="smiley.gif">',
- '<img src="http://www.w3schools.com/images/w3schools_green.jpg">',
- '<img src="/img/sunset.gif" height="100%" width="100%">',
- '<img src="mdn-logo-sm.png" alt="MD Logo" srcset="mdn-logo-HD.png 2x, mdn-logo-small.png 15w, mdn-banner-HD.png 100w 2x" />',
- '<img sqrc="/img/sunset.gif" height="100%" width="100%">',
- '<img srqc="/img/sunset.gif" height="100%" width="100%">',
- '<img srcq="/img/sunset.gif" height="100%" width="100%">',
- '<img src=non-quoted.attribute foo="bar">'
- );
-
- $urls = array(
- 'smiley.gif',
- 'smiley.gif',
- 'http://www.w3schools.com/images/w3schools_green.jpg',
- '/img/sunset.gif',
- 'mdn-logo-sm.png',
- '<img sqrc="/img/sunset.gif" height="100%" width="100%">',
- '<img srqc="/img/sunset.gif" height="100%" width="100%">',
- '<img srcq="/img/sunset.gif" height="100%" width="100%">',
- 'non-quoted.attribute'
- );
-
- for ($i = 0; $i < count($imgtags); $i++)
- {
- $this->assertEquals($urls[$i], $this->security->strip_image_tags($imgtags[$i]));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_csrf_set_hash()
- {
- // Set cookie for security test
- $_COOKIE['ci_csrf_cookie'] = md5(uniqid(mt_rand(), TRUE));
-
- // Set config for Security class
- $this->ci_set_config('csrf_protection', TRUE);
- $this->ci_set_config('csrf_token_name', 'ci_csrf_token');
-
- // leave csrf_cookie_name as blank to test _csrf_set_hash function
- $this->ci_set_config('csrf_cookie_name', '');
-
- $this->security = new Mock_Core_Security();
-
- $this->assertNotEmpty($this->security->get_csrf_hash());
- }
-}
diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php
deleted file mode 100644
index 42dff3639..000000000
--- a/tests/codeigniter/core/URI_test.php
+++ /dev/null
@@ -1,254 +0,0 @@
-<?php
-
-class URI_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->uri = new Mock_Core_URI();
- }
-
- // --------------------------------------------------------------------
-
- /* As of the following commit, _set_uri_string() is a protected method:
-
- https://github.com/bcit-ci/CodeIgniter/commit/d461934184d95b0cfb2feec93f27b621ef72a5c2
-
- public function test_set_uri_string()
- {
- // Slashes get killed
- $this->uri->_set_uri_string('/');
- $this->assertEquals('', $this->uri->uri_string);
-
- $this->uri->_set_uri_string('nice/uri');
- $this->assertEquals('nice/uri', $this->uri->uri_string);
- }
- */
-
- // --------------------------------------------------------------------
-
- /*
-
- This has been moved to the constructor
-
- public function test_fetch_uri_string()
- {
- define('SELF', 'index.php');
-
- // uri_protocol: AUTO
- $this->uri->config->set_item('uri_protocol', 'AUTO');
-
- // Test a variety of request uris
- $requests = array(
- '/index.php/controller/method' => 'controller/method',
- '/index.php?/controller/method' => 'controller/method',
- '/index.php?/controller/method/?var=foo' => 'controller/method'
- );
-
- foreach ($requests as $request => $expected)
- {
- $_SERVER['SCRIPT_NAME'] = '/index.php';
- $_SERVER['REQUEST_URI'] = $request;
-
- $this->uri->_fetch_uri_string();
- $this->assertEquals($expected, $this->uri->uri_string);
- }
-
- // Test a subfolder
- $_SERVER['SCRIPT_NAME'] = '/subfolder/index.php';
- $_SERVER['REQUEST_URI'] = '/subfolder/index.php/controller/method';
-
- $this->uri->_fetch_uri_string();
- $this->assertEquals('controller/method', $this->uri->uri_string);
-
- // death to request uri
- unset($_SERVER['REQUEST_URI']);
-
- // life to path info
- $_SERVER['PATH_INFO'] = '/controller/method/';
-
- $this->uri->_fetch_uri_string();
- $this->assertEquals('controller/method', $this->uri->uri_string);
-
- // death to path info
- // At this point your server must be seriously drunk
- unset($_SERVER['PATH_INFO']);
-
- $_SERVER['QUERY_STRING'] = '/controller/method/';
-
- $this->uri->_fetch_uri_string();
- $this->assertEquals('controller/method', $this->uri->uri_string);
-
- // At this point your server is a labotomy victim
- unset($_SERVER['QUERY_STRING']);
-
- $_GET['/controller/method/'] = '';
-
- $this->uri->_fetch_uri_string();
- $this->assertEquals('controller/method', $this->uri->uri_string);
-
- // Test coverage implies that these will work
- // uri_protocol: REQUEST_URI
- // uri_protocol: CLI
- }
- */
-
- // --------------------------------------------------------------------
-
- /*
-
- This has been moved into _set_uri_string()
-
- public function test_explode_segments()
- {
- // Let's test the function's ability to clean up this mess
- $uris = array(
- 'test/uri' => array('test', 'uri'),
- '/test2/uri2' => array('test2', 'uri2'),
- '//test3/test3///' => array('test3', 'test3')
- );
-
- foreach ($uris as $uri => $a)
- {
- $this->uri->segments = array();
- $this->uri->uri_string = $uri;
- $this->uri->_explode_segments();
-
- $this->assertEquals($a, $this->uri->segments);
- }
- }
- */
- // --------------------------------------------------------------------
-
- public function test_filter_uri_passing()
- {
- $this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-');
-
- $str = 'abc01239~%.:_-';
- $this->uri->filter_uri($str);
- }
-
- // --------------------------------------------------------------------
-
- public function test_filter_uri_throws_error()
- {
- $this->setExpectedException('RuntimeException');
-
- $this->uri->config->set_item('enable_query_strings', FALSE);
- $this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-');
- $segment = '$this()'; // filter_uri() accepts by reference
- $this->uri->filter_uri($segment);
- }
-
- // --------------------------------------------------------------------
-
- public function test_segment()
- {
- $this->uri->segments = array(1 => 'controller');
- $this->assertEquals($this->uri->segment(1), 'controller');
- $this->assertEquals($this->uri->segment(2, 'default'), 'default');
- }
-
- // --------------------------------------------------------------------
-
- public function test_rsegment()
- {
- $this->uri->rsegments = array(1 => 'method');
- $this->assertEquals($this->uri->rsegment(1), 'method');
- $this->assertEquals($this->uri->rsegment(2, 'default'), 'default');
- }
-
- // --------------------------------------------------------------------
-
- public function test_uri_to_assoc()
- {
- $this->uri->segments = array('a', '1', 'b', '2', 'c', '3');
-
- $this->assertEquals(
- array('a' => '1', 'b' => '2', 'c' => '3'),
- $this->uri->uri_to_assoc(1)
- );
-
- $this->assertEquals(
- array('b' => '2', 'c' => '3'),
- $this->uri->uri_to_assoc(3)
- );
-
- $this->uri->keyval = array(); // reset cache
- $this->uri->segments = array('a', '1', 'b', '2', 'c');
-
- $this->assertEquals(
- array('a' => '1', 'b' => '2', 'c' => FALSE),
- $this->uri->uri_to_assoc(1)
- );
-
- $this->uri->keyval = array(); // reset cache
- $this->uri->segments = array('a', '1');
-
- // test default
- $this->assertEquals(
- array('a' => '1', 'b' => FALSE),
- $this->uri->uri_to_assoc(1, array('a', 'b'))
- );
- }
-
- // --------------------------------------------------------------------
-
- public function test_ruri_to_assoc()
- {
- $this->uri->rsegments = array('x', '1', 'y', '2', 'z', '3');
-
- $this->assertEquals(
- array('x' => '1', 'y' => '2', 'z' => '3'),
- $this->uri->ruri_to_assoc(1)
- );
-
- $this->assertEquals(
- array('y' => '2', 'z' => '3'),
- $this->uri->ruri_to_assoc(3)
- );
-
- $this->uri->keyval = array(); // reset cache
- $this->uri->rsegments = array('x', '1', 'y', '2', 'z');
-
- $this->assertEquals(
- array('x' => '1', 'y' => '2', 'z' => FALSE),
- $this->uri->ruri_to_assoc(1)
- );
-
- $this->uri->keyval = array(); // reset cache
- $this->uri->rsegments = array('x', '1');
-
- // test default
- $this->assertEquals(
- array('x' => '1', 'y' => FALSE),
- $this->uri->ruri_to_assoc(1, array('x', 'y'))
- );
- }
-
- // --------------------------------------------------------------------
-
- public function test_assoc_to_uri()
- {
- $this->uri->config->set_item('uri_string_slashes', 'none');
- $this->assertEquals('a/1/b/2', $this->uri->assoc_to_uri(array('a' => '1', 'b' => '2')));
- }
-
- // --------------------------------------------------------------------
-
- public function test_slash_segment()
- {
- $this->uri->segments[1] = 'segment';
- $this->uri->rsegments[1] = 'segment';
-
- $this->assertEquals('/segment/', $this->uri->slash_segment(1, 'both'));
- $this->assertEquals('/segment/', $this->uri->slash_rsegment(1, 'both'));
-
- $a = '/segment';
- $this->assertEquals('/segment', $this->uri->slash_segment(1, 'leading'));
- $this->assertEquals('/segment', $this->uri->slash_rsegment(1, 'leading'));
-
- $this->assertEquals('segment/', $this->uri->slash_segment(1, 'trailing'));
- $this->assertEquals('segment/', $this->uri->slash_rsegment(1, 'trailing'));
- }
-
-}
diff --git a/tests/codeigniter/core/Utf8_test.php b/tests/codeigniter/core/Utf8_test.php
deleted file mode 100644
index 7e6ffd930..000000000
--- a/tests/codeigniter/core/Utf8_test.php
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-
-class Utf8_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->ci_set_config('charset', 'UTF-8');
- $this->utf8 = new Mock_Core_Utf8();
- $this->ci_instance_var('utf8', $this->utf8);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * __construct() test
- *
- * @covers CI_Utf8::__construct
- */
- public function test___construct()
- {
- if (defined('PREG_BAD_UTF8_ERROR') && (ICONV_ENABLED === TRUE OR MB_ENABLED === TRUE) && strtoupper(config_item('charset')) === 'UTF-8')
- {
- $this->assertTrue(UTF8_ENABLED);
- }
- else
- {
- $this->assertFalse(UTF8_ENABLED);
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * is_ascii() test
- *
- * Note: DO NOT move this below test_clean_string()
- */
- public function test_is_ascii()
- {
- $this->assertTrue($this->utf8->is_ascii('foo bar'));
- $this->assertFalse($this->utf8->is_ascii('теÑÑ‚'));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * clean_string() test
- *
- * @depends test_is_ascii
- * @covers CI_Utf8::clean_string
- */
- public function test_clean_string()
- {
- $this->assertEquals('foo bar', $this->utf8->clean_string('foo bar'));
-
- $illegal_utf8 = "\xc0теÑÑ‚";
- if (MB_ENABLED)
- {
- $this->assertEquals('теÑÑ‚', $this->utf8->clean_string($illegal_utf8));
- }
- 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));
- }
- else
- {
- $this->assertEquals($illegal_utf8, $this->utf8->clean_string($illegal_utf8));
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * convert_to_utf8() test
- *
- * @covers CI_Utf8::convert_to_utf8
- */
- public function test_convert_to_utf8()
- {
- if (MB_ENABLED OR ICONV_ENABLED)
- {
- $this->assertEquals('теÑÑ‚', $this->utf8->convert_to_utf8('òåñò', 'WINDOWS-1251'));
- }
- else
- {
- $this->assertFalse($this->utf8->convert_to_utf8('òåñò', 'WINDOWS-1251'));
- }
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/core/compat/hash_test.php b/tests/codeigniter/core/compat/hash_test.php
deleted file mode 100644
index d8cd0bb16..000000000
--- a/tests/codeigniter/core/compat/hash_test.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-class hash_test extends CI_TestCase {
-
- public function test_bootstrap()
- {
- if (is_php('5.6'))
- {
- return $this->markTestSkipped('ext/hash is available on PHP 5.6');
- }
-
- $this->assertTrue(function_exists('hash_equals'));
- is_php('5.5') OR $this->assertTrue(function_exists('hash_pbkdf2'));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * hash_equals() test
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_bootstrap
- */
- public function test_hash_equals()
- {
- $this->assertTrue(hash_equals('same', 'same'));
- $this->assertFalse(hash_equals('not1same', 'not2same'));
- $this->assertFalse(hash_equals('short', 'longer'));
- $this->assertFalse(hash_equals('longer', 'short'));
- $this->assertFalse(hash_equals('', 'notempty'));
- $this->assertFalse(hash_equals('notempty', ''));
- $this->assertTrue(hash_equals('', ''));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * hash_pbkdf2() test
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_bootstrap
- */
- public function test_hash_pbkdf2()
- {
- if (is_php('5.5'))
- {
- return $this->markTestSkipped('hash_pbkdf2() is available on PHP 5.5');
- }
-
- $this->assertEquals('0c60c80f961f0e71f3a9', hash_pbkdf2('sha1', 'password', 'salt', 1, 20));
- $this->assertEquals(
- "\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24\xaf\x60\x12\x06\x2f\xe0\x37\xa6",
- hash_pbkdf2('sha1', 'password', 'salt', 1, 20, TRUE)
- );
- $this->assertEquals('3d2eec4fe41c849b80c8d8366', hash_pbkdf2('sha1', 'passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 25));
- $this->assertEquals(
- "\x3d\x2e\xec\x4f\xe4\x1c\x84\x9b\x80\xc8\xd8\x36\x62\xc0\xe4\x4a\x8b\x29\x1a\x96\x4c\xf2\xf0\x70\x38",
- hash_pbkdf2('sha1', 'passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 25, TRUE)
- );
- $this->assertEquals('120fb6cffcf8b32c43e7', hash_pbkdf2('sha256', 'password', 'salt', 1, 20));
- $this->assertEquals(
- "\x12\x0f\xb6\xcf\xfc\xf8\xb3\x2c\x43\xe7\x22\x52\x56\xc4\xf8\x37\xa8\x65\x48\xc9",
- hash_pbkdf2('sha256', 'password', 'salt', 1, 20, TRUE)
- );
- $this->assertEquals(
- '348c89dbcbd32b2f32d814b8116e84cf2b17347e',
- hash_pbkdf2('sha256', 'passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 40)
- );
- $this->assertEquals(
- "\x34\x8c\x89\xdb\xcb\xd3\x2b\x2f\x32\xd8\x14\xb8\x11\x6e\x84\xcf\x2b\x17\x34\x7e\xbc\x18\x00\x18\x1c\x4e\x2a\x1f\xb8\xdd\x53\xe1\xc6\x35\x51\x8c\x7d\xac\x47\xe9",
- hash_pbkdf2('sha256', 'passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 40, TRUE)
- );
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/core/compat/mbstring_test.php b/tests/codeigniter/core/compat/mbstring_test.php
deleted file mode 100644
index 415222446..000000000
--- a/tests/codeigniter/core/compat/mbstring_test.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-
-class mbstring_test extends CI_TestCase {
-
- public function test_bootstrap()
- {
- if (MB_ENABLED)
- {
- return $this->markTestSkipped('ext/mbstring is loaded');
- }
-
- $this->assertTrue(function_exists('mb_strlen'));
- $this->assertTrue(function_exists('mb_substr'));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @depends test_bootstrap
- */
- public function test_mb_strlen()
- {
- $this->assertEquals(ICONV_ENABLED ? 4 : 8, mb_strlen('теÑÑ‚'));
- $this->assertEquals(ICONV_ENABLED ? 4 : 8, mb_strlen('теÑÑ‚', 'UTF-8'));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @depends test_boostrap
- */
- public function test_mb_strpos()
- {
- $this->assertEquals(ICONV_ENABLED ? 3 : 6, mb_strpos('теÑÑ‚', 'Ñ'));
- $this->assertFalse(mb_strpos('теÑÑ‚', 'Ñ', 3));
- $this->assertEquals(ICONV_ENABLED ? 3 : 6, mb_strpos('теÑÑ‚', 'Ñ', 1, 'UTF-8'));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @depends test_boostrap
- */
- public function test_mb_substr()
- {
- $this->assertEquals(ICONV_ENABLED ? 'Ñтинг' : 'еÑтинг', mb_substr('теÑтинг', 2));
- $this->assertEquals(ICONV_ENABLED ? 'нг' : 'г', mb_substr('теÑтинг', -2));
- $this->assertEquals(ICONV_ENABLED ? 'ÑÑ‚' : 'е', mb_substr('теÑтинг', 2, 2));
- $this->assertEquals(ICONV_ENABLED ? 'Ñтинг' : 'еÑтинг', mb_substr('теÑтинг', 2, 'UTF-8'));
- $this->assertEquals(ICONV_ENABLED ? 'нг' : 'г', mb_substr('теÑтинг', -2, 'UTF-8'));
- $this->assertEquals(ICONV_ENABLED ? 'ÑÑ‚' : 'е', mb_substr('теÑтинг', 2, 2, 'UTF-8'));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/core/compat/password_test.php b/tests/codeigniter/core/compat/password_test.php
deleted file mode 100644
index 77f5eba4e..000000000
--- a/tests/codeigniter/core/compat/password_test.php
+++ /dev/null
@@ -1,159 +0,0 @@
-<?php
-
-class password_test extends CI_TestCase {
-
- public function test_bootstrap()
- {
- if (is_php('5.5'))
- {
- return $this->markTestSkipped('ext/standard/password is available on PHP 5.5');
- }
- // defined as of HHVM 2.3.0, which is also when they introduce password_*() as well
- // Note: Do NOT move this after the CRYPT_BLOWFISH check
- elseif (defined('HHVM_VERSION'))
- {
- $this->markTestSkipped('HHVM 2.3.0+ already has it');
- }
- elseif ( ! defined('CRYPT_BLOWFISH') OR CRYPT_BLOWFISH !== 1)
- {
- $this->assertFalse(defined('PASSWORD_BCRYPT'));
- return $this->markTestSkipped('CRYPT_BLOWFISH is not available');
- }
-
- $this->assertTrue(defined('PASSWORD_BCRYPT'));
- $this->assertTrue(defined('PASSWORD_DEFAULT'));
- $this->assertEquals(1, PASSWORD_BCRYPT);
- $this->assertEquals(PASSWORD_BCRYPT, PASSWORD_DEFAULT);
- $this->assertTrue(function_exists('password_get_info'));
- $this->assertTrue(function_exists('password_hash'));
- $this->assertTrue(function_exists('password_needs_rehash'));
- $this->assertTrue(function_exists('password_verify'));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * password_get_info() test
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_bootstrap
- */
- public function test_password_get_info()
- {
- $expected = array(
- 'algo' => 1,
- 'algoName' => 'bcrypt',
- 'options' => array('cost' => 10)
- );
-
- // default
- $this->assertEquals($expected, password_get_info('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y'));
-
- $expected['options']['cost'] = 11;
-
- // cost
- $this->assertEquals($expected, password_get_info('$2y$11$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y'));
-
- $expected = array(
- 'algo' => 0,
- 'algoName' => 'unknown',
- 'options' => array()
- );
-
- // invalid length
- $this->assertEquals($expected, password_get_info('$2y$11$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100'));
-
- // non-bcrypt
- $this->assertEquals($expected, password_get_info('$1$rasmusle$rISCgZzpwk3UhDidwXvin0'));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * password_hash() test
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_bootstrap
- */
- public function test_password_hash()
- {
- // FALSE is returned if no CSPRNG source is available
- if ( ! defined('MCRYPT_DEV_URANDOM') && ! function_exists('openssl_random_pseudo_bytes')
- && (DIRECTORY_SEPARATOR !== '/' OR ! is_readable('/dev/arandom') OR ! is_readable('/dev/urandom'))
- )
- {
- $this->assertFalse(password_hash('foo', PASSWORD_BCRYPT));
- }
- else
- {
- $this->assertEquals(60, strlen(password_hash('foo', PASSWORD_BCRYPT)));
- $this->assertTrue(($hash = password_hash('foo', PASSWORD_BCRYPT)) === crypt('foo', $hash));
- }
-
- $this->assertEquals(
- '$2y$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi',
- password_hash('rasmuslerdorf', PASSWORD_BCRYPT, array('cost' => 7, 'salt' => 'usesomesillystringforsalt'))
- );
-
- $this->assertEquals(
- '$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y',
- password_hash('test', PASSWORD_BCRYPT, array('salt' => '123456789012345678901'.chr(0)))
- );
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * password_needs_rehash() test
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_password_get_info
- */
- public function test_password_needs_rehash()
- {
- // invalid hash: always rehash
- $this->assertTrue(password_needs_rehash('', PASSWORD_BCRYPT));
-
- // valid, because it's an unknown algorithm
- $this->assertFalse(password_needs_rehash('', 0));
-
- // valid with same cost
- $this->assertFalse(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 10)));
-
- // valid with same cost and additional parameters
- $this->assertFalse(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 10, 'foo' => 3)));
-
- // invalid: different (lower) cost
- $this->assertTrue(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 9)));
-
- // invalid: different (higher) cost
- $this->assertTrue(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 11)));
-
- // valid with default cost
- $this->assertFalse(password_needs_rehash('$2y$'.str_pad(10, 2, '0', STR_PAD_LEFT).'$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT));
-
- // invalid: 'foo' is cast to 0
- $this->assertTrue(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 'foo')));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * password_verify() test
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_bootstrap
- */
- public function test_password_verify()
- {
- $this->assertFalse(password_verify(123, 123));
- $this->assertFalse(password_verify('foo', '$2a$07$usesomesillystringforsalt$'));
- $this->assertFalse(password_verify('rasmusler', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi'));
- $this->assertTrue(password_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi'));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/core/compat/standard_test.php b/tests/codeigniter/core/compat/standard_test.php
deleted file mode 100644
index a98460129..000000000
--- a/tests/codeigniter/core/compat/standard_test.php
+++ /dev/null
@@ -1,378 +0,0 @@
-<?php
-
-class standard_test extends CI_TestCase {
-
- public function test_bootstrap()
- {
- if (is_php('5.5'))
- {
- return $this->markTestSkipped('All array functions are already available on PHP 5.5');
- }
-
- $this->assertTrue(function_exists('array_column'));
-
- if ( ! is_php('5.4'))
- {
- $this->assertTrue(function_exists('hex2bin'));
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * array_column() test
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_bootstrap
- */
- public function test_array_column()
- {
- // Basic tests
-
- $input = array(
- array(
- 'id' => 1,
- 'first_name' => 'John',
- 'last_name' => 'Doe'
- ),
- array(
- 'id' => 2,
- 'first_name' => 'Sally',
- 'last_name' => 'Smith'
- ),
- array(
- 'id' => 3,
- 'first_name' => 'Jane',
- 'last_name' => 'Jones'
- )
- );
-
- // Ensure internal array position doesn't break it
- next($input);
-
- $this->assertEquals(
- array('John', 'Sally', 'Jane'),
- array_column($input, 'first_name')
- );
-
- $this->assertEquals(
- array(1, 2, 3),
- array_column($input, 'id')
- );
-
- $this->assertEquals(
- array(
- 1 => 'Doe',
- 2 => 'Smith',
- 3 => 'Jones'
- ),
- array_column($input, 'last_name', 'id')
- );
-
- $this->assertEquals(
- array(
- 'John' => 'Doe',
- 'Sally' => 'Smith',
- 'Jane' => 'Jones'
- ),
- array_column($input, 'last_name', 'first_name')
- );
-
- // Object key search
-
- $f = new Foo();
- $b = new Bar();
-
- $this->assertEquals(
- array('Doe', 'Smith', 'Jones'),
- array_column($input, $f)
- );
-
- $this->assertEquals(
- array(
- 'John' => 'Doe',
- 'Sally' => 'Smith',
- 'Jane' => 'Jones'
- ),
- array_column($input, $f, $b)
- );
-
- // NULL parameters
-
- $input = array(
- 456 => array(
- 'id' => '3',
- 'title' => 'Foo',
- 'date' => '2013-03-25'
- ),
- 457 => array(
- 'id' => '5',
- 'title' => 'Bar',
- 'date' => '2012-05-20'
- )
- );
-
- $this->assertEquals(
- array(
- 3 => array(
- 'id' => '3',
- 'title' => 'Foo',
- 'date' => '2013-03-25'
- ),
- 5 => array(
- 'id' => '5',
- 'title' => 'Bar',
- 'date' => '2012-05-20'
- )
- ),
- array_column($input, NULL, 'id')
- );
-
- $this->assertEquals(
- array(
- array(
- 'id' => '3',
- 'title' => 'Foo',
- 'date' => '2013-03-25'
- ),
- array(
- 'id' => '5',
- 'title' => 'Bar',
- 'date' => '2012-05-20'
- )
- ),
- array_column($input, NULL, 'foo')
- );
-
- $this->assertEquals(
- array(
- array(
- 'id' => '3',
- 'title' => 'Foo',
- 'date' => '2013-03-25'
- ),
- array(
- 'id' => '5',
- 'title' => 'Bar',
- 'date' => '2012-05-20'
- )
- ),
- array_column($input, NULL)
- );
-
- // Data types
-
- $fh = fopen(__FILE__, 'r', TRUE);
- $stdClass = new stdClass();
- $input = array(
- array(
- 'id' => 1,
- 'value' => $stdClass
- ),
- array(
- 'id' => 2,
- 'value' => 34.2345
- ),
- array(
- 'id' => 3,
- 'value' => TRUE
- ),
- array(
- 'id' => 4,
- 'value' => FALSE
- ),
- array(
- 'id' => 5,
- 'value' => NULL
- ),
- array(
- 'id' => 6,
- 'value' => 1234
- ),
- array(
- 'id' => 7,
- 'value' => 'Foo'
- ),
- array(
- 'id' => 8,
- 'value' => $fh
- )
- );
-
- $this->assertEquals(
- array(
- $stdClass,
- 34.2345,
- TRUE,
- FALSE,
- NULL,
- 1234,
- 'Foo',
- $fh
- ),
- array_column($input, 'value')
- );
-
- $this->assertEquals(
- array(
- 1 => $stdClass,
- 2 => 34.2345,
- 3 => TRUE,
- 4 => FALSE,
- 5 => NULL,
- 6 => 1234,
- 7 => 'Foo',
- 8 => $fh
- ),
- array_column($input, 'value', 'id')
- );
-
- // Numeric column keys
-
- $input = array(
- array('aaa', '111'),
- array('bbb', '222'),
- array('ccc', '333', -1 => 'ddd')
- );
-
- $this->assertEquals(
- array('111', '222', '333'),
- array_column($input, 1)
- );
-
- $this->assertEquals(
- array(
- 'aaa' => '111',
- 'bbb' => '222',
- 'ccc' => '333'
- ),
- array_column($input, 1, 0)
- );
-
- $this->assertEquals(
- array(
- 'aaa' => '111',
- 'bbb' => '222',
- 'ccc' => '333'
- ),
- array_column($input, 1, 0.123)
- );
-
- $this->assertEquals(
- array(
- 0 => '111',
- 1 => '222',
- 'ddd' => '333'
- ),
- array_column($input, 1, -1)
- );
-
- // Non-existing columns
-
- $this->assertEquals(array(), array_column($input, 2));
- $this->assertEquals(array(), array_column($input, 'foo'));
- $this->assertEquals(
- array('aaa', 'bbb', 'ccc'),
- array_column($input, 0, 'foo')
- );
- $this->assertEquals(array(), array_column($input, 3.14));
-
- // One-dimensional array
- $this->assertEquals(array(), array_column(array('foo', 'bar', 'baz'), 1));
-
- // Columns not present in all rows
-
- $input = array(
- array('a' => 'foo', 'b' => 'bar', 'e' => 'bbb'),
- array('a' => 'baz', 'c' => 'qux', 'd' => 'aaa'),
- array('a' => 'eee', 'b' => 'fff', 'e' => 'ggg')
- );
-
- $this->assertEquals(
- array('qux'),
- array_column($input, 'c')
- );
-
- $this->assertEquals(
- array('baz' => 'qux'),
- array_column($input, 'c', 'a')
- );
-
- $this->assertEquals(
- array(
- 0 => 'foo',
- 'aaa' => 'baz',
- 1 => 'eee'
- ),
- array_column($input, 'a', 'd')
- );
-
- $this->assertEquals(
- array(
- 'bbb' => 'foo',
- 0 => 'baz',
- 'ggg' => 'eee'
- ),
- array_column($input, 'a', 'e')
- );
-
- $this->assertEquals(
- array('bar', 'fff'),
- array_column($input, 'b')
- );
-
- $this->assertEquals(
- array(
- 'foo' => 'bar',
- 'eee' => 'fff'
- ),
- array_column($input, 'b', 'a')
- );
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * hex2bin() tests
- *
- * @depends test_bootstrap
- */
- public function test_hex2bin()
- {
- if (is_php('5.4'))
- {
- return $this->markTestSkipped('hex2bin() is already available on PHP 5.4');
- }
-
- $this->assertEquals("\x03\x04", hex2bin("0304"));
- $this->assertEquals('', hex2bin(''));
- $this->assertEquals("\x01\x02\x03", hex2bin(new FooHex()));
- }
-}
-
-// ------------------------------------------------------------------------
-
-class Foo {
-
- public function __toString()
- {
- return 'last_name';
- }
-}
-
-class Bar {
-
- public function __toString()
- {
- return 'first_name';
- }
-}
-
-class FooHex {
-
- public function __toString()
- {
- return '010203';
- }
-}
diff --git a/tests/codeigniter/database/DB_driver_test.php b/tests/codeigniter/database/DB_driver_test.php
deleted file mode 100644
index 26416d3fc..000000000
--- a/tests/codeigniter/database/DB_driver_test.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-class DB_driver_test extends CI_TestCase {
-
- public function test_initialize()
- {
- $config = Mock_Database_DB::config(DB_DRIVER);
- sscanf(DB_DRIVER, '%[^/]/', $driver_name);
- $driver = $this->{$driver_name}($config[DB_DRIVER]);
-
- $this->assertTrue($driver->initialize());
- }
-
- protected function pdo($config)
- {
- return new Mock_Database_Drivers_PDO($config);
- }
-
- protected function mysql($config)
- {
- return new Mock_Database_Drivers_Mysql($config);
- }
-
- protected function mysqli($config)
- {
- return new Mock_Database_Drivers_Mysqli($config);
- }
-
- protected function sqlite($config)
- {
- return new Mock_Database_Drivers_Sqlite($config);
- }
-
- protected function pgsql($config)
- {
- return new Mock_Database_Drivers_Postgre($config);
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/DB_test.php b/tests/codeigniter/database/DB_test.php
deleted file mode 100644
index dc4fae986..000000000
--- a/tests/codeigniter/database/DB_test.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-class DB_test extends CI_TestCase {
-
- public function test_db_invalid()
- {
- $connection = new Mock_Database_DB(array(
- 'undefined' => array(
- 'dsn' => '',
- 'hostname' => 'undefined',
- 'username' => 'undefined',
- 'password' => 'undefined',
- 'database' => 'undefined',
- 'dbdriver' => 'undefined',
- ),
- ));
-
- $this->setExpectedException('RuntimeException', 'CI Error: Invalid DB driver');
-
- Mock_Database_DB::DB($connection->set_dsn('undefined'), TRUE);
- }
-
- // ------------------------------------------------------------------------
-
- public function test_db_valid()
- {
- $config = Mock_Database_DB::config(DB_DRIVER);
- $connection = new Mock_Database_DB($config);
-
- // E_DEPRECATED notices thrown by mysql_connect(), mysql_pconnect()
- // on PHP 5.5+ cause the tests to fail
- if (DB_DRIVER === 'mysql' && version_compare(PHP_VERSION, '5.5', '>='))
- {
- error_reporting(E_ALL & ~E_DEPRECATED);
- }
-
- $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 test is unusable, because whoever wrote it apparently thought that
- an E_WARNING should equal an Exception and based the whole test suite
- around that bogus assumption.
-
- public function test_db_failover()
- {
- $config = Mock_Database_DB::config(DB_DRIVER);
- $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);
- }
-*/
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/count_test.php b/tests/codeigniter/database/query_builder/count_test.php
deleted file mode 100644
index da312d866..000000000
--- a/tests/codeigniter/database/query_builder/count_test.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-class Count_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_count_all()
- {
- $this->assertEquals(4, $this->db->count_all('job'));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_count_all_results()
- {
- $this->assertEquals(2, $this->db->like('name', 'ian')->count_all_results('job'));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_count_all_results_limit()
- {
- $this->assertEquals(1, $this->db->like('name', 'ian')->limit(1)->count_all_results('job'));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/delete_test.php b/tests/codeigniter/database/query_builder/delete_test.php
deleted file mode 100644
index ab9d97f56..000000000
--- a/tests/codeigniter/database/query_builder/delete_test.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-class Delete_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_delete()
- {
- // Check initial record
- $job1 = $this->db->where('id', 1)->get('job')->row();
-
- $this->assertEquals('Developer', $job1->name);
-
- // Do the delete
- $this->db->delete('job', array('id' => 1));
-
- // Check the record
- $job1 = $this->db->where('id', 1)->get('job');
-
- $this->assertEmpty($job1->result_array());
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_delete_several_tables()
- {
- // Check initial record
- $user4 = $this->db->where('id', 4)->get('user')->row();
- $job4 = $this->db->where('id', 4)->get('job')->row();
-
- $this->assertEquals('Musician', $job4->name);
- $this->assertEquals('Chris Martin', $user4->name);
-
- // Do the delete
- $this->db->delete(array('job', 'user'), array('id' => 4));
-
- // Check the record
- $job4 = $this->db->where('id', 4)->get('job');
- $user4 = $this->db->where('id', 4)->get('user');
-
- $this->assertEmpty($job4->result_array());
- $this->assertEmpty($user4->result_array());
- }
-
-} \ 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
deleted file mode 100644
index cc98009ce..000000000
--- a/tests/codeigniter/database/query_builder/distinct_test.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-class Distinct_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_distinct()
- {
- $users = $this->db->select('country')
- ->distinct()
- ->get('user')
- ->result_array();
-
- $this->assertEquals(3, count($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
deleted file mode 100644
index d1f56285f..000000000
--- a/tests/codeigniter/database/query_builder/empty_test.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-class Empty_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_empty_table()
- {
- // Check initial record
- $jobs = $this->db->get('job')->result_array();
-
- $this->assertEquals(4, count($jobs));
-
- // Do the empty
- $this->db->empty_table('job');
-
- // Check the record
- $jobs = $this->db->get('job');
-
- $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
deleted file mode 100644
index 27e678f22..000000000
--- a/tests/codeigniter/database/query_builder/escape_test.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-class Escape_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_escape_like_percent_sign()
- {
- // Escape the like string
- $string = $this->db->escape_like_str('\%foo');
-
- if (strpos(DB_DRIVER, 'mysql') !== FALSE)
- {
- $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%' ESCAPE '!';";
- }
- else
- {
- $sql = 'SELECT "value" FROM "misc" WHERE "key" LIKE \''.$string.'%\' ESCAPE \'!\';';
- }
-
- $res = $this->db->query($sql)->result_array();
-
- // Check the result
- $this->assertEquals(1, count($res));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_escape_like_backslash_sign()
- {
- // Escape the like string
- $string = $this->db->escape_like_str('\\');
-
- if (strpos(DB_DRIVER, 'mysql') !== FALSE)
- {
- $sql = "SELECT `value` FROM `misc` WHERE `key` LIKE '$string%' ESCAPE '!';";
- }
- else
- {
- $sql = 'SELECT "value" FROM "misc" WHERE "key" LIKE \''.$string.'%\' ESCAPE \'!\';';
- }
-
- $res = $this->db->query($sql)->result_array();
-
- // Check the result
- $this->assertEquals(2, count($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
deleted file mode 100644
index 7aaae348d..000000000
--- a/tests/codeigniter/database/query_builder/from_test.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-class From_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_from_simple()
- {
- $jobs = $this->db->from('job')
- ->get()
- ->result_array();
-
- $this->assertEquals(4, count($jobs));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_from_with_where()
- {
- $job1 = $this->db->from('job')
- ->where('id', 1)
- ->get()
- ->row();
-
- $this->assertEquals('1', $job1->id);
- $this->assertEquals('Developer', $job1->name);
- $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/get_test.php b/tests/codeigniter/database/query_builder/get_test.php
deleted file mode 100644
index 156027537..000000000
--- a/tests/codeigniter/database/query_builder/get_test.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-class Get_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_get_simple()
- {
- $jobs = $this->db->get('job')->result_array();
-
- // Dummy jobs contain 4 rows
- $this->assertCount(4, $jobs);
-
- // Check rows item
- $this->assertEquals('Developer', $jobs[0]['name']);
- $this->assertEquals('Politician', $jobs[1]['name']);
- $this->assertEquals('Accountant', $jobs[2]['name']);
- $this->assertEquals('Musician', $jobs[3]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_get_where()
- {
- $job1 = $this->db->get_where('job', array('id' => 1))->result_array();
-
- // Dummy jobs contain 1 rows
- $this->assertCount(1, $job1);
-
- // Check rows item
- $this->assertEquals('Developer', $job1[0]['name']);
- }
-
-} \ 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
deleted file mode 100644
index 5249f7c87..000000000
--- a/tests/codeigniter/database/query_builder/group_test.php
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-
-class Group_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_group_by()
- {
- $jobs = $this->db->select('name')
- ->from('job')
- ->group_by('name')
- ->get()
- ->result_array();
-
- $this->assertEquals(4, count($jobs));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_having_by()
- {
- $jobs = $this->db->select('name')
- ->from('job')
- ->group_by('name')
- ->having('SUM(id) > 2')
- ->get()
- ->result_array();
-
- $this->assertEquals(2, count($jobs));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/insert_test.php b/tests/codeigniter/database/query_builder/insert_test.php
deleted file mode 100644
index 30c055680..000000000
--- a/tests/codeigniter/database/query_builder/insert_test.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-
-class Insert_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- * @see ./mocks/schema/skeleton.php
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
-
- // Truncate the current datas
- $this->db->truncate('job');
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_insert()
- {
- $job_data = array('id' => 1, 'name' => 'Grocery Sales', 'description' => 'Discount!');
-
- // Do normal insert
- $this->assertTrue($this->db->insert('job', $job_data));
-
- $job1 = $this->db->get('job')->row();
-
- // Check the result
- $this->assertEquals('Grocery Sales', $job1->name);
-
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_insert_batch()
- {
- $job_datas = array(
- array('id' => 2, 'name' => 'Commedian', 'description' => 'Theres something in your teeth'),
- array('id' => 3, 'name' => 'Cab Driver', 'description' => 'Iam yellow'),
- );
-
- // Do insert batch except for sqlite driver
- if (strpos(DB_DRIVER, 'sqlite') === FALSE)
- {
- $this->assertEquals(2, $this->db->insert_batch('job', $job_datas));
-
- $job_2 = $this->db->where('id', 2)->get('job')->row();
- $job_3 = $this->db->where('id', 3)->get('job')->row();
-
- // Check the result
- $this->assertEquals('Commedian', $job_2->name);
- $this->assertEquals('Cab Driver', $job_3->name);
- }
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php
deleted file mode 100644
index 54b2a4e18..000000000
--- a/tests/codeigniter/database/query_builder/join_test.php
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-
-class Join_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_join_simple()
- {
- $job_user = $this->db->select('job.id as job_id, job.name as job_name, user.id as user_id, user.name as user_name')
- ->from('job')
- ->join('user', 'user.id = job.id')
- ->get()
- ->result_array();
-
- // Check the result
- $this->assertEquals('1', $job_user[0]['job_id']);
- $this->assertEquals('1', $job_user[0]['user_id']);
- $this->assertEquals('Derek Jones', $job_user[0]['user_name']);
- $this->assertEquals('Developer', $job_user[0]['job_name']);
- }
-
- // ------------------------------------------------------------------------
-
- public function test_join_escape_is_null()
- {
- $expected = 'SELECT '.$this->db->escape_identifiers('field')
- ."\nFROM ".$this->db->escape_identifiers('table1')
- ."\nJOIN ".$this->db->escape_identifiers('table2').' ON '.$this->db->escape_identifiers('field').' IS NULL';
-
- $this->assertEquals(
- $expected,
- $this->db->select('field')->from('table1')->join('table2', 'field IS NULL')->get_compiled_select()
- );
-
- $expected = 'SELECT '.$this->db->escape_identifiers('field')
- ."\nFROM ".$this->db->escape_identifiers('table1')
- ."\nJOIN ".$this->db->escape_identifiers('table2').' ON '.$this->db->escape_identifiers('field').' IS NOT NULL';
-
- $this->assertEquals(
- $expected,
- $this->db->select('field')->from('table1')->join('table2', 'field IS NOT NULL')->get_compiled_select()
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_join_escape_multiple_conditions()
- {
- // We just need a valid query produced, not one that makes sense
- $fields = array($this->db->protect_identifiers('table1.field1'), $this->db->protect_identifiers('table2.field2'));
-
- $expected = 'SELECT '.implode(', ', $fields)
- ."\nFROM ".$this->db->escape_identifiers('table1')
- ."\nLEFT JOIN ".$this->db->escape_identifiers('table2').' ON '.implode(' = ', $fields)
- .' AND '.$fields[0]." = 'foo' AND ".$fields[1].' = 0';
-
- $result = $this->db->select('table1.field1, table2.field2')
- ->from('table1')
- ->join('table2', "table1.field1 = table2.field2 AND table1.field1 = 'foo' AND table2.field2 = 0", 'LEFT')
- ->get_compiled_select();
-
- $this->assertEquals($expected, $result);
- }
-
- // ------------------------------------------------------------------------
-
- public function test_join_escape_multiple_conditions_with_parentheses()
- {
- // We just need a valid query produced, not one that makes sense
- $fields = array($this->db->protect_identifiers('table1.field1'), $this->db->protect_identifiers('table2.field2'));
-
- $expected = 'SELECT '.implode(', ', $fields)
- ."\nFROM ".$this->db->escape_identifiers('table1')
- ."\nRIGHT JOIN ".$this->db->escape_identifiers('table2').' ON '.implode(' = ', $fields)
- .' AND ('.$fields[0]." = 'foo' OR ".$fields[1].' IS NULL)';
-
- $result = $this->db->select('table1.field1, table2.field2')
- ->from('table1')
- ->join('table2', "table1.field1 = table2.field2 AND (table1.field1 = 'foo' OR table2.field2 IS NULL)", 'RIGHT')
- ->get_compiled_select();
-
- $this->assertEquals($expected, $result);
- }
-
-} \ 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
deleted file mode 100644
index 2736fbe0b..000000000
--- a/tests/codeigniter/database/query_builder/like_test.php
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php
-
-class Like_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_like()
- {
- $job1 = $this->db->like('name', 'veloper')
- ->get('job')
- ->row();
-
- // Check the result
- $this->assertEquals('1', $job1->id);
- $this->assertEquals('Developer', $job1->name);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_or_like()
- {
- $jobs = $this->db->like('name', 'ian')
- ->or_like('name', 'veloper')
- ->get('job')
- ->result_array();
-
- // Check the result
- $this->assertEquals(3, count($jobs));
- $this->assertEquals('Developer', $jobs[0]['name']);
- $this->assertEquals('Politician', $jobs[1]['name']);
- $this->assertEquals('Musician', $jobs[2]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_not_like()
- {
- $jobs = $this->db->not_like('name', 'veloper')
- ->get('job')
- ->result_array();
-
- // Check the result
- $this->assertEquals(3, count($jobs));
- $this->assertEquals('Politician', $jobs[0]['name']);
- $this->assertEquals('Accountant', $jobs[1]['name']);
- $this->assertEquals('Musician', $jobs[2]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_or_not_like()
- {
- $jobs = $this->db->like('name', 'an')
- ->or_not_like('name', 'veloper')
- ->get('job')
- ->result_array();
-
- // Check the result
- $this->assertEquals(3, count($jobs));
- $this->assertEquals('Politician', $jobs[0]['name']);
- $this->assertEquals('Accountant', $jobs[1]['name']);
- $this->assertEquals('Musician', $jobs[2]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * GitHub issue #273
- *
- * @see ./mocks/schema/skeleton.php
- */
- public function test_like_spaces_and_tabs()
- {
- $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));
- }
-
-} \ 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
deleted file mode 100644
index a0954c7ab..000000000
--- a/tests/codeigniter/database/query_builder/limit_test.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-class Limit_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_limit()
- {
- $jobs = $this->db->limit(2)
- ->get('job')
- ->result_array();
-
- $this->assertEquals(2, count($jobs));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_limit_and_offset()
- {
- $jobs = $this->db->limit(2, 2)
- ->get('job')
- ->result_array();
-
- $this->assertEquals(2, count($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
deleted file mode 100644
index 46f452bae..000000000
--- a/tests/codeigniter/database/query_builder/order_test.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-class Order_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_order_ascending()
- {
- $jobs = $this->db->order_by('name', 'asc')
- ->get('job')
- ->result_array();
-
- // Check the result
- $this->assertEquals(4, count($jobs));
- $this->assertEquals('Accountant', $jobs[0]['name']);
- $this->assertEquals('Developer', $jobs[1]['name']);
- $this->assertEquals('Musician', $jobs[2]['name']);
- $this->assertEquals('Politician', $jobs[3]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_order_descending()
- {
- $jobs = $this->db->order_by('name', 'desc')
- ->get('job')
- ->result_array();
-
- $this->assertEquals(4, count($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
deleted file mode 100644
index 877b5d8c0..000000000
--- a/tests/codeigniter/database/query_builder/select_test.php
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-
-class Select_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_select_only_one_collumn()
- {
- $jobs_name = $this->db->select('name')
- ->get('job')
- ->result_array();
-
- // 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]));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_select_min()
- {
- $job_min = $this->db->select_min('id')
- ->get('job')
- ->row();
-
- // Minimum id was 1
- $this->assertEquals('1', $job_min->id);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_select_max()
- {
- $job_max = $this->db->select_max('id')
- ->get('job')
- ->row();
-
- // Maximum id was 4
- $this->assertEquals('4', $job_max->id);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_select_avg()
- {
- $job_avg = $this->db->select_avg('id')
- ->get('job')
- ->row();
-
- // Average should be 2.5
- $this->assertEquals('2.5', $job_avg->id);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_select_sum()
- {
- $job_sum = $this->db->select_sum('id')
- ->get('job')
- ->row();
-
- // Sum of ids should be 10
- $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
deleted file mode 100644
index 09923c7f1..000000000
--- a/tests/codeigniter/database/query_builder/truncate_test.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-
-class Truncate_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_truncate()
- {
- // Check initial record
- $jobs = $this->db->get('job')->result_array();
- $this->assertEquals(4, count($jobs));
-
- // Do the empty
- $this->db->truncate('job');
-
- // Check the record
- $jobs = $this->db->get('job');
- $this->assertEmpty($jobs->result_array());
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_truncate_with_from()
- {
- // Check initial record
- $users = $this->db->get('user')->result_array();
- $this->assertEquals(4, count($users));
-
- // Do the empty
- $this->db->from('user')->truncate();
-
- // Check the record
- $users = $this->db->get('user');
- $this->assertEmpty($users->result_array());
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/update_test.php b/tests/codeigniter/database/query_builder/update_test.php
deleted file mode 100644
index 27a647c45..000000000
--- a/tests/codeigniter/database/query_builder/update_test.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-class Update_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_update()
- {
- // Check initial record
- $job1 = $this->db->where('id', 1)->get('job')->row();
- $this->assertEquals('Developer', $job1->name);
-
- // Do the update
- $this->db->where('id', 1)->update('job', array('name' => 'Programmer'));
-
- // Check updated record
- $job1 = $this->db->where('id', 1)->get('job')->row();
- $this->assertEquals('Programmer', $job1->name);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_update_with_set()
- {
- // Check initial record
- $job1 = $this->db->where('id', 4)->get('job')->row();
- $this->assertEquals('Musician', $job1->name);
-
- // Do the update
- $this->db->set('name', 'Vocalist');
- $this->db->update('job', NULL, 'id = 4');
-
- // Check updated record
- $job1 = $this->db->where('id', 4)->get('job')->row();
- $this->assertEquals('Vocalist', $job1->name);
- }
-
-} \ 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
deleted file mode 100644
index 46a7fa2eb..000000000
--- a/tests/codeigniter/database/query_builder/where_test.php
+++ /dev/null
@@ -1,134 +0,0 @@
-<?php
-
-class Where_test extends CI_TestCase {
-
- /**
- * @var object Database/Query Builder holder
- */
- protected $db;
-
- public function set_up()
- {
- $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
-
- Mock_Database_Schema_Skeleton::create_tables();
- Mock_Database_Schema_Skeleton::create_data();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_simple_key_value()
- {
- $job1 = $this->db->where('id', 1)->get('job')->row();
-
- $this->assertEquals('1', $job1->id);
- $this->assertEquals('Developer', $job1->name);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_custom_key_value()
- {
- $jobs = $this->db->where('id !=', 1)->get('job')->result_array();
- $this->assertEquals(3, count($jobs));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_associative_array()
- {
- $where = array('id >' => 2, 'name !=' => 'Accountant');
- $jobs = $this->db->where($where)->get('job')->result_array();
-
- $this->assertEquals(1, count($jobs));
-
- // Should be Musician
- $job = current($jobs);
- $this->assertEquals('Musician', $job['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_custom_string()
- {
- $where = "id > 2 AND name != 'Accountant'";
- $jobs = $this->db->where($where)->get('job')->result_array();
-
- $this->assertEquals(1, count($jobs));
-
- // Should be Musician
- $job = current($jobs);
- $this->assertEquals('Musician', $job['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_or()
- {
- $jobs = $this->db->where('name !=', 'Accountant')
- ->or_where('id >', 3)
- ->get('job')
- ->result_array();
-
- $this->assertEquals(3, count($jobs));
- $this->assertEquals('Developer', $jobs[0]['name']);
- $this->assertEquals('Politician', $jobs[1]['name']);
- $this->assertEquals('Musician', $jobs[2]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_in()
- {
- $jobs = $this->db->where_in('name', array('Politician', 'Accountant'))
- ->get('job')
- ->result_array();
-
- $this->assertEquals(2, count($jobs));
- $this->assertEquals('Politician', $jobs[0]['name']);
- $this->assertEquals('Accountant', $jobs[1]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * @see ./mocks/schema/skeleton.php
- */
- public function test_where_not_in()
- {
- $jobs = $this->db->where_not_in('name', array('Politician', 'Accountant'))
- ->get('job')
- ->result_array();
-
- $this->assertEquals(2, count($jobs));
- $this->assertEquals('Developer', $jobs[0]['name']);
- $this->assertEquals('Musician', $jobs[1]['name']);
- }
-
- // ------------------------------------------------------------------------
-
- public function test_issue4093()
- {
- $input = 'bar and baz or qux';
- $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
deleted file mode 100644
index 5a9958971..000000000
--- a/tests/codeigniter/helpers/array_helper_test.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-class Array_helper_test extends CI_TestCase {
-
- public $my_array = array(
- 'foo' => 'bar',
- 'sally' => 'jim',
- 'maggie' => 'bessie',
- 'herb' => 'cook'
- );
-
- public function set_up()
- {
- $this->helper('array');
- }
-
- // ------------------------------------------------------------------------
-
- public function test_element_with_existing_item()
- {
- $this->assertEquals(FALSE, element('testing', $this->my_array));
- $this->assertEquals('not set', element('testing', $this->my_array, 'not set'));
- $this->assertEquals('bar', element('foo', $this->my_array));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_random_element()
- {
- // Send a string, not an array to random_element
- $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));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_elements()
- {
- $this->assertEquals(TRUE, is_array(elements('test', $this->my_array)));
- $this->assertEquals(TRUE, is_array(elements('foo', $this->my_array)));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/captcha_helper_test.php b/tests/codeigniter/helpers/captcha_helper_test.php
deleted file mode 100644
index bb8760a15..000000000
--- a/tests/codeigniter/helpers/captcha_helper_test.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-class Captcha_helper_test extends CI_TestCase {
-
- public function test_create_captcha()
- {
- $this->markTestSkipped("Can't test");
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/cookie_helper_test.php b/tests/codeigniter/helpers/cookie_helper_test.php
deleted file mode 100644
index fba68f20f..000000000
--- a/tests/codeigniter/helpers/cookie_helper_test.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-class Cookie_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('cookie');
- }
-
- // ------------------------------------------------------------------------
-
- function test_set_cookie()
- {
- /*$input_cls = $this->ci_core_class('input');
- $this->ci_instance_var('input', new $input_cls);
-
- $this->assertTrue(set_cookie(
- 'my_cookie',
- 'foobar'
- ));*/
-
- $this->markTestSkipped('Need to find a way to overcome a headers already set exception');
- }
-
- // ------------------------------------------------------------------------
-
- function test_get_cookie()
- {
- $_COOKIE['foo'] = 'bar';
-
- $security = new Mock_Core_Security();
- $utf8 = new Mock_Core_Utf8();
- $input_cls = $this->ci_core_class('input');
- $this->ci_instance_var('input', new Mock_Core_Input($security, $utf8));
-
- $this->assertEquals('bar', get_cookie('foo', FALSE));
- $this->assertEquals('bar', get_cookie('foo', TRUE));
-
- $_COOKIE['bar'] = "Hello, i try to <script>alert('Hack');</script> your site";
-
- $this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", get_cookie('bar', TRUE));
- $this->assertEquals("Hello, i try to <script>alert('Hack');</script> your site", get_cookie('bar', FALSE));
- }
-
- // ------------------------------------------------------------------------
-
- function test_delete_cookie()
- {
- /*$input_cls = $this->ci_core_class('input');
- $this->ci_instance_var('input', new $input_cls);
-
- $this->assertTrue(delete_cookie(
- 'my_cookie'
- ));*/
-
- $this->markTestSkipped('Need to find a way to overcome a headers already set exception');
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php
deleted file mode 100644
index b419418bf..000000000
--- a/tests/codeigniter/helpers/date_helper_test.php
+++ /dev/null
@@ -1,325 +0,0 @@
-<?php
-
-class Date_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('date');
- $this->time = time();
- }
-
- // ------------------------------------------------------------------------
-
- public function test_nice_date()
- {
- $this->assertEquals('2016-11-01', nice_date('201611', 'Y-m-d'));
- $this->assertEquals('2016-11-23', nice_date('20161123', 'Y-m-d'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_now_local()
- {
- /*
-
- // This stub job, is simply to cater $config['time_reference']
- $config = $this->getMockBuilder('CI_Config')->getMock();
- $config->expects($this->any())
- ->method('item')
- ->will($this->returnValue('local'));
-
- // Add the stub to our test instance
- $this->ci_instance_var('config', $config);
-
- */
-
- $this->ci_set_config('time_reference', 'local');
-
- $this->assertEquals(time(), now());
- }
-
- // ------------------------------------------------------------------------
-
- public function test_now_utc()
- {
- /*
-
- // This stub job, is simply to cater $config['time_reference']
- $config = $this->getMockBuilder('CI_Config')->getMock();
- $config->expects($this->any())
- ->method('item')
- ->will($this->returnValue('UTC'));
-
- // Add the stub to our stdClass
- $this->ci_instance_var('config', $config);
-
- */
-
- $this->assertEquals(
- mktime(gmdate('G'), gmdate('i'), gmdate('s'), gmdate('n'), gmdate('j'), gmdate('Y')),
- now('UTC')
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_mdate()
- {
- $this->assertEquals(
- date('Y-m-d - h:i a', $this->time),
- mdate('%Y-%m-%d - %h:%i %a', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc822()
- {
- $this->assertEquals(
- date(DATE_RFC822, $this->time),
- standard_date('DATE_RFC822', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_atom()
- {
- $this->assertEquals(
- date(DATE_ATOM, $this->time),
- standard_date('DATE_ATOM', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_cookie()
- {
- $this->assertEquals(
- date(DATE_COOKIE, $this->time),
- standard_date('DATE_COOKIE', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_iso8601()
- {
- $this->assertEquals(
- date(DATE_ISO8601, $this->time),
- standard_date('DATE_ISO8601', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc850()
- {
- $this->assertEquals(
- date(DATE_RFC850, $this->time),
- standard_date('DATE_RFC850', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc1036()
- {
- $this->assertEquals(
- date(DATE_RFC1036, $this->time),
- standard_date('DATE_RFC1036', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc1123()
- {
- $this->assertEquals(
- date(DATE_RFC1123, $this->time),
- standard_date('DATE_RFC1123', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc2822()
- {
- $this->assertEquals(
- date(DATE_RFC2822, $this->time),
- standard_date('DATE_RFC2822', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rss()
- {
- $this->assertEquals(
- date(DATE_RSS, $this->time),
- standard_date('DATE_RSS', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_w3c()
- {
- $this->assertEquals(
- date(DATE_W3C, $this->time),
- standard_date('DATE_W3C', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_timespan()
- {
- $this->ci_vfs_clone('system/language/english/date_lang.php');
-
- $loader_cls = $this->ci_core_class('load');
- $this->ci_instance_var('load', new $loader_cls);
-
- $lang_cls = $this->ci_core_class('lang');
- $this->ci_instance_var('lang', new $lang_cls);
-
- $this->assertEquals('1 Second', timespan(time(), time()+1));
- $this->assertEquals('1 Minute', timespan(time(), time()+60));
- $this->assertEquals('1 Hour', timespan(time(), time()+3600));
- $this->assertEquals('2 Hours', timespan(time(), time()+7200));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_days_in_month()
- {
- $this->assertEquals(30, days_in_month(06, 2005));
- $this->assertEquals(28, days_in_month(02, 2011));
- $this->assertEquals(29, days_in_month(02, 2012));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_local_to_gmt()
- {
- $this->assertEquals(
- mktime(
- gmdate('G', $this->time), gmdate('i', $this->time), gmdate('s', $this->time),
- gmdate('n', $this->time), gmdate('j', $this->time), gmdate('Y', $this->time)
- ),
- local_to_gmt($this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_gmt_to_local()
- {
- $this->assertEquals(1140128493, gmt_to_local('1140153693', 'UM8', TRUE));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_mysql_to_unix()
- {
- $this->assertEquals($this->time, mysql_to_unix(date('Y-m-d H:i:s', $this->time)));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_unix_to_human()
- {
- $this->assertEquals(date('Y-m-d h:i A', $this->time), unix_to_human($this->time));
- $this->assertEquals(date('Y-m-d h:i:s A', $this->time), unix_to_human($this->time, TRUE, 'us'));
- $this->assertEquals(date('Y-m-d H:i:s', $this->time), unix_to_human($this->time, TRUE, 'eu'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_human_to_unix()
- {
- $date = '2000-12-31 10:00:00 PM';
- $this->assertEquals(strtotime($date), human_to_unix($date));
- $this->assertFalse(human_to_unix());
- }
-
- // ------------------------------------------------------------------------
-
- public function test_timezones()
- {
- $zones = array(
- 'UM12' => -12,
- 'UM11' => -11,
- 'UM10' => -10,
- 'UM95' => -9.5,
- 'UM9' => -9,
- 'UM8' => -8,
- 'UM7' => -7,
- 'UM6' => -6,
- 'UM5' => -5,
- 'UM45' => -4.5,
- 'UM4' => -4,
- 'UM35' => -3.5,
- 'UM3' => -3,
- 'UM2' => -2,
- 'UM1' => -1,
- 'UTC' => 0,
- 'UP1' => +1,
- 'UP2' => +2,
- 'UP3' => +3,
- 'UP35' => +3.5,
- 'UP4' => +4,
- 'UP45' => +4.5,
- 'UP5' => +5,
- 'UP55' => +5.5,
- 'UP575' => +5.75,
- 'UP6' => +6,
- 'UP65' => +6.5,
- 'UP7' => +7,
- 'UP8' => +8,
- 'UP875' => +8.75,
- 'UP9' => +9,
- 'UP95' => +9.5,
- 'UP10' => +10,
- 'UP105' => +10.5,
- 'UP11' => +11,
- 'UP115' => +11.5,
- 'UP12' => +12,
- 'UP1275' => +12.75,
- 'UP13' => +13,
- 'UP14' => +14
- );
-
- foreach ($zones AS $test => $expected)
- {
- $this->assertEquals($expected, timezones($test));
- }
-
- $this->assertArrayHasKey('UP3', timezones());
- $this->assertEquals(0, timezones('non_existent'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_date_range()
- {
- $dates = array(
- '29-01-2012', '30-01-2012', '31-01-2012',
- '01-02-2012', '02-02-2012', '03-02-2012',
- '04-02-2012', '05-02-2012', '06-02-2012',
- '07-02-2012', '08-02-2012', '09-02-2012',
- '10-02-2012', '11-02-2012', '12-02-2012',
- '13-02-2012', '14-02-2012', '15-02-2012',
- '16-02-2012', '17-02-2012', '18-02-2012',
- '19-02-2012', '20-02-2012', '21-02-2012',
- '22-02-2012', '23-02-2012', '24-02-2012',
- '25-02-2012', '26-02-2012', '27-02-2012',
- '28-02-2012', '29-02-2012', '01-03-2012'
- );
-
- $this->assertEquals($dates, date_range(mktime(12, 0, 0, 1, 29, 2012), mktime(12, 0, 0, 3, 1, 2012), TRUE, 'd-m-Y'));
- array_pop($dates);
- $this->assertEquals($dates, date_range(mktime(12, 0, 0, 1, 29, 2012), 31, FALSE, 'd-m-Y'));
- }
-
-}
diff --git a/tests/codeigniter/helpers/directory_helper_test.php b/tests/codeigniter/helpers/directory_helper_test.php
deleted file mode 100644
index 253c1e368..000000000
--- a/tests/codeigniter/helpers/directory_helper_test.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-class Directory_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('directory');
-
- vfsStreamWrapper::register();
- vfsStreamWrapper::setRoot(new vfsStreamDirectory('testDir'));
-
- $this->_test_dir = vfsStreamWrapper::getRoot();
- }
-
- public function test_directory_map()
- {
- $ds = DIRECTORY_SEPARATOR;
-
- $structure = array(
- 'libraries' => array(
- 'benchmark.html' => '',
- 'database' => array('active_record.html' => '', 'binds.html' => ''),
- 'email.html' => '',
- '0' => '',
- '.hiddenfile.txt' => ''
- )
- );
-
- vfsStream::create($structure, $this->_test_dir);
-
- // is_dir(), opendir(), etc. seem to fail on Windows + vfsStream when there are trailing backslashes in directory names
- if ( ! is_dir(vfsStream::url('testDir').DIRECTORY_SEPARATOR))
- {
- $this->markTestSkipped("Can't test this under Windows");
- return;
- }
-
- // test default recursive behavior
- $expected = array(
- 'libraries'.$ds => array(
- 'benchmark.html',
- 'database'.$ds => array('active_record.html', 'binds.html'),
- 'email.html',
- '0'
- )
- );
-
- $this->assertEquals($expected, directory_map(vfsStream::url('testDir')));
-
- // test detection of hidden files
- $expected['libraries'.$ds][] = '.hiddenfile.txt';
-
- $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), 0, TRUE));
-
- // test recursion depth behavior
- $this->assertEquals(array('libraries'.$ds), directory_map(vfsStream::url('testDir'), 1));
- }
-
-}
diff --git a/tests/codeigniter/helpers/download_helper_test.php b/tests/codeigniter/helpers/download_helper_test.php
deleted file mode 100644
index d2b42e46b..000000000
--- a/tests/codeigniter/helpers/download_helper_test.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-class Download_helper_test extends CI_TestCase {
-
- public function test_force_download()
- {
- $this->markTestSkipped('Cant easily test');
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/email_helper_test.php b/tests/codeigniter/helpers/email_helper_test.php
deleted file mode 100644
index 529e96910..000000000
--- a/tests/codeigniter/helpers/email_helper_test.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-class Email_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('email');
- }
-
- public function test_valid_email()
- {
- $this->assertEquals(FALSE, valid_email('test'));
- $this->assertEquals(FALSE, valid_email('test@test@test.com'));
- $this->assertEquals(TRUE, valid_email('test@test.com'));
- $this->assertEquals(TRUE, valid_email('my.test@test.com'));
- $this->assertEquals(TRUE, valid_email('my.test@subdomain.test.com'));
- }
-
- public function test_send_mail()
- {
- $this->markTestSkipped("Can't test");
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/file_helper_test.php b/tests/codeigniter/helpers/file_helper_test.php
deleted file mode 100644
index c31817595..000000000
--- a/tests/codeigniter/helpers/file_helper_test.php
+++ /dev/null
@@ -1,147 +0,0 @@
-<?php
-
-class File_helper_Test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('file');
-
- vfsStreamWrapper::register();
- vfsStreamWrapper::setRoot(new vfsStreamDirectory('testDir'));
-
- $this->_test_dir = vfsStreamWrapper::getRoot();
- }
-
- // --------------------------------------------------------------------
-
- public function test_read_file()
- {
- $this->assertFalse(read_file('does_not_exist'));
-
- $content = 'Jack and Jill went up the mountain to fight a billy goat.';
-
- $file = vfsStream::newFile('my_file.txt')->withContent($content)->at($this->_test_dir);
-
- $this->assertEquals($content, read_file(vfsStream::url('my_file.txt')));
- }
-
- // --------------------------------------------------------------------
-
- public function test_octal_permissions()
- {
- $content = 'Jack and Jill went up the mountain to fight a billy goat.';
-
- $file = vfsStream::newFile('my_file.txt', 0777)
- ->withContent($content)
- ->lastModified(time() - 86400)
- ->at($this->_test_dir);
-
- $this->assertEquals('777', octal_permissions($file->getPermissions()));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * More tests should happen here, since I'm not hitting the whole function.
- */
- public function test_symbolic_permissions()
- {
- $content = 'Jack and Jill went up the mountain to fight a billy goat.';
-
- $file = vfsStream::newFile('my_file.txt', 0777)
- ->withContent($content)
- ->lastModified(time() - 86400)
- ->at($this->_test_dir);
-
- $this->assertEquals('urwxrwxrwx', symbolic_permissions($file->getPermissions()));
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_mime_by_extension()
- {
- $content = 'Jack and Jill went up the mountain to fight a billy goat.';
-
- $file = vfsStream::newFile('my_file.txt', 0777)
- ->withContent($content)
- ->lastModified(time() - 86400)
- ->at($this->_test_dir);
-
- $this->assertEquals('text/plain', get_mime_by_extension(vfsStream::url('my_file.txt')));
-
- // Test a mime with an array, such as png
- $file = vfsStream::newFile('foo.png')->at($this->_test_dir);
-
- $this->assertEquals('image/png', get_mime_by_extension(vfsStream::url('foo.png')));
-
- // Test a file not in the mimes array
- $file = vfsStream::newFile('foo.blarfengar')->at($this->_test_dir);
-
- $this->assertFalse(get_mime_by_extension(vfsStream::url('foo.blarfengar')));
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_file_info()
- {
- // Test Bad File
- $this->assertFalse(get_file_info('i_am_bad_boo'));
-
- // Test the rest
-
- // First pass in an array
- $vals = array(
- 'name', 'server_path', 'size', 'date',
- 'readable', 'writable', 'executable', 'fileperms'
- );
-
- $this->_test_get_file_info($vals);
-
- // Test passing in vals as a string.
- $this->_test_get_file_info(implode(', ', $vals));
- }
-
- private function _test_get_file_info($vals)
- {
- $content = 'Jack and Jill went up the mountain to fight a billy goat.';
- $last_modified = time() - 86400;
-
- $file = vfsStream::newFile('my_file.txt', 0777)
- ->withContent($content)
- ->lastModified($last_modified)
- ->at($this->_test_dir);
-
- $ret_values = array(
- 'name' => 'my_file.txt',
- 'server_path' => 'vfs://my_file.txt',
- 'size' => 57,
- 'date' => $last_modified,
- 'readable' => TRUE,
- 'writable' => TRUE,
- 'executable' => TRUE,
- 'fileperms' => 33279
- );
-
- $info = get_file_info(vfsStream::url('my_file.txt'), $vals);
-
- foreach ($info as $k => $v)
- {
- $this->assertEquals($ret_values[$k], $v);
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_write_file()
- {
- $content = 'Jack and Jill went up the mountain to fight a billy goat.';
-
- $file = vfsStream::newFile('write.txt', 0777)
- ->withContent('')
- ->lastModified(time() - 86400)
- ->at($this->_test_dir);
-
- $this->assertTrue(write_file(vfsStream::url('write.txt'), $content));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/form_helper_test.php b/tests/codeigniter/helpers/form_helper_test.php
deleted file mode 100644
index b5fe99b96..000000000
--- a/tests/codeigniter/helpers/form_helper_test.php
+++ /dev/null
@@ -1,290 +0,0 @@
-<?php
-
-class Form_helper_test extends CI_TestCase
-{
- public function set_up()
- {
- $this->helper('form');
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_hidden()
- {
- $expected = <<<EOH
-
-<input type="hidden" name="username" value="johndoe" />
-
-EOH;
-
- $this->assertEquals($expected, form_hidden('username', 'johndoe'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_input()
- {
- $expected = <<<EOH
-<input type="text" name="username" value="johndoe" id="username" maxlength="100" size="50" style="width:50%" />
-
-EOH;
-
- $data = array(
- 'name' => 'username',
- 'id' => 'username',
- 'value' => 'johndoe',
- 'maxlength' => '100',
- 'size' => '50',
- 'style' => 'width:50%',
- );
-
- $this->assertEquals($expected, form_input($data));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_password()
- {
- $expected = <<<EOH
-<input type="password" name="password" value="" />
-
-EOH;
-
- $this->assertEquals($expected, form_password('password'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_upload()
- {
- $expected = <<<EOH
-<input type="file" name="attachment" />
-
-EOH;
-
- $this->assertEquals($expected, form_upload('attachment'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_textarea()
- {
- $expected = <<<EOH
-<textarea name="notes" cols="40" rows="10" >Notes</textarea>
-
-EOH;
-
- $this->assertEquals($expected, form_textarea('notes', 'Notes'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_dropdown()
- {
- $expected = <<<EOH
-<select name="shirts">
-<option value="small">Small Shirt</option>
-<option value="med">Medium Shirt</option>
-<option value="large" selected="selected">Large Shirt</option>
-<option value="xlarge">Extra Large Shirt</option>
-</select>
-
-EOH;
-
- $options = array(
- 'small' => 'Small Shirt',
- 'med' => 'Medium Shirt',
- 'large' => 'Large Shirt',
- 'xlarge' => 'Extra Large Shirt',
- );
-
- $this->assertEquals($expected, form_dropdown('shirts', $options, 'large'));
-
- $expected = <<<EOH
-<select name="shirts" multiple="multiple">
-<option value="small" selected="selected">Small Shirt</option>
-<option value="med">Medium Shirt</option>
-<option value="large" selected="selected">Large Shirt</option>
-<option value="xlarge">Extra Large Shirt</option>
-</select>
-
-EOH;
-
- $shirts_on_sale = array('small', 'large');
-
- $this->assertEquals($expected, form_dropdown('shirts', $options, $shirts_on_sale));
-
- $options = array(
- 'Swedish Cars' => array(
- 'volvo' => 'Volvo',
- 'saab' => 'Saab'
- ),
- 'German Cars' => array(
- 'mercedes' => 'Mercedes',
- 'audi' => 'Audi'
- )
- );
-
- $expected = <<<EOH
-<select name="cars" multiple="multiple">
-<optgroup label="Swedish Cars">
-<option value="volvo" selected="selected">Volvo</option>
-<option value="saab">Saab</option>
-</optgroup>
-<optgroup label="German Cars">
-<option value="mercedes">Mercedes</option>
-<option value="audi" selected="selected">Audi</option>
-</optgroup>
-</select>
-
-EOH;
-
- $this->assertEquals($expected, form_dropdown('cars', $options, array('volvo', 'audi')));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_multiselect()
- {
- $expected = <<<EOH
-<select name="shirts[]" multiple="multiple">
-<option value="small">Small Shirt</option>
-<option value="med" selected="selected">Medium Shirt</option>
-<option value="large" selected="selected">Large Shirt</option>
-<option value="xlarge">Extra Large Shirt</option>
-</select>
-
-EOH;
-
- $options = array(
- 'small' => 'Small Shirt',
- 'med' => 'Medium Shirt',
- 'large' => 'Large Shirt',
- 'xlarge' => 'Extra Large Shirt',
- );
-
- $this->assertEquals($expected, form_multiselect('shirts[]', $options, array('med', 'large')));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_fieldset()
- {
- $expected = <<<EOH
-<fieldset>
-<legend>Address Information</legend>
-
-EOH;
-
- $this->assertEquals($expected, form_fieldset('Address Information'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_fieldset_close()
- {
- $expected = <<<EOH
-</fieldset></div></div>
-EOH;
-
- $this->assertEquals($expected, form_fieldset_close('</div></div>'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_checkbox()
- {
- $expected = <<<EOH
-<input type="checkbox" name="newsletter" value="accept" checked="checked" />
-
-EOH;
-
- $this->assertEquals($expected, form_checkbox('newsletter', 'accept', TRUE));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_radio()
- {
- $expected = <<<EOH
-<input type="radio" name="newsletter" value="accept" checked="checked" />
-
-EOH;
-
- $this->assertEquals($expected, form_radio('newsletter', 'accept', TRUE));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_submit()
- {
- $expected = <<<EOH
-<input type="submit" name="mysubmit" value="Submit Post!" />
-
-EOH;
-
- $this->assertEquals($expected, form_submit('mysubmit', 'Submit Post!'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_label()
- {
- $expected = <<<EOH
-<label for="username">What is your Name</label>
-EOH;
-
- $this->assertEquals($expected, form_label('What is your Name', 'username'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_reset()
- {
- $expected = <<<EOH
-<input type="reset" name="myreset" value="Reset" />
-
-EOH;
-
- $this->assertEquals($expected, form_reset('myreset', 'Reset'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_button()
- {
- $expected = <<<EOH
-<button name="name" type="button" >content</button>
-
-EOH;
-
- $this->assertEquals($expected, form_button('name', 'content'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_close()
- {
- $expected = <<<EOH
-</form></div></div>
-EOH;
-
- $this->assertEquals($expected, form_close('</div></div>'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_form_prep()
- {
- $this->assertEquals(
- 'Here is a string containing &quot;quoted&quot; text.',
- form_prep('Here is a string containing "quoted" text.')
- );
-
- $this->assertEquals(
- 'Here is a string containing a &lt;tag&gt;.',
- form_prep('Here is a string containing a <tag>.', TRUE)
- );
- }
-
-}
diff --git a/tests/codeigniter/helpers/html_helper_test.php b/tests/codeigniter/helpers/html_helper_test.php
deleted file mode 100644
index 3cf1016ec..000000000
--- a/tests/codeigniter/helpers/html_helper_test.php
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php
-
-class Html_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('html');
- }
-
- // ------------------------------------------------------------------------
-
- public function test_br()
- {
- $this->assertEquals('<br /><br />', br(2));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_heading()
- {
- $this->assertEquals('<h1>foobar</h1>', heading('foobar'));
- $this->assertEquals('<h2 class="bar">foobar</h2>', heading('foobar', 2, 'class="bar"'));
- }
-
- public function test_heading_array_attributes()
- {
- // Test array of attributes
- $this->assertEquals('<h2 class="bar" id="foo">foobar</h2>', heading('foobar', 2, array('class' => 'bar', 'id' => 'foo')));
- }
-
- public function test_heading_object_attributes()
- {
- // Test array of attributes
- $this->assertEquals('<h2 class="bar" id="foo">foobar</h2>', heading('foobar', 2, array('class' => 'bar', 'id' => 'foo')));
- $test = new stdClass;
- $test->class = "bar";
- $test->id = "foo";
- $this->assertEquals('<h2 class="bar" id="foo">foobar</h2>', heading('foobar', 2, $test));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_img()
- {
- $this->ci_set_config('base_url', 'http://localhost/');
- $this->assertEquals('<img src="http://localhost/test" alt="" />', img("test"));
- $this->assertEquals('<img src="data:foo/bar,baz" alt="" />', img("data:foo/bar,baz"));
- $this->assertEquals('<img src="http://localhost/data://foo" alt="" />', img("data://foo"));
- $this->assertEquals('<img src="//foo.bar/baz" alt="" />', img("//foo.bar/baz"));
- $this->assertEquals('<img src="http://foo.bar/baz" alt="" />', img("http://foo.bar/baz"));
- $this->assertEquals('<img src="https://foo.bar/baz" alt="" />', img("https://foo.bar/baz"));
- $this->assertEquals('<img src="ftp://foo.bar/baz" alt="" />', img("ftp://foo.bar/baz"));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_Ul()
- {
- $expect = <<<EOH
-<ul>
- <li>foo</li>
- <li>bar</li>
-</ul>
-
-EOH;
-
- $expect = ltrim($expect);
- $list = array('foo', 'bar');
-
- $this->assertEquals(ltrim($expect), ul($list));
-
- $expect = <<<EOH
-<ul class="test">
- <li>foo</li>
- <li>bar</li>
-</ul>
-
-EOH;
-
- $expect = ltrim($expect);
-
- $this->assertEquals($expect, ul($list, 'class="test"'));
-
- $this->assertEquals($expect, ul($list, array('class' => 'test')));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_NBS()
- {
- $this->assertEquals('&nbsp;&nbsp;&nbsp;', nbs(3));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_meta()
- {
- $this->assertEquals("<meta name=\"test\" content=\"foo\" />\n", meta('test', 'foo'));
-
- $expect = "<meta name=\"foo\" content=\"\" />\n";
-
- $this->assertEquals($expect, meta(array('name' => 'foo')));
-
- }
-
-}
diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php
deleted file mode 100644
index 81ce5e394..000000000
--- a/tests/codeigniter/helpers/inflector_helper_test.php
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-
-class Inflector_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('inflector');
- }
-
- public function test_singular()
- {
- $strs = array(
- 'tellies' => 'telly',
- 'smellies' => 'smelly',
- 'abjectnesses' => 'abjectness',
- 'smells' => 'smell',
- 'equipment' => 'equipment'
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, singular($str));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_plural()
- {
- $strs = array(
- 'telly' => 'tellies',
- 'smelly' => 'smellies',
- 'abjectness' => 'abjectnesses', // ref : http://en.wiktionary.org/wiki/abjectnesses
- 'smell' => 'smells',
- 'witch' => 'witches',
- 'equipment' => 'equipment'
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, plural($str));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_camelize()
- {
- $strs = array(
- 'this is the string' => 'thisIsTheString',
- 'this is another one' => 'thisIsAnotherOne',
- 'i-am-playing-a-trick' => 'i-am-playing-a-trick',
- 'what_do_you_think-yo?' => 'whatDoYouThink-yo?',
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, camelize($str));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_underscore()
- {
- $strs = array(
- 'this is the string' => 'this_is_the_string',
- 'this is another one' => 'this_is_another_one',
- 'i-am-playing-a-trick' => 'i-am-playing-a-trick',
- 'what_do_you_think-yo?' => 'what_do_you_think-yo?',
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, underscore($str));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_humanize()
- {
- $strs = array(
- 'this_is_the_string' => 'This Is The String',
- 'this_is_another_one' => 'This Is Another One',
- 'i-am-playing-a-trick' => 'I-am-playing-a-trick',
- 'what_do_you_think-yo?' => 'What Do You Think-yo?',
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, humanize($str));
- }
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/language_helper_test.php b/tests/codeigniter/helpers/language_helper_test.php
deleted file mode 100644
index 1ddabea3d..000000000
--- a/tests/codeigniter/helpers/language_helper_test.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-class Language_helper_test extends CI_TestCase {
-
- public function test_lang()
- {
- $this->helper('language');
- $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('line'))->getMock();
- $lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
- $this->ci_instance_var('lang', $lang);
-
- $this->assertFalse(lang(1));
- $this->assertEquals('<label for="foo" class="bar"></label>', lang(1, 'foo', array('class' => 'bar')));
- }
-
-}
diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php
deleted file mode 100644
index 663e354fe..000000000
--- a/tests/codeigniter/helpers/number_helper_test.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-
-class Number_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('number');
-
- // Grab the core lang class
- $lang_cls = $this->ci_core_class('lang');
-
- // Mock away load, too much going on in there,
- // we'll just check for the expected parameter
- $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
- $lang->expects($this->once())
- ->method('load')
- ->with($this->equalTo('number'));
-
- // Assign the proper language array
- $lang->language = $this->lang('number');
-
- // We don't have a controller, so just create
- // a cheap class to act as our super object.
- // Make sure it has a lang attribute.
- $this->ci_instance_var('lang', $lang);
- }
-
- public function test_byte_format()
- {
- $this->assertEquals('456 Bytes', byte_format(456));
- }
-
- public function test_kb_format()
- {
- $this->assertEquals('4.5 KB', byte_format(4567));
- }
-
- public function test_kb_format_medium()
- {
- $this->assertEquals('44.6 KB', byte_format(45678));
- }
-
- public function test_kb_format_large()
- {
- $this->assertEquals('446.1 KB', byte_format(456789));
- }
-
- public function test_mb_format()
- {
- $this->assertEquals('3.3 MB', byte_format(3456789));
- }
-
- public function test_gb_format()
- {
- $this->assertEquals('1.8 GB', byte_format(1932735283.2));
- }
-
- public function test_tb_format()
- {
- $this->assertEquals('112,283.3 TB', byte_format(123456789123456789));
- }
-
-}
diff --git a/tests/codeigniter/helpers/path_helper_test.php b/tests/codeigniter/helpers/path_helper_test.php
deleted file mode 100644
index 9d325e70d..000000000
--- a/tests/codeigniter/helpers/path_helper_test.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-class Path_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('path');
- }
-
- public function test_set_realpath()
- {
- $this->assertEquals(getcwd().DIRECTORY_SEPARATOR, set_realpath(getcwd()));
- }
-
- public function test_set_realpath_nonexistent_directory()
- {
- $expected = '/path/to/nowhere';
- $this->assertEquals($expected, set_realpath('/path/to/nowhere', FALSE));
- }
-
- public function test_set_realpath_error_trigger()
- {
- $this->setExpectedException(
- 'RuntimeException', 'CI Error: Not a valid path: /path/to/nowhere'
- );
-
- set_realpath('/path/to/nowhere', TRUE);
- }
-
-}
diff --git a/tests/codeigniter/helpers/security_helper_test.php b/tests/codeigniter/helpers/security_helper_test.php
deleted file mode 100644
index effd3ec02..000000000
--- a/tests/codeigniter/helpers/security_helper_test.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-class Security_helper_tests extends CI_TestCase {
-
- function setUp()
- {
- $this->helper('security');
- $obj = new stdClass;
- $obj->security = new Mock_Core_Security();
- $this->ci_instance($obj);
- }
-
- function test_xss_clean()
- {
- $this->assertEquals('foo', xss_clean('foo'));
-
- $this->assertEquals("Hello, i try to [removed]alert&#40;'Hack'&#41;;[removed] your site", xss_clean("Hello, i try to <script>alert('Hack');</script> your site"));
- }
-
- function test_sanitize_filename()
- {
- $this->assertEquals('hello.doc', sanitize_filename('hello.doc'));
-
- $filename = './<!--foo-->';
- $this->assertEquals('foo', sanitize_filename($filename));
- }
-
- function test_do_hash()
- {
- $md5 = md5('foo');
- $sha1 = sha1('foo');
-
- $algos = hash_algos();
- $algo_results = array();
- foreach ($algos as $k => $v)
- {
- $algo_results[$v] = hash($v, 'foo');
- }
-
- $this->assertEquals($sha1, do_hash('foo'));
- $this->assertEquals($sha1, do_hash('foo', 'sha1'));
- $this->assertEquals($md5, do_hash('foo', 'md5'));
- $this->assertEquals($md5, do_hash('foo', 'foobar'));
-
- // Test each algorithm available to PHP
- foreach ($algo_results as $algo => $result)
- {
- $this->assertEquals($result, do_hash('foo', $algo));
- }
- }
-
- function test_strip_image_tags()
- {
- $this->assertEquals('http://example.com/spacer.gif', strip_image_tags('http://example.com/spacer.gif'));
-
- $this->assertEquals('http://example.com/spacer.gif', strip_image_tags('<img src="http://example.com/spacer.gif" alt="Who needs CSS when you have a spacer.gif?" />'));
- }
-
- function test_encode_php_tags()
- {
- $this->assertEquals('&lt;? echo $foo; ?&gt;', encode_php_tags('<? echo $foo; ?>'));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/string_helper_test.php b/tests/codeigniter/helpers/string_helper_test.php
deleted file mode 100644
index 75701ec13..000000000
--- a/tests/codeigniter/helpers/string_helper_test.php
+++ /dev/null
@@ -1,148 +0,0 @@
-<?php
-
-class String_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('string');
- }
-
- public function test_strip_slashes()
- {
- $expected = array(
- "Is your name O'reilly?",
- "No, my name is O'connor."
- );
-
- $str = array(
- "Is your name O\'reilly?",
- "No, my name is O\'connor."
- );
-
- $this->assertEquals($expected, strip_slashes($str));
- }
-
- public function test_trim_slashes()
- {
- $strs = array(
- '//Slashes//\/' => 'Slashes//\\',
- '/var/www/html/' => 'var/www/html'
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, trim_slashes($str));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_strip_quotes()
- {
- $strs = array(
- '"me oh my!"' => 'me oh my!',
- "it's a winner!" => 'its a winner!',
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, strip_quotes($str));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_quotes_to_entities()
- {
- $strs = array(
- '"me oh my!"' => '&quot;me oh my!&quot;',
- "it's a winner!" => 'it&#39;s a winner!',
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, quotes_to_entities($str));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_reduce_double_slashes()
- {
- $strs = array(
- 'http://codeigniter.com' => 'http://codeigniter.com',
- '//var/www/html/example.com/' => '/var/www/html/example.com/',
- '/var/www/html//index.php' => '/var/www/html/index.php'
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, reduce_double_slashes($str));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_reduce_multiples()
- {
- $strs = array(
- 'Fred, Bill,, Joe, Jimmy' => 'Fred, Bill, Joe, Jimmy',
- 'Ringo, John, Paul,,' => 'Ringo, John, Paul,'
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, reduce_multiples($str));
- }
-
- $strs = array(
- 'Fred, Bill,, Joe, Jimmy' => 'Fred, Bill, Joe, Jimmy',
- 'Ringo, John, Paul,,' => 'Ringo, John, Paul'
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, reduce_multiples($str, ',', TRUE));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_repeater()
- {
- $strs = array(
- 'a' => 'aaaaaaaaaa',
- '&nbsp;' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
- '<br>' => '<br><br><br><br><br><br><br><br><br><br>'
-
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, repeater($str, 10));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_random_string()
- {
- $this->assertEquals(16, strlen(random_string('alnum', 16)));
- $this->assertEquals(32, strlen(random_string('unique', 16)));
- $this->assertInternalType('string', random_string('numeric', 16));
- }
-
- // --------------------------------------------------------------------
-
- public function test_increment_string()
- {
- $this->assertEquals('my-test_1', increment_string('my-test'));
- $this->assertEquals('my-test-1', increment_string('my-test', '-'));
- $this->assertEquals('file_5', increment_string('file_4'));
- $this->assertEquals('file-5', increment_string('file-4', '-'));
- $this->assertEquals('file-5', increment_string('file-4', '-'));
- $this->assertEquals('file-1', increment_string('file', '-', '1'));
- $this->assertEquals(124, increment_string('123', ''));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php
deleted file mode 100644
index 7a7dc0a12..000000000
--- a/tests/codeigniter/helpers/text_helper_test.php
+++ /dev/null
@@ -1,174 +0,0 @@
-<?php
-
-class Text_helper_test extends CI_TestCase {
-
- private $_long_string;
-
- public function set_up()
- {
- $this->helper('text');
-
- $this->_long_string = 'Once upon a time, a framework had no tests. It sad. So some nice people began to write tests. The more time that went on, the happier it became. Everyone was happy.';
- }
-
- // ------------------------------------------------------------------------
-
- public function test_word_limiter()
- {
- $this->assertEquals('Once upon a time,&#8230;', word_limiter($this->_long_string, 4));
- $this->assertEquals('Once upon a time,&hellip;', word_limiter($this->_long_string, 4, '&hellip;'));
- $this->assertEquals('', word_limiter('', 4));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_character_limiter()
- {
- $this->assertEquals('Once upon a time, a&#8230;', character_limiter($this->_long_string, 20));
- $this->assertEquals('Once upon a time, a&hellip;', character_limiter($this->_long_string, 20, '&hellip;'));
- $this->assertEquals('Short', character_limiter('Short', 20));
- $this->assertEquals('Short', character_limiter('Short', 5));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_ascii_to_entities()
- {
- $strs = array(
- '“‘ “testâ€' => '&#8220;&#8216; &#8220;test&#8221;',
- '†¥¨ˆøåß∂ƒ©˙∆˚¬' => '&#8224;&#165;&#168;&#710;&#248;&#229;&#223;&#8706;&#402;&#169;&#729;&#8710;&#730;&#172;'
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, ascii_to_entities($str));
- }
- }
-
- // ------------------------------------------------------------------------
-
- public function test_entities_to_ascii()
- {
- $strs = array(
- '&#8220;&#8216; &#8220;test&#8221;' => '“‘ “testâ€',
- '&#8224;&#165;&#168;&#710;&#248;&#229;&#223;&#8706;&#402;&#169;&#729;&#8710;&#730;&#172;' => '†¥¨ˆøåß∂ƒ©˙∆˚¬'
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, entities_to_ascii($str));
- }
- }
-
- // ------------------------------------------------------------------------
-
- public function test_convert_accented_characters()
- {
- $this->ci_vfs_clone('application/config/foreign_chars.php');
- $this->assertEquals('AAAeEEEIIOOEUUUeY', convert_accented_characters('ÀÂÄÈÊËÎÃÔŒÙÛÜŸ'));
- $this->assertEquals('a e i o u n ue', convert_accented_characters('á é í ó ú ñ ü'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_censored_words()
- {
- $censored = array('boob', 'nerd', 'ass', 'fart');
-
- $strs = array(
- 'Ted bobbled the ball' => 'Ted bobbled the ball',
- 'Jake is a nerdo' => 'Jake is a nerdo',
- 'The borg will assimilate you' => 'The borg will assimilate you',
- 'Did Mary Fart?' => 'Did Mary $*#?',
- 'Jake is really a boob' => 'Jake is really a $*#'
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, word_censor($str, $censored, '$*#'));
- }
-
- // test censored words being sent as a string
- $this->assertEquals('test', word_censor('test', 'test'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_highlight_code()
- {
- $expect = "<code><span style=\"color: #000000\">\n<span style=\"color: #0000BB\">&lt;?php&nbsp;var_dump</span><span style=\"color: #007700\">(</span><span style=\"color: #0000BB\">\$this</span><span style=\"color: #007700\">);&nbsp;</span><span style=\"color: #0000BB\">?&gt;&nbsp;</span>\n</span>\n</code>";
-
- $this->assertEquals($expect, highlight_code('<?php var_dump($this); ?>'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_highlight_phrase()
- {
- $strs = array(
- 'this is a phrase' => '<mark>this is</mark> a phrase',
- 'this is another' => '<mark>this is</mark> another',
- 'Gimme a test, Sally' => 'Gimme a test, Sally',
- 'Or tell me what this is' => 'Or tell me what <mark>this is</mark>',
- '' => ''
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, highlight_phrase($str, 'this is'));
- }
-
- $this->assertEquals('<strong>this is</strong> a strong test', highlight_phrase('this is a strong test', 'this is', '<strong>', '</strong>'));
- }
-
- // ------------------------------------------------------------------------
-
- public function test_ellipsize()
- {
- $strs = array(
- '0' => array(
- 'this is my string' => '&hellip; my string',
- "here's another one" => '&hellip;nother one',
- 'this one is just a bit longer' => '&hellip;bit longer',
- 'short' => 'short'
- ),
- '.5' => array(
- 'this is my string' => 'this &hellip;tring',
- "here's another one" => "here'&hellip;r one",
- 'this one is just a bit longer' => 'this &hellip;onger',
- 'short' => 'short'
- ),
- '1' => array(
- 'this is my string' => 'this is my&hellip;',
- "here's another one" => "here's ano&hellip;",
- 'this one is just a bit longer' => 'this one i&hellip;',
- 'short' => 'short'
- ),
- );
-
- foreach ($strs as $pos => $s)
- {
- foreach ($s as $str => $expect)
- {
- $this->assertEquals($expect, ellipsize($str, 10, $pos));
- }
- }
- }
-
- // ------------------------------------------------------------------------
-
- public function test_word_wrap()
- {
- $string = 'Here is a simple string of text that will help us demonstrate this function.';
- $this->assertEquals(substr_count(word_wrap($string, 25), "\n"), 4);
- }
-
- // ------------------------------------------------------------------------
-
- public function test_default_word_wrap_charlim()
- {
- $string = "Here is a longer string of text that will help us demonstrate the default charlim of this function.";
- $this->assertEquals(strpos(word_wrap($string), "\n"), 73);
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php
deleted file mode 100644
index 24823a634..000000000
--- a/tests/codeigniter/helpers/url_helper_test.php
+++ /dev/null
@@ -1,79 +0,0 @@
-<?php
-
-class Url_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('url');
- }
-
- public function test_url_title()
- {
- $words = array(
- 'foo bar /' => 'foo-bar',
- '\ testing 12' => 'testing-12'
- );
-
- foreach ($words as $in => $out)
- {
- $this->assertEquals($out, url_title($in, 'dash', TRUE));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_url_title_extra_dashes()
- {
- $words = array(
- '_foo bar_' => 'foo_bar',
- '_What\'s wrong with CSS?_' => 'Whats_wrong_with_CSS'
- );
-
- foreach ($words as $in => $out)
- {
- $this->assertEquals($out, url_title($in, 'underscore'));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_prep_url()
- {
- $this->assertEquals('http://codeigniter.com', prep_url('codeigniter.com'));
- $this->assertEquals('http://www.codeigniter.com', prep_url('www.codeigniter.com'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_auto_link_url()
- {
- $strings = array(
- 'www.codeigniter.com test' => '<a href="http://www.codeigniter.com">www.codeigniter.com</a> test',
- 'This is my noreply@codeigniter.com test' => 'This is my noreply@codeigniter.com test',
- '<br />www.google.com' => '<br /><a href="http://www.google.com">www.google.com</a>',
- 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">www.codeigniter.com</a>. Period test.',
- 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">www.codeigniter.com</a>, comma test',
- 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' => 'This one: <a href="://codeigniter.com">://codeigniter.com</a> must not break this one: <a href="http://codeigniter.com">http://codeigniter.com</a>'
- );
-
- foreach ($strings as $in => $out)
- {
- $this->assertEquals($out, auto_link($in, 'url'));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_pull_675()
- {
- $strings = array(
- '<br />www.google.com' => '<br /><a href="http://www.google.com">www.google.com</a>',
- );
-
- foreach ($strings as $in => $out)
- {
- $this->assertEquals($out, auto_link($in, 'url'));
- }
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/xml_helper_test.php b/tests/codeigniter/helpers/xml_helper_test.php
deleted file mode 100644
index e8cf411da..000000000
--- a/tests/codeigniter/helpers/xml_helper_test.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-class Xml_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('xml');
- }
-
- public function test_xml_convert()
- {
- $this->assertEquals('&lt;tag&gt;my &amp; test &#45; &lt;/tag&gt;', xml_convert('<tag>my & test - </tag>'));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/libraries/Calendar_test.php b/tests/codeigniter/libraries/Calendar_test.php
deleted file mode 100644
index ad1f45e8c..000000000
--- a/tests/codeigniter/libraries/Calendar_test.php
+++ /dev/null
@@ -1,222 +0,0 @@
-<?php
-
-class Calendar_test extends CI_TestCase {
-
- public function set_up()
- {
- // Required for get_total_days()
- $this->ci_instance_var('load', $this->getMockBuilder('CI_Loader')->setMethods(array('helper'))->getMock());
-
- $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load', 'line'))->getMock();
- $lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
- $this->ci_instance_var('lang', $lang);
-
- $this->calendar = new CI_Calendar();
- }
-
- // --------------------------------------------------------------------
-
- public function test_initialize()
- {
- $this->calendar->initialize(array(
- 'month_type' => 'short',
- 'start_day' => 'monday'
- ));
- $this->assertEquals('short', $this->calendar->month_type);
- $this->assertEquals('monday', $this->calendar->start_day);
- }
-
- // --------------------------------------------------------------------
-
- public function test_generate()
- {
- $no_events = '<table border="0" cellpadding="4" cellspacing="0">
-
-<tr>
-<th colspan="7">September&nbsp;2011</th>
-
-</tr>
-
-<tr>
-<td>Su</td><td>Mo</td><td>Tu</td><td>We</td><td>Th</td><td>Fr</td><td>Sa</td>
-</tr>
-
-<tr>
-<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>1</td><td>2</td><td>3</td>
-</tr>
-
-<tr>
-<td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td>
-</tr>
-
-<tr>
-<td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td>
-</tr>
-
-<tr>
-<td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td>
-</tr>
-
-<tr>
-<td>25</td><td>26</td><td>27</td><td>28</td><td>29</td><td>30</td><td>&nbsp;</td>
-</tr>
-
-</table>';
-
- $this->assertEquals($no_events, $this->calendar->generate(2011, 9));
-
- $data = array(
- 3 => 'http://example.com/news/article/2006/03/',
- 7 => 'http://example.com/news/article/2006/07/',
- 13 => 'http://example.com/news/article/2006/13/',
- 26 => 'http://example.com/news/article/2006/26/'
- );
-
- $events = '<table border="0" cellpadding="4" cellspacing="0">
-
-<tr>
-<th colspan="7">September&nbsp;2011</th>
-
-</tr>
-
-<tr>
-<td>Su</td><td>Mo</td><td>Tu</td><td>We</td><td>Th</td><td>Fr</td><td>Sa</td>
-</tr>
-
-<tr>
-<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>1</td><td>2</td><td><a href="http://example.com/news/article/2006/03/">3</a></td>
-</tr>
-
-<tr>
-<td>4</td><td>5</td><td>6</td><td><a href="http://example.com/news/article/2006/07/">7</a></td><td>8</td><td>9</td><td>10</td>
-</tr>
-
-<tr>
-<td>11</td><td>12</td><td><a href="http://example.com/news/article/2006/13/">13</a></td><td>14</td><td>15</td><td>16</td><td>17</td>
-</tr>
-
-<tr>
-<td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td>
-</tr>
-
-<tr>
-<td>25</td><td><a href="http://example.com/news/article/2006/26/">26</a></td><td>27</td><td>28</td><td>29</td><td>30</td><td>&nbsp;</td>
-</tr>
-
-</table>';
-
- $this->assertEquals($events, $this->calendar->generate(2011, 9, $data));
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_month_name()
- {
- $this->calendar->month_type = NULL;
- $this->assertEquals('January', $this->calendar->get_month_name('01'));
-
- $this->calendar->month_type = 'short';
- $this->assertEquals('Jan', $this->calendar->get_month_name('01'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_day_names()
- {
- $this->assertEquals(array(
- 'Sunday',
- 'Monday',
- 'Tuesday',
- 'Wednesday',
- 'Thursday',
- 'Friday',
- 'Saturday'
- ), $this->calendar->get_day_names('long'));
-
- $this->assertEquals(array(
- 'Sun',
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat'
- ), $this->calendar->get_day_names('short'));
-
- $this->calendar->day_type = NULL;
-
- $this->assertEquals(array(
- 'Su',
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa'
- ), $this->calendar->get_day_names());
- }
-
- // --------------------------------------------------------------------
-
- public function test_adjust_date()
- {
- $this->assertEquals(array('month' => 8, 'year' => 2012), $this->calendar->adjust_date(8, 2012));
- $this->assertEquals(array('month' => 1, 'year' => 2013), $this->calendar->adjust_date(13, 2012));
- }
-
- // --------------------------------------------------------------------
-
- public function test_get_total_days()
- {
- $this->assertEquals(0, $this->calendar->get_total_days(13, 2012));
-
- $this->assertEquals(31, $this->calendar->get_total_days(1, 2012));
- $this->assertEquals(28, $this->calendar->get_total_days(2, 2011));
- $this->assertEquals(29, $this->calendar->get_total_days(2, 2012));
- $this->assertEquals(31, $this->calendar->get_total_days(3, 2012));
- $this->assertEquals(30, $this->calendar->get_total_days(4, 2012));
- $this->assertEquals(31, $this->calendar->get_total_days(5, 2012));
- $this->assertEquals(30, $this->calendar->get_total_days(6, 2012));
- $this->assertEquals(31, $this->calendar->get_total_days(7, 2012));
- $this->assertEquals(31, $this->calendar->get_total_days(8, 2012));
- $this->assertEquals(30, $this->calendar->get_total_days(9, 2012));
- $this->assertEquals(31, $this->calendar->get_total_days(10, 2012));
- $this->assertEquals(30, $this->calendar->get_total_days(11, 2012));
- $this->assertEquals(31, $this->calendar->get_total_days(12, 2012));
- }
-
- // --------------------------------------------------------------------
-
- public function test_default_template()
- {
- $array = array(
- 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
- 'heading_row_start' => '<tr>',
- 'heading_previous_cell' => '<th><a href="{previous_url}">&lt;&lt;</a></th>',
- 'heading_title_cell' => '<th colspan="{colspan}">{heading}</th>',
- 'heading_next_cell' => '<th><a href="{next_url}">&gt;&gt;</a></th>',
- 'heading_row_end' => '</tr>',
- 'week_row_start' => '<tr>',
- 'week_day_cell' => '<td>{week_day}</td>',
- 'week_row_end' => '</tr>',
- 'cal_row_start' => '<tr>',
- 'cal_cell_start' => '<td>',
- 'cal_cell_start_today' => '<td>',
- 'cal_cell_content' => '<a href="{content}">{day}</a>',
- 'cal_cell_content_today' => '<a href="{content}"><strong>{day}</strong></a>',
- 'cal_cell_no_content' => '{day}',
- 'cal_cell_no_content_today' => '<strong>{day}</strong>',
- 'cal_cell_blank' => '&nbsp;',
- 'cal_cell_end' => '</td>',
- 'cal_cell_end_today' => '</td>',
- 'cal_row_end' => '</tr>',
- 'table_close' => '</table>',
- 'cal_cell_start_other' => '<td style="color: #666;">',
- 'cal_cell_other' => '{day}',
- 'cal_cell_end_other' => '</td>'
- );
-
- $this->assertEquals($array, $this->calendar->default_template());
- }
-
-}
diff --git a/tests/codeigniter/libraries/Driver_test.php b/tests/codeigniter/libraries/Driver_test.php
deleted file mode 100644
index e4401e688..000000000
--- a/tests/codeigniter/libraries/Driver_test.php
+++ /dev/null
@@ -1,178 +0,0 @@
-<?php
-
-/**
- * Driver library base class unit test
- */
-class Driver_test extends CI_TestCase {
-
- /**
- * Set up test framework
- */
- public function set_up()
- {
- // Set our subclass prefix
- $this->subclass = 'Mock_Libraries_';
- $this->ci_set_config('subclass_prefix', $this->subclass);
-
- // Mock Loader->get_package_paths
- $paths = 'get_package_paths';
- $ldr = $this->getMockBuilder('CI_Loader')->setMethods(array($paths))->getMock();
- $ldr->expects($this->any())->method($paths)->will($this->returnValue(array(APPPATH, BASEPATH)));
- $this->ci_instance_var('load', $ldr);
-
- // Create mock driver library
- $this->name = 'Driver';
- $this->lib = new Mock_Libraries_Driver();
- }
-
- /**
- * Test driver child loading
- */
- public function test_load_driver()
- {
- // Create driver file
- $driver = 'basic';
- $file = $this->name.'_'.$driver;
- $class = 'CI_'.$file;
- $prop = 'called';
- $content = '<?php class '.$class.' extends CI_Driver { public $'.$prop.' = FALSE; '.
- 'public function decorate($parent) { $this->'.$prop.' = TRUE; } }';
- $this->ci_vfs_create($file, $content, $this->ci_base_root, array('libraries', $this->name, 'drivers'));
-
- // Make driver valid
- $this->lib->driver_list($driver);
-
- // Load driver
- $this->assertNotNull($this->lib->load_driver($driver));
-
- // Did lib name get set?
- $this->assertEquals($this->name, $this->lib->get_name());
-
- // Was driver loaded?
- $this->assertObjectHasAttribute($driver, $this->lib);
- $this->assertAttributeInstanceOf($class, $driver, $this->lib);
- $this->assertAttributeInstanceOf('CI_Driver', $driver, $this->lib);
-
- // Was decorate called?
- $this->assertObjectHasAttribute($prop, $this->lib->$driver);
- $this->assertTrue($this->lib->$driver->$prop);
-
- // Do we get an error for an invalid driver?
- $driver = 'unlisted';
- $this->setExpectedException('RuntimeException', 'CI Error: Invalid driver requested: '.$this->name.'_'.$driver);
- $this->lib->load_driver($driver);
- }
-
- /**
- * Test loading lowercase from app path
- */
- public function test_load_app_driver()
- {
- // Create driver file
- $driver = 'lowpack';
- $file = $this->name.'_'.$driver;
- $class = 'CI_'.$file;
- $content = '<?php class '.$class.' extends CI_Driver { }';
- $this->ci_vfs_create($file, $content, $this->ci_app_root,
- array('libraries', $this->name, 'drivers'));
-
- // Make valid list
- $nodriver = 'absent';
- $this->lib->driver_list(array($driver, $nodriver));
-
- // Load driver
- $this->assertNotNull($this->lib->load_driver($driver));
-
- // Was driver loaded?
- $this->assertObjectHasAttribute($driver, $this->lib);
- $this->assertAttributeInstanceOf($class, $driver, $this->lib);
- $this->assertAttributeInstanceOf('CI_Driver', $driver, $this->lib);
-
- // Do we get an error for a non-existent driver?
- $this->setExpectedException('RuntimeException', 'CI Error: Unable to load the requested driver: CI_'.
- $this->name.'_'.$nodriver);
- $this->lib->load_driver($nodriver);
- }
-
- /**
- * Test loading driver extension
- */
- public function test_load_driver_ext()
- {
- // Create base file
- $driver = 'extend';
- $base = $this->name.'_'.$driver;
- $baseclass = 'CI_'.$base;
- $content = '<?php class '.$baseclass.' extends CI_Driver { }';
- $this->ci_vfs_create($base, $content, $this->ci_base_root, array('libraries', $this->name, 'drivers'));
-
- // Create driver file
- $class = $this->subclass.$base;
- $content = '<?php class '.$class.' extends '.$baseclass.' { }';
- $this->ci_vfs_create($class, $content, $this->ci_app_root, array('libraries', $this->name, 'drivers'));
-
- // Make valid list
- $this->lib->driver_list($driver);
-
- // Load driver
- $this->assertNotNull($this->lib->load_driver($driver));
-
- // Was driver loaded?
- $this->assertObjectHasAttribute($driver, $this->lib);
- $this->assertAttributeInstanceOf($class, $driver, $this->lib);
- $this->assertAttributeInstanceOf($baseclass, $driver, $this->lib);
- $this->assertAttributeInstanceOf('CI_Driver', $driver, $this->lib);
-
- // Create driver extension without base
- $driver = 'baseless';
- $base = $this->name.'_'.$driver;
- $class = $this->subclass.$base;
- $content = '<?php class '.$class.' extends CI_Driver { }';
- $this->ci_vfs_create($class, $content, $this->ci_app_root, array('libraries', $this->name, 'drivers'));
- $this->lib->driver_list($driver);
-
- // Do we get an error when base class isn't found?
- $this->setExpectedException('RuntimeException', 'CI Error: Unable to load the requested class: CI_'.$base);
- $this->lib->load_driver($driver);
- }
-
- /**
- * Test decorating driver with parent attributes
- */
- public function test_decorate()
- {
- // Create parent with a method and property to access
- $pclass = 'Test_Parent';
- $prop = 'parent_prop';
- $value = 'initial';
- $method = 'parent_func';
- $return = 'func return';
- $code = 'class '.$pclass.' { public $'.$prop.' = \''.$value.'\'; '.
- 'public function '.$method.'() { return \''.$return.'\'; } }';
- eval($code);
- $parent = new $pclass();
-
- // Create child driver to decorate
- $class = 'Test_Driver';
- eval('class '.$class.' extends CI_Driver { }');
- $child = new $class();
-
- // Decorate child
- $child->decorate($parent);
-
- // Do we get the initial parent property value?
- $this->assertEquals($value, $child->$prop);
-
- // Can we change the parent property?
- $newval = 'changed';
- $child->$prop = $newval;
- $this->assertEquals($newval, $parent->$prop);
-
- // Do we get back the updated value?
- $this->assertEquals($newval, $child->$prop);
-
- // Can we call the parent method?
- $this->assertEquals($return, $child->$method());
- }
-
-}
diff --git a/tests/codeigniter/libraries/Encrypt_test.php b/tests/codeigniter/libraries/Encrypt_test.php
deleted file mode 100644
index adbca31b2..000000000
--- a/tests/codeigniter/libraries/Encrypt_test.php
+++ /dev/null
@@ -1,79 +0,0 @@
-<?php
-/**
- * @requires extension mcrypt
- */
-class Encrypt_test extends CI_TestCase {
-
- public function set_up()
- {
- if ( ! extension_loaded('mcrypt'))
- {
- return;
- }
- elseif (version_compare(PHP_VERSION, '7.1.0-alpha', '>='))
- {
- return $this->markTestSkipped('ext/mcrypt is deprecated since PHP 7.1 and will generate notices here.');
- }
-
- $this->encrypt = new Mock_Libraries_Encrypt();
- $this->ci_instance_var('encrypt', $this->encrypt);
-
- $this->ci_set_config('encryption_key', "Encryptin'glike@boss!");
- $this->msg = 'My secret message';
- }
-
- // --------------------------------------------------------------------
-
- public function test_encode()
- {
- $this->assertNotEquals($this->msg, $this->encrypt->encode($this->msg));
- }
-
- // --------------------------------------------------------------------
-
- public function test_decode()
- {
- $encoded_msg = $this->encrypt->encode($this->msg);
- $this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg));
- }
-
- // --------------------------------------------------------------------
-
- public function test_optional_key()
- {
- $key = 'Ohai!ù0129°03182%HD1892P0';
- $encoded_msg = $this->encrypt->encode($this->msg, $key);
- $this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg, $key));
- }
-
- // --------------------------------------------------------------------
-
- public function test_default_cipher()
- {
- $this->assertEquals('rijndael-256', $this->encrypt->get_cipher());
- }
-
- // --------------------------------------------------------------------
-
- public function test_set_cipher()
- {
- $this->encrypt->set_cipher(MCRYPT_BLOWFISH);
- $this->assertEquals('blowfish', $this->encrypt->get_cipher());
- }
-
- // --------------------------------------------------------------------
-
- public function test_default_mode()
- {
- $this->assertEquals('cbc', $this->encrypt->get_mode());
- }
-
- // --------------------------------------------------------------------
-
- public function test_set_mode()
- {
- $this->encrypt->set_mode(MCRYPT_MODE_CFB);
- $this->assertEquals('cfb', $this->encrypt->get_mode());
- }
-
-}
diff --git a/tests/codeigniter/libraries/Encryption_test.php b/tests/codeigniter/libraries/Encryption_test.php
deleted file mode 100644
index 99c5d4b9d..000000000
--- a/tests/codeigniter/libraries/Encryption_test.php
+++ /dev/null
@@ -1,400 +0,0 @@
-<?php
-
-class Encryption_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->encryption = new Mock_Libraries_Encryption();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * __construct test
- *
- * Covers behavior with $config['encryption_key'] set or not
- */
- public function test___construct()
- {
- // Assume no configuration from set_up()
- $this->assertNull($this->encryption->get_key());
-
- // Try with an empty value
- $this->ci_set_config('encryption_key');
- $this->encrypt = new Mock_Libraries_Encryption();
- $this->assertNull($this->encrypt->get_key());
-
- $this->ci_set_config('encryption_key', str_repeat("\x0", 16));
- $this->encrypt = new Mock_Libraries_Encryption();
- $this->assertEquals(str_repeat("\x0", 16), $this->encrypt->get_key());
- }
-
- // --------------------------------------------------------------------
-
- /**
- * hkdf() test
- *
- * Applies test vectors described in Appendix A(1-3) RFC5869.
- * Described vectors 4-7 SHA-1, which we don't support and are
- * therefore excluded.
- *
- * Because our implementation is a single method instead of being
- * split into hkdf_extract() and hkdf_expand(), we cannot test for
- * the PRK value. As long as the OKM is correct though, it's fine.
- *
- * @link https://tools.ietf.org/rfc/rfc5869.txt
- */
- public function test_hkdf()
- {
- $vectors = array(
- // A.1: Basic test case with SHA-256
- array(
- 'digest' => 'sha256',
- 'ikm' => "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
- 'salt' => "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c",
- 'length' => 42,
- 'info' => "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9",
- // 'prk' => "\x07\x77\x09\x36\x2c\x2e\x32\xdf\x0d\xdc\x3f\x0d\xc4\x7b\xba\x63\x90\xb6\xc7\x3b\xb5\x0f\x9c\x31\x22\xec\x84\x4a\xd7\xc2\xb3\xe5",
- 'okm' => "\x3c\xb2\x5f\x25\xfa\xac\xd5\x7a\x90\x43\x4f\x64\xd0\x36\x2f\x2a\x2d\x2d\x0a\x90\xcf\x1a\x5a\x4c\x5d\xb0\x2d\x56\xec\xc4\xc5\xbf\x34\x00\x72\x08\xd5\xb8\x87\x18\x58\x65"
- ),
- // A.2: Test with SHA-256 and longer inputs/outputs
- array(
- 'digest' => 'sha256',
- 'ikm' => "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f",
- 'salt' => "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf",
- 'length' => 82,
- 'info' => "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
- // 'prk' => "\x06\xa6\xb8\x8c\x58\x53\x36\x1a\x06\x10\x4c\x9c\xeb\x35\xb4\x5c\xef\x76\x00\x14\x90\x46\x71\x01\x4a\x19\x3f\x40\xc1\x5f\xc2\x44",
- 'okm' => "\xb1\x1e\x39\x8d\xc8\x03\x27\xa1\xc8\xe7\xf7\x8c\x59\x6a\x49\x34\x4f\x01\x2e\xda\x2d\x4e\xfa\xd8\xa0\x50\xcc\x4c\x19\xaf\xa9\x7c\x59\x04\x5a\x99\xca\xc7\x82\x72\x71\xcb\x41\xc6\x5e\x59\x0e\x09\xda\x32\x75\x60\x0c\x2f\x09\xb8\x36\x77\x93\xa9\xac\xa3\xdb\x71\xcc\x30\xc5\x81\x79\xec\x3e\x87\xc1\x4c\x01\xd5\xc1\xf3\x43\x4f\x1d\x87",
- ),
- // A.3: Test with SHA-256 and zero-length salt/info
- array(
- 'digest' => 'sha256',
- 'ikm' => "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
- 'salt' => '',
- 'length' => 42,
- 'info' => '',
- // 'prk' => "\x19\xef\x24\xa3\x2c\x71\x7b\x16\x7f\x33\xa9\x1d\x6f\x64\x8b\xdf\x96\x59\x67\x76\xaf\xdb\x63\x77\xac\x43\x4c\x1c\x29\x3c\xcb\x04",
- 'okm' => "\x8d\xa4\xe7\x75\xa5\x63\xc1\x8f\x71\x5f\x80\x2a\x06\x3c\x5a\x31\xb8\xa1\x1f\x5c\x5e\xe1\x87\x9e\xc3\x45\x4e\x5f\x3c\x73\x8d\x2d\x9d\x20\x13\x95\xfa\xa4\xb6\x1a\x96\xc8",
- )
- );
-
- foreach ($vectors as $test)
- {
- $this->assertEquals(
- $test['okm'],
- $this->encryption->hkdf(
- $test['ikm'],
- $test['digest'],
- $test['salt'],
- $test['length'],
- $test['info']
- )
- );
- }
-
- // Test default length, it must match the digest size
- $hkdf_result = $this->encryption->hkdf('foobar', 'sha512');
- $this->assertEquals(
- 64,
- defined('MB_OVERLOAD_STRING')
- ? mb_strlen($hkdf_result, '8bit')
- : strlen($hkdf_result)
- );
-
- // Test maximum length (RFC5869 says that it must be up to 255 times the digest size)
- $hkdf_result = $this->encryption->hkdf('foobar', 'sha384', NULL, 48 * 255);
- $this->assertEquals(
- 12240,
- defined('MB_OVERLOAD_STRING')
- ? mb_strlen($hkdf_result, '8bit')
- : strlen($hkdf_result)
- );
- $this->assertFalse($this->encryption->hkdf('foobar', 'sha224', NULL, 28 * 255 + 1));
-
- // CI-specific test for an invalid digest
- $this->assertFalse($this->encryption->hkdf('fobar', 'sha1'));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * _get_params() test
- */
- public function test__get_params()
- {
- $key = str_repeat("\x0", 16);
-
- // Invalid custom parameters
- $params = array(
- // No cipher, mode or key
- array('cipher' => 'aes-128', 'mode' => 'cbc'),
- array('cipher' => 'aes-128', 'key' => $key),
- array('mode' => 'cbc', 'key' => $key),
- // No HMAC key or not a valid digest
- array('cipher' => 'aes-128', 'mode' => 'cbc', 'key' => $key),
- array('cipher' => 'aes-128', 'mode' => 'cbc', 'key' => $key, 'hmac_digest' => 'sha1', 'hmac_key' => $key),
- // Invalid mode
- array('cipher' => 'aes-128', 'mode' => 'foo', 'key' => $key, 'hmac_digest' => 'sha256', 'hmac_key' => $key)
- );
-
- for ($i = 0, $c = count($params); $i < $c; $i++)
- {
- $this->assertFalse($this->encryption->__get_params($params[$i]));
- }
-
- // Valid parameters
- $params = array(
- 'cipher' => 'aes-128',
- 'mode' => 'cbc',
- 'key' => str_repeat("\x0", 16),
- 'hmac_key' => str_repeat("\x0", 16)
- );
-
- $this->assertTrue(is_array($this->encryption->__get_params($params)));
-
- $params['base64'] = TRUE;
- $params['hmac_digest'] = 'sha512';
-
- // Including all parameters
- $params = array(
- 'cipher' => 'aes-128',
- 'mode' => 'cbc',
- 'key' => str_repeat("\x0", 16),
- 'raw_data' => TRUE,
- 'hmac_key' => str_repeat("\x0", 16),
- 'hmac_digest' => 'sha256'
- );
-
- $output = $this->encryption->__get_params($params);
- unset($output['handle'], $output['cipher'], $params['raw_data'], $params['cipher']);
- $params['base64'] = FALSE;
- $this->assertEquals($params, $output);
-
- // HMAC disabled
- unset($params['hmac_key'], $params['hmac_digest']);
- $params['hmac'] = $params['raw_data'] = FALSE;
- $params['cipher'] = 'aes-128';
- $output = $this->encryption->__get_params($params);
- unset($output['handle'], $output['cipher'], $params['hmac'], $params['raw_data'], $params['cipher']);
- $params['base64'] = TRUE;
- $params['hmac_digest'] = $params['hmac_key'] = NULL;
- $this->assertEquals($params, $output);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * initialize(), encrypt(), decrypt() test
- *
- * Testing the three methods separately is not realistic as they are
- * designed to work together. A more thorough test for initialize()
- * though is the OpenSSL/MCrypt compatibility test.
- *
- * @depends test_hkdf
- * @depends test__get_params
- */
- public function test_initialize_encrypt_decrypt()
- {
- $message = 'This is a plain-text message.';
- $key = "\xd0\xc9\x08\xc4\xde\x52\x12\x6e\xf8\xcc\xdb\x03\xea\xa0\x3a\x5c";
-
- // Default state (AES-128/Rijndael-128 in CBC mode)
- $this->encryption->initialize(array('key' => $key));
-
- // Was the key properly set?
- $this->assertEquals($key, $this->encryption->get_key());
-
- $this->assertEquals($message, $this->encryption->decrypt($this->encryption->encrypt($message)));
-
- // Try DES in ECB mode, just for the sake of changing stuff
- $this->encryption->initialize(array('cipher' => 'des', 'mode' => 'ecb', 'key' => substr($key, 0, 8)));
- $this->assertEquals($message, $this->encryption->decrypt($this->encryption->encrypt($message)));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * encrypt(), decrypt test with custom parameters
- *
- * @depends test___get_params
- */
- public function test_encrypt_decrypt_custom()
- {
- $message = 'Another plain-text message.';
-
- // A random invalid parameter
- $this->assertFalse($this->encryption->encrypt($message, array('foo')));
- $this->assertFalse($this->encryption->decrypt($message, array('foo')));
-
- // No HMAC, binary output
- $params = array(
- 'cipher' => 'tripledes',
- 'mode' => 'cfb',
- 'key' => str_repeat("\x1", 16),
- 'base64' => FALSE,
- 'hmac' => FALSE
- );
-
- $ciphertext = $this->encryption->encrypt($message, $params);
-
- $this->assertEquals($message, $this->encryption->decrypt($ciphertext, $params));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * _mcrypt_get_handle() test
- */
- public function test__mcrypt_get_handle()
- {
- if ($this->encryption->drivers['mcrypt'] === FALSE)
- {
- return $this->markTestSkipped('Cannot test MCrypt because it is not available.');
- }
- elseif (version_compare(PHP_VERSION, '7.1.0-alpha', '>='))
- {
- 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')));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * _openssl_get_handle() test
- */
- public function test__openssl_mcrypt_get_handle()
- {
- if ($this->encryption->drivers['openssl'] === FALSE)
- {
- return $this->markTestSkipped('Cannot test OpenSSL because it is not available.');
- }
-
- $this->assertEquals('aes-128-cbc', $this->encryption->__driver_get_handle('openssl', 'aes-128', 'cbc'));
- $this->assertEquals('rc4-40', $this->encryption->__driver_get_handle('openssl', 'rc4-40', 'stream'));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * OpenSSL/MCrypt portability test
- *
- * Amongst the obvious stuff, _cipher_alias() is also tested here.
- */
- public function test_portability()
- {
- if ( ! $this->encryption->drivers['mcrypt'] OR ! $this->encryption->drivers['openssl'])
- {
- $this->markTestSkipped('Both MCrypt and OpenSSL support are required for portability tests.');
- return;
- }
- elseif (version_compare(PHP_VERSION, '7.1.0-alpha', '>='))
- {
- return $this->markTestSkipped('ext/mcrypt is deprecated since PHP 7.1 and will generate notices here.');
- }
-
- $message = 'This is a message encrypted via MCrypt and decrypted via OpenSSL, or vice-versa.';
-
- // Format is: <Cipher name>, <Cipher mode>, <Key size>
- $portable = array(
- array('aes-128', 'cbc', 16),
- array('aes-128', 'cfb', 16),
- array('aes-128', 'cfb8', 16),
- array('aes-128', 'ofb', 16),
- array('aes-128', 'ecb', 16),
- array('aes-128', 'ctr', 16),
- array('aes-192', 'cbc', 24),
- array('aes-192', 'cfb', 24),
- array('aes-192', 'cfb8', 24),
- array('aes-192', 'ofb', 24),
- array('aes-192', 'ecb', 24),
- array('aes-192', 'ctr', 24),
- array('aes-256', 'cbc', 32),
- array('aes-256', 'cfb', 32),
- array('aes-256', 'cfb8', 32),
- array('aes-256', 'ofb', 32),
- array('aes-256', 'ecb', 32),
- array('aes-256', 'ctr', 32),
- array('des', 'cbc', 7),
- array('des', 'cfb', 7),
- array('des', 'cfb8', 7),
- array('des', 'ofb', 7),
- array('des', 'ecb', 7),
- array('tripledes', 'cbc', 7),
- array('tripledes', 'cfb', 7),
- array('tripledes', 'cfb8', 7),
- array('tripledes', 'ofb', 7),
- array('tripledes', 'cbc', 14),
- array('tripledes', 'cfb', 14),
- array('tripledes', 'cfb8', 14),
- array('tripledes', 'ofb', 14),
- array('tripledes', 'cbc', 21),
- array('tripledes', 'cfb', 21),
- array('tripledes', 'cfb8', 21),
- array('tripledes', 'ofb', 21),
- array('blowfish', 'cbc', 16),
- array('blowfish', 'cfb', 16),
- array('blowfish', 'ofb', 16),
- array('blowfish', 'ecb', 16),
- array('blowfish', 'cbc', 56),
- array('blowfish', 'cfb', 56),
- array('blowfish', 'ofb', 56),
- array('blowfish', 'ecb', 56),
- array('cast5', 'cbc', 11),
- array('cast5', 'cfb', 11),
- array('cast5', 'ofb', 11),
- array('cast5', 'ecb', 11),
- array('cast5', 'cbc', 16),
- array('cast5', 'cfb', 16),
- array('cast5', 'ofb', 16),
- array('cast5', 'ecb', 16),
- array('rc4', 'stream', 5),
- array('rc4', 'stream', 8),
- array('rc4', 'stream', 16),
- array('rc4', 'stream', 32),
- array('rc4', 'stream', 64),
- array('rc4', 'stream', 128),
- array('rc4', 'stream', 256)
- );
- $driver_index = array('mcrypt', 'openssl');
-
- foreach ($portable as &$test)
- {
- // Add some randomness to the selected driver
- $driver = mt_rand(0,1);
- $params = array(
- 'driver' => $driver_index[$driver],
- 'cipher' => $test[0],
- 'mode' => $test[1],
- 'key' => openssl_random_pseudo_bytes($test[2])
- );
-
- $this->encryption->initialize($params);
- $ciphertext = $this->encryption->encrypt($message);
-
- $driver = (int) ! $driver;
- $params['driver'] = $driver_index[$driver];
-
- $this->encryption->initialize($params);
- $this->assertEquals($message, $this->encryption->decrypt($ciphertext));
- }
- }
-
- // --------------------------------------------------------------------
-
- /**
- * __get() test
- */
- public function test_magic_get()
- {
- $this->assertNull($this->encryption->foo);
- $this->assertEquals(array('mcrypt', 'openssl'), array_keys($this->encryption->drivers));
-
- // 'stream' mode is translated into an empty string for OpenSSL
- $this->encryption->initialize(array('cipher' => 'rc4', 'mode' => 'stream'));
- $this->assertEquals('stream', $this->encryption->mode);
- }
-
-}
diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php
deleted file mode 100644
index c9c404b43..000000000
--- a/tests/codeigniter/libraries/Form_validation_test.php
+++ /dev/null
@@ -1,624 +0,0 @@
-<?php
-
-class Form_validation_test extends CI_TestCase {
-
- public function set_up()
- {
- $_SERVER['REQUEST_METHOD'] = 'POST';
-
- // Create a mock loader since load->helper() looks in the wrong directories for unit tests,
- // We'll use CI_TestCase->helper() instead
- $loader = $this->getMockBuilder('CI_Loader')->setMethods(array('helper'))->getMock();
-
- // Same applies for lang
- $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
-
- $this->ci_set_config('charset', 'UTF-8');
- $utf8 = new Mock_Core_Utf8();
- $security = new Mock_Core_Security();
- $input = new Mock_Core_Input($security, $utf8);
-
- $this->ci_instance_var('lang', $lang);
- $this->ci_instance_var('load', $loader);
- $this->ci_instance_var('input', $input);
-
- $this->lang('form_validation');
- $this->helper('form');
-
- $this->form_validation = new CI_Form_validation();
- }
-
- public function test_empty_array_input()
- {
- $this->assertFalse(
- $this->run_rules(
- array(array('field' => 'foo', 'label' => 'Foo Label', 'rules' => 'required')),
- array('foo' => array())
- )
- );
- }
-
- public function test_rule_required()
- {
- $rules = array(array('field' => 'foo', 'label' => 'Foo', 'rules' => 'is_numeric'));
-
- // Empty, not required
- $this->assertTrue($this->run_rules($rules, array('foo' => '')));
-
-
- // Not required, but also not empty
- $this->assertTrue($this->run_rules($rules, array('foo' => '123')));
- $this->assertFalse($this->run_rules($rules, array('foo' => 'bar')));
-
- // Required variations
- $rules[0]['rules'] .= '|required';
- $this->assertTrue($this->run_rules($rules, array('foo' => '123')));
- $this->assertFalse($this->run_rules($rules, array('foo' => '')));
- $this->assertFalse($this->run_rules($rules, array('foo' => ' ')));
- $this->assertFalse($this->run_rules($rules, array('foo' => 'bar')));
- }
-
- public function test_rule_matches()
- {
- $rules = array(
- array('field' => 'foo', 'label' => 'label', 'rules' => 'required'),
- array('field' => 'bar', 'label' => 'label2', 'rules' => 'matches[foo]')
- );
- $values_base = array('foo' => 'sample');
-
- $this->assertTrue($this->run_rules($rules, array_merge($values_base, array('bar' => 'sample'))));
-
- $this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => ''))));
- $this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => 'Sample'))));
- $this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => ' sample'))));
- }
-
- public function test_rule_differs()
- {
- $rules = array(
- array('field' => 'foo', 'label' => 'label', 'rules' => 'required'),
- array('field' => 'bar', 'label' => 'label2', 'rules' => 'differs[foo]')
- );
- $values_base = array('foo' => 'sample');
-
- $this->assertTrue($this->run_rules($rules, array_merge($values_base, array('bar' => 'does_not_match'))));
- $this->assertTrue($this->run_rules($rules, array_merge($values_base, array('bar' => 'Sample'))));
- $this->assertTrue($this->run_rules($rules, array_merge($values_base, array('bar' => ' sample'))));
-
- $this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => 'sample'))));
- }
-
- public function test_rule_min_length()
- {
- $this->assertTrue($this->form_validation->min_length('12345', '5'));
- $this->assertTrue($this->form_validation->min_length('test', '0'));
-
- $this->assertFalse($this->form_validation->min_length('123', '4'));
- $this->assertFalse($this->form_validation->min_length('should_fail', 'A'));
- $this->assertFalse($this->form_validation->min_length('', '4'));
- }
-
- public function test_rule_max_length()
- {
- $this->assertTrue($this->form_validation->max_length('', '4'));
- $this->assertTrue($this->form_validation->max_length('1234', '4'));
-
- $this->assertFalse($this->form_validation->max_length('12345', '4'));
- $this->assertFalse($this->form_validation->max_length('should_fail', 'A'));
- }
-
- public function test_rule_exact_length()
- {
- $this->assertTrue($this->form_validation->exact_length('1234', '4'));
-
- $this->assertFalse($this->form_validation->exact_length('', '3'));
- $this->assertFalse($this->form_validation->exact_length('12345', '4'));
- $this->assertFalse($this->form_validation->exact_length('123', '4'));
- $this->assertFalse($this->form_validation->exact_length('should_fail', 'A'));
- }
-
- public function test_rule_greater_than()
- {
- $this->assertTrue($this->form_validation->greater_than('-10', '-11'));
- $this->assertTrue($this->form_validation->greater_than('10', '9'));
-
- $this->assertFalse($this->form_validation->greater_than('10', '10'));
- $this->assertFalse($this->form_validation->greater_than('10', 'a'));
- $this->assertFalse($this->form_validation->greater_than('10a', '10'));
- }
-
- public function test_rule_greater_than_equal_to()
- {
- $this->assertTrue($this->form_validation->greater_than_equal_to('0', '0'));
- $this->assertTrue($this->form_validation->greater_than_equal_to('1', '0'));
-
- $this->assertFalse($this->form_validation->greater_than_equal_to('-1', '0'));
- $this->assertFalse($this->form_validation->greater_than_equal_to('10a', '0'));
- }
-
- public function test_rule_less_than()
- {
- $this->assertTrue($this->form_validation->less_than('4', '5'));
- $this->assertTrue($this->form_validation->less_than('-1', '0'));
-
- $this->assertFalse($this->form_validation->less_than('4', '4'));
- $this->assertFalse($this->form_validation->less_than('10a', '5'));
- }
-
- public function test_rule_less_than_equal_to()
- {
- $this->assertTrue($this->form_validation->less_than_equal_to('-1', '0'));
- $this->assertTrue($this->form_validation->less_than_equal_to('-1', '-1'));
- $this->assertTrue($this->form_validation->less_than_equal_to('4', '4'));
-
- $this->assertFalse($this->form_validation->less_than_equal_to('0', '-1'));
- $this->assertFalse($this->form_validation->less_than_equal_to('10a', '0'));
- }
-
- public function test_rule_in_list()
- {
- $this->assertTrue($this->form_validation->in_list('red', 'red,Blue,123'));
- $this->assertTrue($this->form_validation->in_list('Blue', 'red,Blue,123'));
- $this->assertTrue($this->form_validation->in_list('123', 'red,Blue,123'));
-
- $this->assertFalse($this->form_validation->in_list('Red', 'red,Blue,123'));
- $this->assertFalse($this->form_validation->in_list(' red', 'red,Blue,123'));
- $this->assertFalse($this->form_validation->in_list('1234', 'red,Blue,123'));
- }
-
- public function test_rule_alpha()
- {
- $this->assertTrue($this->form_validation->alpha('abcdefghijklmnopqrstuvwxyzABCDEFGHLIJKLMNOPQRSTUVWXYZ'));
-
- $this->assertFalse($this->form_validation->alpha('abcdefghijklmnopqrstuvwxyzABCDEFGHLIJKLMNOPQRSTUVWXYZ '));
- $this->assertFalse($this->form_validation->alpha('abcdefghijklmnopqrstuvwxyzABCDEFGHLIJKLMNOPQRSTUVWXYZ1'));
- $this->assertFalse($this->form_validation->alpha('abcdefghijklmnopqrstuvwxyzABCDEFGHLIJKLMNOPQRSTUVWXYZ*'));
- }
-
- public function test_rule_alpha_numeric()
- {
- $this->assertTrue($this->form_validation->alpha_numeric('abcdefghijklmnopqrstuvwxyzABCDEFGHLIJKLMNOPQRSTUVWXYZ0123456789'));
-
- $this->assertFalse($this->form_validation->alpha_numeric('abcdefghijklmnopqrstuvwxyzABCDEFGHLIJKLMNOPQRSTUVWXYZ0123456789\ '));
- $this->assertFalse($this->form_validation->alpha_numeric('abcdefghijklmnopqrstuvwxyzABCDEFGHLIJKLMNOPQRSTUVWXYZ0123456789_'));
- }
-
- public function test_rule_alpha_numeric_spaces()
- {
- $this->assertTrue($this->form_validation->alpha_numeric_spaces(' abcdefghijklmnopqrstuvwxyzABCDEFGHLIJKLMNOPQRSTUVWXYZ0123456789'));
-
- $this->assertFalse($this->form_validation->alpha_numeric_spaces(' abcdefghijklmnopqrstuvwxyzABCDEFGHLIJKLMNOPQRSTUVWXYZ0123456789_'));
- }
-
- public function test_rule_alpha_dash()
- {
- $this->assertTrue($this->form_validation->alpha_dash('abcdefghijklmnopqrstuvwxyzABCDEFGHLIJKLMNOPQRSTUVWXYZ0123456789-_'));
-
- $this->assertFalse($this->form_validation->alpha_dash('abcdefghijklmnopqrstuvwxyzABCDEFGHLIJKLMNOPQRSTUVWXYZ0123456789-_\ '));
- }
-
- public function test_rule_numeric()
- {
- $this->assertTrue($this->form_validation->numeric('0'));
- $this->assertTrue($this->form_validation->numeric('12314'));
- $this->assertTrue($this->form_validation->numeric('-42'));
-
- $this->assertFalse($this->form_validation->numeric('123a'));
- $this->assertFalse($this->form_validation->numeric('--1'));
- }
-
- public function test_rule_integer()
- {
- $this->assertTrue($this->form_validation->integer('0'));
- $this->assertTrue($this->form_validation->integer('42'));
- $this->assertTrue($this->form_validation->integer('-1'));
-
- $this->assertFalse($this->form_validation->integer('124a'));
- $this->assertFalse($this->form_validation->integer('1.9'));
- $this->assertFalse($this->form_validation->integer('--1'));
- }
-
- public function test_rule_decimal()
- {
- $this->assertTrue($this->form_validation->decimal('1.0'));
- $this->assertTrue($this->form_validation->decimal('-0.98'));
-
- $this->assertFalse($this->form_validation->decimal('0'));
- $this->assertFalse($this->form_validation->decimal('1.0a'));
- $this->assertFalse($this->form_validation->decimal('-i'));
- $this->assertFalse($this->form_validation->decimal('--1'));
- }
-
- public function test_rule_is_natural()
- {
- $this->assertTrue($this->form_validation->is_natural('0'));
- $this->assertTrue($this->form_validation->is_natural('12'));
-
- $this->assertFalse($this->form_validation->is_natural('42a'));
- $this->assertFalse($this->form_validation->is_natural('-1'));
- }
-
- public function test_rule_is_natural_no_zero()
- {
- $this->assertTrue($this->form_validation->is_natural_no_zero('42'));
-
- $this->assertFalse($this->form_validation->is_natural_no_zero('0'));
- $this->assertFalse($this->form_validation->is_natural_no_zero('42a'));
- $this->assertFalse($this->form_validation->is_natural_no_zero('-1'));
- }
-
- public function test_rule_valid_url()
- {
- $this->assertTrue($this->form_validation->valid_url('www.codeigniter.com'));
- $this->assertTrue($this->form_validation->valid_url('http://codeigniter.com'));
-
- // https://bugs.php.net/bug.php?id=51192
- $this->assertTrue($this->form_validation->valid_url('http://accept-dashes.tld'));
- $this->assertFalse($this->form_validation->valid_url('http://reject_underscores.tld'));
-
- // https://github.com/bcit-ci/CodeIgniter/issues/4415
- $this->assertTrue($this->form_validation->valid_url('http://[::1]/ipv6'));
-
- // URI scheme case-sensitivity: https://github.com/bcit-ci/CodeIgniter/pull/4758
- $this->assertTrue($this->form_validation->valid_url('HtTp://127.0.0.1/'));
-
- $this->assertFalse($this->form_validation->valid_url('htt://www.codeIgniter.com'));
- $this->assertFalse($this->form_validation->valid_url(''));
- $this->assertFalse($this->form_validation->valid_url('code igniter'));
- }
-
- public function test_rule_valid_email()
- {
- $this->assertTrue($this->form_validation->valid_email('email@sample.com'));
- $this->assertFalse($this->form_validation->valid_email('email@sample.com foo bar'));
- $this->assertFalse($this->form_validation->valid_email('valid_email', '@sample.com'));
- }
-
- public function test_rule_valid_emails()
- {
- $this->assertTrue($this->form_validation->valid_emails('1@sample.com,2@sample.com'));
- $this->assertTrue($this->form_validation->valid_emails('email@sample.com'));
-
- $this->assertFalse($this->form_validation->valid_emails('valid_email', '@sample.com'));
- $this->assertFalse($this->form_validation->valid_emails('@sample.com,2@sample.com,validemail@email.ca'));
- }
-
- public function test_rule_valid_ip()
- {
- $this->assertTrue($this->form_validation->valid_ip('127.0.0.1'));
- $this->assertTrue($this->form_validation->valid_ip('127.0.0.1', 'ipv4'));
- $this->assertTrue($this->form_validation->valid_ip('2001:0db8:85a3:0000:0000:8a2e:0370:7334'));
- $this->assertTrue($this->form_validation->valid_ip('2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'ipv6'));
-
- $this->assertFalse($this->form_validation->valid_ip('2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'ipv4'));
- $this->assertFalse($this->form_validation->valid_ip('127.0.0.1', 'ipv6'));
- $this->assertFalse($this->form_validation->valid_ip('H001:0db8:85a3:0000:0000:8a2e:0370:7334'));
- $this->assertFalse($this->form_validation->valid_ip('127.0.0.259'));
- }
-
- public function test_rule_valid_base64()
- {
- $this->assertTrue($this->form_validation->valid_base64(base64_encode('string')));
-
- $this->assertFalse($this->form_validation->valid_base64('FA08GG'));
- }
-
- public function test_set_data()
- {
- // Reset test environment
- $_POST = array();
- $this->form_validation->reset_validation();
- $data = array('field' => 'some_data');
- $this->form_validation->set_data($data);
- $this->form_validation->set_rules('field', 'label', 'required');
- $this->assertTrue($this->form_validation->run());
-
- // Test with empty array
- $_POST = array();
- $this->form_validation->reset_validation();
- $data = array('field' => 'some_data');
- $this->form_validation->set_data($data);
- // This should do nothing. Old data will still be used
- $this->form_validation->set_data(array());
- $this->form_validation->set_rules('field', 'label', 'required');
- $this->assertTrue($this->form_validation->run());
- }
-
- public function test_set_message()
- {
- // Reset test environment
- $_POST = array();
- $this->form_validation->reset_validation();
- $err_message = 'What a terrible error!';
- $rules = array(
- array(
- 'field' => 'req_field',
- 'label' => 'label',
- 'rules' => 'required'
- )
- );
- $errorless_data = array('req_field' => 'some text');
- $erroneous_data = array('req_field' => '');
-
- $this->form_validation->set_message('required', $err_message);
- $this->form_validation->set_data($erroneous_data);
- $this->form_validation->set_rules($rules);
- $this->form_validation->run();
- $this->assertEquals('<p>'.$err_message.'</p>', $this->form_validation->error('req_field'));
-
- $this->form_validation->reset_validation();
- $this->form_validation->set_message('required', $err_message);
- $this->form_validation->set_data($errorless_data);
- $this->form_validation->set_rules($rules);
- $this->form_validation->run();
- $this->assertEquals('', $this->form_validation->error('req_field'));
- }
-
- public function test_set_error_delimiters()
- {
- $this->form_validation->reset_validation();
- $prefix = '<div class="error">';
- $suffix = '</div>';
- $this->form_validation->set_error_delimiters($prefix, $suffix);
- $this->form_validation->set_rules('foo', 'label', 'required');
- $_POST = array('foo' => '');
- $this->form_validation->run();
- $error_msg = $this->form_validation->error('foo');
-
- $this->assertTrue(strrpos($error_msg, $prefix) === 0);
- $this->assertTrue(strrpos($error_msg, $suffix, -strlen($suffix)) === (strlen($error_msg) - strlen($suffix)));
- }
-
- public function test_error_array()
- {
- $this->form_validation->reset_validation();
- $error_message = 'What a terrible error!';
- $this->form_validation->set_message('required', $error_message);
- $this->form_validation->set_rules('foo', 'label', 'required');
- $_POST = array('foo' => '');
- $this->form_validation->run();
- $error_array = $this->form_validation->error_array();
- $this->assertEquals($error_message, $error_array['foo']);
- }
-
- public function test_error_string()
- {
- $this->form_validation->reset_validation();
- $error_message = 'What a terrible error!';
- $prefix_default = '<foo>';
- $suffix_default = '</foo>';
- $prefix_test = '<bar>';
- $suffix_test = '</bar>';
- $this->form_validation->set_error_delimiters($prefix_default, $suffix_default);
- $this->form_validation->set_message('required', $error_message);
- $this->form_validation->set_rules('foo', 'label', 'required');
- $_POST = array('foo' => '');
- $this->form_validation->run();
-
- $this->assertEquals($prefix_default.$error_message.$suffix_default."\n", $this->form_validation->error_string());
- $this->assertEquals($prefix_test.$error_message.$suffix_default."\n", $this->form_validation->error_string($prefix_test, ''));
- $this->assertEquals($prefix_default.$error_message.$suffix_test."\n", $this->form_validation->error_string('', $suffix_test));
- $this->assertEquals($prefix_test.$error_message.$suffix_test."\n", $this->form_validation->error_string($prefix_test, $suffix_test));
-
- $this->form_validation->reset_validation();
- $this->form_validation->set_rules('foo', 'label', 'required');
- $_POST = array('foo' => 'bar');
- $this->form_validation->run();
- $this->assertEquals('', $this->form_validation->error_string());
- }
-
- public function test_run()
- {
- // form_validation->run() is tested in many of the other unit tests
- // This test will only test run(group='') when group is not empty
- $config = array(
- 'pass' => array(
- array(
- 'field' => 'username',
- 'label' => 'user',
- 'rules' => 'alpha_numeric'
- )
- ),
- 'fail' => array(
- array(
- 'field' => 'username',
- 'label' => 'user',
- 'rules' => 'alpha'
- )
- )
- );
- $_POST = array('username' => 'foo42');
- $form_validation = new CI_Form_validation($config);
- $this->assertTrue($form_validation->run('pass'));
-
- $form_validation = new CI_Form_validation($config);
- $this->assertFalse($form_validation->run('fail'));
- }
-
- public function test_has_rule()
- {
- $this->form_validation->reset_validation();
- $this->form_validation->set_rules('foo', 'label', 'required');
-
- $this->assertTrue($this->form_validation->has_rule('foo'));
- $this->assertFalse($this->form_validation->has_rule('bar'));
- }
-
- public function test_set_value()
- {
- $this->form_validation->reset_validation();
- $default = 'default';
- $this->form_validation->set_rules('foo', 'label', 'required');
- $this->form_validation->set_rules('bar[]', 'label', 'required');
-
- // No post data yet: should return the default value provided
- $this->assertEquals($default, $this->form_validation->set_value('foo', $default));
- $_POST = array('foo' => 'foo', 'bar' => array('bar1', 'bar2'));
- $this->form_validation->run();
- $this->assertEquals('foo', $this->form_validation->set_value('foo', $default));
- $this->assertEquals('bar1', $this->form_validation->set_value('bar[]', $default));
- $this->assertEquals('bar2', $this->form_validation->set_value('bar[]', $default));
- }
-
- public function test_set_select()
- {
- // Test 1: No options selected
- $this->form_validation->reset_validation();
- $_POST = array();
- $this->form_validation->run();
-
- $this->assertEquals('', $this->form_validation->set_select('select', 'foo'));
- $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'bar', TRUE));
-
- // Test 2: 1 option selected
- $this->form_validation->reset_validation();
- $this->form_validation->set_rules('select', 'label', 'alpha_numeric');
- $_POST = array('select' => 'foo');
- $this->form_validation->run();
-
- $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'foo'));
- $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select', 'foo', TRUE));
- $this->assertEquals('', $this->form_validation->set_select('select', 'bar'));
- $this->assertEquals('', $this->form_validation->set_select('select', 'bar', TRUE));
-
- // Test 3: Multiple options selected
- $this->form_validation->reset_validation();
- $this->form_validation->set_rules('select[]', 'label', 'alpha_numeric');
- $_POST = array('select' => array('foo', 'bar'));
- $this->form_validation->run();
-
- $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select[]', 'foo'));
- $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select[]', 'foo', TRUE));
- $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select[]', 'bar'));
- $this->assertEquals(' selected="selected"', $this->form_validation->set_select('select[]', 'bar', TRUE));
- $this->assertEquals('', $this->form_validation->set_select('select[]', 'foobar'));
- $this->assertEquals('', $this->form_validation->set_select('select[]', 'foobar', TRUE));
- }
-
- public function test_set_radio()
- {
- // Test 1: No options selected
- $this->form_validation->reset_validation();
- $_POST = array();
- $this->form_validation->run();
-
- $this->assertEquals('', $this->form_validation->set_radio('select', 'foo'));
- // Default should only work when no rules are set
- $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'bar', TRUE));
-
- // Test 2: 1 option selected
- $this->form_validation->reset_validation();
- $this->form_validation->set_rules('select', 'label', 'alpha_numeric');
- $_POST = array('select' => 'foo');
- $this->form_validation->run();
-
- $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'foo'));
- $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select', 'foo', TRUE));
- $this->assertEquals('', $this->form_validation->set_radio('select', 'bar'));
- $this->assertEquals('', $this->form_validation->set_radio('select', 'bar', TRUE));
-
- // Test 3: Multiple options checked
- $this->form_validation->reset_validation();
- $this->form_validation->set_rules('select[]', 'label', 'alpha_numeric');
- $_POST = array('select' => array('foo', 'bar'));
- $this->form_validation->run();
-
- $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select[]', 'foo'));
- $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select[]', 'foo', TRUE));
- $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select[]', 'bar'));
- $this->assertEquals(' checked="checked"', $this->form_validation->set_radio('select[]', 'bar', TRUE));
- $this->assertEquals('', $this->form_validation->set_radio('select[]', 'foobar'));
- $this->assertEquals('', $this->form_validation->set_radio('select[]', 'foobar', TRUE));
- }
-
- public function test_set_checkbox()
- {
- // Test 1: No options selected
- $this->form_validation->reset_validation();
- $_POST = array();
- $this->form_validation->run();
-
- $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foo'));
- $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'bar', TRUE));
-
- // Test 2: 1 option selected
- $this->form_validation->reset_validation();
- $this->form_validation->set_rules('select', 'label', 'alpha_numeric');
- $_POST = array('select' => 'foo');
- $this->form_validation->run();
-
- $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'foo'));
- $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select', 'foo', TRUE));
- $this->assertEquals('', $this->form_validation->set_checkbox('select', 'bar'));
- $this->assertEquals('', $this->form_validation->set_checkbox('select', 'bar', TRUE));
-
- // Test 3: Multiple options selected
- $this->form_validation->reset_validation();
- $this->form_validation->set_rules('select[]', 'label', 'alpha_numeric');
- $_POST = array('select' => array('foo', 'bar'));
- $this->form_validation->run();
-
- $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select[]', 'foo'));
- $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select[]', 'foo', TRUE));
- $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select[]', 'bar'));
- $this->assertEquals(' checked="checked"', $this->form_validation->set_checkbox('select[]', 'bar', TRUE));
- $this->assertEquals('', $this->form_validation->set_checkbox('select[]', 'foobar'));
- $this->assertEquals('', $this->form_validation->set_checkbox('select[]', 'foobar', TRUE));
- }
-
- public function test_regex_match()
- {
- $regex = '/f[a-zA-Z]+/';
- $this->assertTrue($this->form_validation->regex_match('foo', $regex));
- $this->assertFalse($this->form_validation->regex_match('bar', $regex));
- }
-
- public function test_prep_for_form()
- {
- $this->form_validation->reset_validation();
- $error_msg_unprepped = '<error =\'foobar\'">';
- $error_msg_prepped = '&lt;error =&#39;foobar&#39;&quot;&gt;';
- $this->form_validation->set_rules('foo', 'label', 'required', array('required' => $error_msg_unprepped));
- $_POST = array('foo' => '');
- $this->form_validation->run();
- $error_arr = $this->form_validation->error_array();
-
- $this->assertEquals('', $this->form_validation->prep_for_form(''));
- $this->assertEquals(array('foo' => $error_msg_prepped), $this->form_validation->prep_for_form($error_arr));
- }
-
- public function test_prep_url()
- {
- $this->assertEquals('', $this->form_validation->prep_url(''));
- $this->assertEquals('http://codeigniter.com', $this->form_validation->prep_url('codeigniter.com'));
- $this->assertEquals('https://codeigniter.com', $this->form_validation->prep_url('https://codeigniter.com'));
- $this->assertEquals('http://codeigniter.com', $this->form_validation->prep_url('http://codeigniter.com'));
- $this->assertEquals('http://www.codeigniter.com', $this->form_validation->prep_url('www.codeigniter.com'));
- }
-
- public function test_encode_php_tags()
- {
- $this->assertEquals("&lt;?php", $this->form_validation->encode_php_tags('<?php'));
- $this->assertEquals('?&gt;', $this->form_validation->encode_php_tags('?>'));
- }
-
- /**
- * Run rules
- *
- * Helper method to set rules and run them at once, not
- * an actual test case.
- */
- public function run_rules($rules, $values)
- {
- $this->form_validation->reset_validation();
- $_POST = array();
-
- $this->form_validation->set_rules($rules);
- foreach ($values as $field => $value)
- {
- $_POST[$field] = $value;
- }
-
- return $this->form_validation->run();
- }
-}
diff --git a/tests/codeigniter/libraries/Parser_test.php b/tests/codeigniter/libraries/Parser_test.php
deleted file mode 100644
index 2a2348793..000000000
--- a/tests/codeigniter/libraries/Parser_test.php
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-
-class Parser_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->parser = new CI_Parser();
- $this->ci_instance_var('parser', $this->parser);
- }
-
- // --------------------------------------------------------------------
-
- public function test_set_delimiters()
- {
- // Make sure default delimiters are there
- $this->assertEquals('{', $this->parser->l_delim);
- $this->assertEquals('}', $this->parser->r_delim);
-
- // Change them to square brackets
- $this->parser->set_delimiters('[', ']');
-
- // Make sure they changed
- $this->assertEquals('[', $this->parser->l_delim);
- $this->assertEquals(']', $this->parser->r_delim);
-
- // Reset them
- $this->parser->set_delimiters();
-
- // Make sure default delimiters are there
- $this->assertEquals('{', $this->parser->l_delim);
- $this->assertEquals('}', $this->parser->r_delim);
- }
-
- // --------------------------------------------------------------------
-
- public function test_parse_string()
- {
- $data = array(
- 'title' => 'Page Title',
- 'body' => 'Lorem ipsum dolor sit amet.'
- );
-
- $template = "{title}\n{body}";
-
- $result = implode("\n", $data);
-
- $this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE));
- }
-
- // --------------------------------------------------------------------
-
- public function test_parse()
- {
- $this->_parse_no_template();
- $this->_parse_var_pair();
- $this->_mismatched_var_pair();
- }
-
- // --------------------------------------------------------------------
-
- private function _parse_no_template()
- {
- $this->assertFalse($this->parser->parse_string('', '', TRUE));
- }
-
- // --------------------------------------------------------------------
-
- private function _parse_var_pair()
- {
- $data = array(
- 'title' => 'Super Heroes',
- 'powers' => array(array('invisibility' => 'yes', 'flying' => 'no'))
- );
-
- $template = "{title}\n{powers}{invisibility}\n{flying}{/powers}\nsecond:{powers} {invisibility} {flying}{/powers}";
-
- $this->assertEquals("Super Heroes\nyes\nno\nsecond: yes no", $this->parser->parse_string($template, $data, TRUE));
- }
-
- // --------------------------------------------------------------------
-
- private function _mismatched_var_pair()
- {
- $data = array(
- 'title' => 'Super Heroes',
- 'powers' => array(array('invisibility' => 'yes', 'flying' => 'no'))
- );
-
- $template = "{title}\n{powers}{invisibility}\n{flying}";
- $result = "Super Heroes\n{powers}{invisibility}\n{flying}";
-
- $this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/libraries/Session_test.php b/tests/codeigniter/libraries/Session_test.php
deleted file mode 100644
index 76a4fcc98..000000000
--- a/tests/codeigniter/libraries/Session_test.php
+++ /dev/null
@@ -1,440 +0,0 @@
-<?php
-
-/**
- * Session driver library unit test
- */
-class Session_test extends CI_TestCase {
-
- protected $settings = array(
- 'use_cookies' => 0,
- 'use_only_cookies' => 0,
- 'cache_limiter' => FALSE
- );
- protected $setting_vals = array();
- protected $cookie_vals;
- protected $session;
-
- /**
- * Set up test framework
- */
- public function set_up()
- {
-return;
- // Override settings
- foreach ($this->settings as $name => $value) {
- $this->setting_vals[$name] = ini_get('session.'.$name);
- ini_set('session.'.$name, $value);
- }
-
- // Start with clean environment
- $this->cookie_vals = $_COOKIE;
- $_COOKIE = array();
-
- // Set subclass prefix to match our mock
- $this->ci_set_config('subclass_prefix', 'Mock_Libraries_');
-
- // Establish necessary support classes
- $ci = $this->ci_instance();
- $ldr = $this->ci_core_class('load');
- $ci->load = new $ldr();
- $ci->input = new Mock_Core_Input(NULL, NULL);
-
- // Make sure string helper is available
- $this->ci_vfs_clone('system/helpers/string_helper.php');
-
- // Attach session instance locally
- $config = array(
- 'sess_encrypt_cookie' => FALSE,
- 'sess_use_database' => FALSE,
- 'sess_table_name' => '',
- 'sess_expiration' => 7200,
- 'sess_expire_on_close' => FALSE,
- 'sess_match_ip' => FALSE,
- 'sess_match_useragent' => TRUE,
- 'sess_cookie_name' => 'ci_session',
- 'cookie_path' => '',
- 'cookie_domain' => '',
- 'cookie_secure' => FALSE,
- 'cookie_httponly' => FALSE,
- 'sess_time_to_update' => 300,
- 'time_reference' => 'local',
- 'cookie_prefix' => '',
- 'encryption_key' => 'foobar'
- );
- $this->session = new Mock_Libraries_Session($config);
- }
-
- /**
- * Tear down test framework
- */
- public function tear_down()
- {
-return;
- // Restore environment
- if (session_id()) session_destroy();
- $_SESSION = array();
- $_COOKIE = $this->cookie_vals;
-
- // Restore settings
- foreach ($this->settings as $name => $value) {
- ini_set('session.'.$name, $this->setting_vals[$name]);
- }
- }
-
- /**
- * Test set_userdata() function
- */
- public function test_set_userdata()
- {
-return;
- // Set userdata values for each driver
- $key1 = 'test1';
- $ckey2 = 'test2';
- $nkey2 = 'test3';
- $cmsg1 = 'Some test data';
- $cmsg2 = 42;
- $nmsg1 = 'Other test data';
- $nmsg2 = TRUE;
- $this->session->cookie->set_userdata($key1, $cmsg1);
- $this->session->set_userdata($ckey2, $cmsg2);
- $this->session->native->set_userdata($key1, $nmsg1);
- $this->session->set_userdata($nkey2, $nmsg2);
-
- // Verify independent messages
- $this->assertEquals($cmsg1, $this->session->cookie->userdata($key1));
- $this->assertEquals($nmsg1, $this->session->native->userdata($key1));
-
- // Verify pre-selected driver sets
- $this->assertEquals($cmsg2, $this->session->cookie->userdata($ckey2));
- $this->assertEquals($nmsg2, $this->session->native->userdata($nkey2));
-
- // Verify no crossover
- $this->assertNull($this->session->cookie->userdata($nkey2));
- $this->assertNull($this->session->native->userdata($ckey2));
- }
-
- /**
- * Test the has_userdata() function
- */
- public function test_has_userdata()
- {
-return;
- // Set a userdata value for each driver
- $key = 'hastest';
- $cmsg = 'My test data';
- $this->session->cookie->set_userdata($key, $cmsg);
- $nmsg = 'Your test data';
- $this->session->native->set_userdata($key, $nmsg);
-
- // Verify values exist
- $this->assertTrue($this->session->cookie->has_userdata($key));
- $this->assertTrue($this->session->native->has_userdata($key));
-
- // Verify non-existent values
- $nokey = 'hasnot';
- $this->assertFalse($this->session->cookie->has_userdata($nokey));
- $this->assertFalse($this->session->native->has_userdata($nokey));
- }
-
- /**
- * Test the all_userdata() function
- */
- public function test_all_userdata()
- {
-return;
- // Set a specific series of data for each driver
- $cdata = array(
- 'one' => 'first',
- 'two' => 'second',
- 'three' => 'third',
- 'foo' => 'bar',
- 'bar' => 'baz'
- );
- $ndata = array(
- 'one' => 'gold',
- 'two' => 'silver',
- 'three' => 'bronze',
- 'foo' => 'baz',
- 'bar' => 'foo'
- );
- $this->session->cookie->set_userdata($cdata);
- $this->session->native->set_userdata($ndata);
-
- // Make sure all values are present
- $call = $this->session->cookie->userdata();
- foreach ($cdata as $key => $value) {
- $this->assertEquals($value, $call[$key]);
- }
- $nall = $this->session->native->userdata();
- foreach ($ndata as $key => $value) {
- $this->assertEquals($value, $nall[$key]);
- }
- }
-
- /**
- * Test the unset_userdata() function
- */
- public function test_unset_userdata()
- {
-return;
- // Set a userdata message for each driver
- $key = 'untest';
- $cmsg = 'Other test data';
- $this->session->cookie->set_userdata($key, $cmsg);
- $nmsg = 'Sundry test data';
- $this->session->native->set_userdata($key, $nmsg);
-
- // Verify independent messages
- $this->assertEquals($this->session->cookie->userdata($key), $cmsg);
- $this->assertEquals($this->session->native->userdata($key), $nmsg);
-
- // Unset them and verify absence
- $this->session->cookie->unset_userdata($key);
- $this->session->native->unset_userdata($key);
- $this->assertNull($this->session->cookie->userdata($key));
- $this->assertNull($this->session->native->userdata($key));
- }
-
- /**
- * Test the flashdata() functions
- */
- public function test_flashdata()
- {
-return;
- // Set flashdata message for each driver
- $key = 'fltest';
- $cmsg = 'Some flash data';
- $this->session->cookie->set_flashdata($key, $cmsg);
- $nmsg = 'Other flash data';
- $this->session->native->set_flashdata($key, $nmsg);
-
- // Simulate page reload
- $this->session->cookie->reload();
- $this->session->native->reload();
-
- // Verify independent messages
- $this->assertEquals($cmsg, $this->session->cookie->flashdata($key));
- $this->assertEquals($nmsg, $this->session->native->flashdata($key));
-
- // Simulate next page reload
- $this->session->cookie->reload();
- $this->session->native->reload();
-
- // Verify absence of messages
- $this->assertNull($this->session->cookie->flashdata($key));
- $this->assertNull($this->session->native->flashdata($key));
- }
-
- /**
- * Test the keep_flashdata() function
- */
- public function test_keep_flashdata()
- {
-return;
- // Set flashdata message for each driver
- $key = 'kfltest';
- $cmsg = 'My flash data';
- $this->session->cookie->set_flashdata($key, $cmsg);
- $nmsg = 'Your flash data';
- $this->session->native->set_flashdata($key, $nmsg);
-
- // Simulate page reload and verify independent messages
- $this->session->cookie->reload();
- $this->session->native->reload();
- $this->assertEquals($cmsg, $this->session->cookie->flashdata($key));
- $this->assertEquals($nmsg, $this->session->native->flashdata($key));
-
- // Keep messages
- $this->session->cookie->keep_flashdata($key);
- $this->session->native->keep_flashdata($key);
-
- // Simulate next page reload and verify message persistence
- $this->session->cookie->reload();
- $this->session->native->reload();
- $this->assertEquals($cmsg, $this->session->cookie->flashdata($key));
- $this->assertEquals($nmsg, $this->session->native->flashdata($key));
-
- // Simulate next page reload and verify absence of messages
- $this->session->cookie->reload();
- $this->session->native->reload();
- $this->assertNull($this->session->cookie->flashdata($key));
- $this->assertNull($this->session->native->flashdata($key));
- }
-
- public function test_keep_flashdata_with_array()
- {
-return;
- // Set flashdata array for each driver
- $cdata = array(
- 'one' => 'first',
- 'two' => 'second',
- 'three' => 'third',
- 'foo' => 'bar',
- 'bar' => 'baz'
- );
- $ndata = array(
- 'one' => 'gold',
- 'two' => 'silver',
- 'three' => 'bronze',
- 'foo' => 'baz',
- 'bar' => 'foo'
- );
- $kdata = array(
- 'one',
- 'two',
- 'three',
- 'foo',
- 'bar'
- );
- $this->session->cookie->set_flashdata($cdata);
- $this->session->native->set_flashdata($ndata);
-
- // Simulate page reload and verify independent messages
- $this->session->cookie->reload();
- $this->session->native->reload();
- $this->assertEquals($cdata, $this->session->cookie->flashdata());
- $this->assertEquals($ndata, $this->session->native->flashdata());
-
- // Keep messages
- $this->session->cookie->keep_flashdata($kdata);
- $this->session->native->keep_flashdata($kdata);
-
- // Simulate next page reload and verify message persistence
- $this->session->cookie->reload();
- $this->session->native->reload();
- $this->assertEquals($cdata, $this->session->cookie->flashdata());
- $this->assertEquals($ndata, $this->session->native->flashdata());
-
- // Simulate next page reload and verify absence of messages
- $this->session->cookie->reload();
- $this->session->native->reload();
- $this->assertEmpty($this->session->cookie->flashdata());
- $this->assertEmpty($this->session->native->flashdata());
- }
-
- /**
- * Test the all_flashdata() function
- */
- public function test_all_flashdata()
- {
-return;
- // Set a specific series of data for each driver
- $cdata = array(
- 'one' => 'first',
- 'two' => 'second',
- 'three' => 'third',
- 'foo' => 'bar',
- 'bar' => 'baz'
- );
- $ndata = array(
- 'one' => 'gold',
- 'two' => 'silver',
- 'three' => 'bronze',
- 'foo' => 'baz',
- 'bar' => 'foo'
- );
- $this->session->cookie->set_flashdata($cdata);
- $this->session->native->set_flashdata($ndata);
-
- // Simulate page reload and make sure all values are present
- $this->session->cookie->reload();
- $this->session->native->reload();
- $this->assertEquals($cdata, $this->session->cookie->flashdata());
- $this->assertEquals($ndata, $this->session->native->flashdata());
- }
-
- /**
- * Test the tempdata() functions
- */
- public function test_set_tempdata()
- {
-return;
- // Set tempdata message for each driver - 1 second timeout
- $key = 'tmptest';
- $cmsg = 'Some temp data';
- $this->session->cookie->set_tempdata($key, $cmsg, 1);
- $nmsg = 'Other temp data';
- $this->session->native->set_tempdata($key, $nmsg, 1);
-
- // Simulate page reload and verify independent messages
- $this->session->cookie->reload();
- $this->session->native->reload();
- $this->assertEquals($cmsg, $this->session->cookie->tempdata($key));
- $this->assertEquals($nmsg, $this->session->native->tempdata($key));
-
- // Wait 2 seconds, simulate page reload and verify message absence
- sleep(2);
- $this->session->cookie->reload();
- $this->session->native->reload();
- $this->assertNull($this->session->cookie->tempdata($key));
- $this->assertNull($this->session->native->tempdata($key));
- }
-
- /**
- * Test the unset_tempdata() function
- */
- public function test_unset_tempdata()
- {
-return;
- // Set tempdata message for each driver - 1 second timeout
- $key = 'utmptest';
- $cmsg = 'My temp data';
- $this->session->cookie->set_tempdata($key, $cmsg, 1);
- $nmsg = 'Your temp data';
- $this->session->native->set_tempdata($key, $nmsg, 1);
-
- // Verify independent messages
- $this->assertEquals($cmsg, $this->session->cookie->tempdata($key));
- $this->assertEquals($nmsg, $this->session->native->tempdata($key));
-
- // Unset data and verify message absence
- $this->session->cookie->unset_tempdata($key);
- $this->session->native->unset_tempdata($key);
- $this->assertNull($this->session->cookie->tempdata($key));
- $this->assertNull($this->session->native->tempdata($key));
- }
-
- /**
- * Test the sess_regenerate() function
- */
- public function test_sess_regenerate()
- {
-return;
- // Get current session id, regenerate, and compare
- // Cookie driver
- $oldid = $this->session->cookie->userdata('session_id');
- $this->session->cookie->sess_regenerate();
- $newid = $this->session->cookie->userdata('session_id');
- $this->assertNotEquals($oldid, $newid);
-
- // Native driver - bug #55267 (https://bugs.php.net/bug.php?id=55267) prevents testing this
- // $oldid = session_id();
- // $this->session->native->sess_regenerate();
- // $oldid = session_id();
- // $this->assertNotEquals($oldid, $newid);
- }
-
- /**
- * Test the sess_destroy() function
- */
- public function test_sess_destroy()
- {
-return;
- // Set a userdata message, destroy session, and verify absence
- $key = 'dsttest';
- $msg = 'More test data';
-
- // Cookie driver
- $this->session->cookie->set_userdata($key, $msg);
- $this->assertEquals($msg, $this->session->cookie->userdata($key));
- $this->session->cookie->sess_destroy();
- $this->assertNull($this->session->cookie->userdata($key));
-
- // Native driver
- $this->session->native->set_userdata($key, $msg);
- $this->assertEquals($msg, $this->session->native->userdata($key));
- $this->session->native->sess_destroy();
- $this->assertNull($this->session->native->userdata($key));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php
deleted file mode 100644
index 8e7452474..000000000
--- a/tests/codeigniter/libraries/Table_test.php
+++ /dev/null
@@ -1,300 +0,0 @@
-<?php
-
-class Table_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->table = new Mock_Libraries_Table();
- $this->ci_instance_var('table', $this->table);
- }
-
- // Setter Methods
- // --------------------------------------------------------------------
-
- public function test_set_template()
- {
- $this->assertFalse($this->table->set_template('not an array'));
-
- $template = array('a' => 'b');
-
- $this->table->set_template($template);
- $this->assertEquals($template, $this->table->template);
- }
-
- public function test_set_empty()
- {
- $this->table->set_empty('nada');
- $this->assertEquals('nada', $this->table->empty_cells);
- }
-
- public function test_set_caption()
- {
- $this->table->set_caption('awesome cap');
- $this->assertEquals('awesome cap', $this->table->caption);
- }
-
- /*
- * @depends test_prep_args
- */
- public function test_set_heading()
- {
- // uses _prep_args internally, so we'll just do a quick
- // check to verify that func_get_args and prep_args are
- // being called.
-
- $this->table->set_heading('name', 'color', 'size');
-
- $this->assertEquals(
- array(
- array('data' => 'name'),
- array('data' => 'color'),
- array('data' => 'size')
- ),
- $this->table->heading
- );
- }
-
- /*
- * @depends test_prep_args
- */
- public function test_add_row()
- {
- // uses _prep_args internally, so we'll just do a quick
- // check to verify that func_get_args and prep_args are
- // being called.
-
- $this->table->add_row('my', 'pony', 'sings');
- $this->table->add_row('your', 'pony', 'stinks');
- $this->table->add_row('my pony', '>', 'your pony');
-
- $this->assertEquals(count($this->table->rows), 3);
-
- $this->assertEquals(
- array(
- array('data' => 'your'),
- array('data' => 'pony'),
- array('data' => 'stinks')
- ),
- $this->table->rows[1]
- );
- }
-
- // Uility Methods
- // --------------------------------------------------------------------
-
- public function test_prep_args()
- {
- $expected = array(
- array('data' => 'name'),
- array('data' => 'color'),
- array('data' => 'size')
- );
-
- $this->assertEquals(
- $expected,
- $this->table->prep_args(array('name', 'color', 'size'))
- );
-
- // with cell attributes
- // need to add that new argument row to our expected outcome
- $expected[] = array('data' => 'weight', 'class' => 'awesome');
-
- $this->assertEquals(
- $expected,
- $this->table->prep_args(array('name', 'color', 'size', array('data' => 'weight', 'class' => 'awesome')))
- );
- }
-
- public function test_default_template_keys()
- {
- $keys = array(
- 'table_open',
- 'thead_open', 'thead_close',
- 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end',
- 'tbody_open', 'tbody_close',
- 'row_start', 'row_end', 'cell_start', 'cell_end',
- 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end',
- 'table_close'
- );
-
- foreach ($keys as $key)
- {
- $this->assertArrayHasKey($key, $this->table->default_template());
- }
- }
-
- public function test_compile_template()
- {
- $this->assertFalse($this->table->set_template('invalid_junk'));
-
- // non default key
- $this->table->set_template(array('nonsense' => 'foo'));
- $this->table->compile_template();
-
- $this->assertArrayHasKey('nonsense', $this->table->template);
- $this->assertEquals('foo', $this->table->template['nonsense']);
-
- // override default
- $this->table->set_template(array('table_close' => '</table junk>'));
- $this->table->compile_template();
-
- $this->assertArrayHasKey('table_close', $this->table->template);
- $this->assertEquals('</table junk>', $this->table->template['table_close']);
- }
-
- public function test_make_columns()
- {
- // Test bogus parameters
- $this->assertFalse($this->table->make_columns('invalid_junk'));
- $this->assertFalse($this->table->make_columns(array()));
- $this->assertFalse($this->table->make_columns(array('one', 'two'), '2.5'));
-
- // Now on to the actual column creation
-
- $five_values = array(
- 'Laura', 'Red', '15',
- 'Katie', 'Blue'
- );
-
- // No column count - no changes to the array
- $this->assertEquals(
- $five_values,
- $this->table->make_columns($five_values)
- );
-
- // Column count of 3 leaves us with one &nbsp;
- $this->assertEquals(
- array(
- array('Laura', 'Red', '15'),
- array('Katie', 'Blue', '&nbsp;')
- ),
- $this->table->make_columns($five_values, 3)
- );
- }
-
- public function test_clear()
- {
- $this->table->set_heading('Name', 'Color', 'Size');
-
- // Make columns changes auto_heading
- $rows = $this->table->make_columns(array(
- 'Laura', 'Red', '15',
- 'Katie', 'Blue'
- ), 3);
-
- foreach ($rows as $row)
- {
- $this->table->add_row($row);
- }
-
- $this->assertFalse($this->table->auto_heading);
- $this->assertEquals(count($this->table->heading), 3);
- $this->assertEquals(count($this->table->rows), 2);
-
- $this->table->clear();
-
- $this->assertTrue($this->table->auto_heading);
- $this->assertEmpty($this->table->heading);
- $this->assertEmpty($this->table->rows);
- }
-
- public function test_set_from_array()
- {
- $data = array(
- array('name', 'color', 'number'),
- array('Laura', 'Red', '22'),
- array('Katie', 'Blue')
- );
-
- $this->table->auto_heading = FALSE;
- $this->table->set_from_array($data);
- $this->assertEmpty($this->table->heading);
-
- $this->table->clear();
-
- $this->table->set_from_array($data);
- $this->assertEquals(count($this->table->rows), 2);
-
- $expected = array(
- array('data' => 'name'),
- array('data' => 'color'),
- array('data' => 'number')
- );
-
- $this->assertEquals($expected, $this->table->heading);
-
- $expected = array(
- array('data' => 'Katie'),
- array('data' => 'Blue'),
- );
-
- $this->assertEquals($expected, $this->table->rows[1]);
- }
-
- public function test_set_from_object()
- {
- // This needs to be passed by reference to CI_DB_result::__construct()
- $dummy = new stdClass();
- $dummy->conn_id = NULL;
- $dummy->result_id = NULL;
-
- $db_result = new DB_result_dummy($dummy);
-
- $this->table->set_from_db_result($db_result);
-
- $expected = array(
- array('data' => 'name'),
- array('data' => 'email')
- );
-
- $this->assertEquals($expected, $this->table->heading);
-
- $expected = array(
- 'name' => array('data' => 'Foo Bar'),
- 'email' => array('data' => 'foo@bar.com'),
- );
-
- $this->assertEquals($expected, $this->table->rows[1]);
- }
-
- public function test_generate()
- {
- // Prepare the data
- $data = array(
- array('Name', 'Color', 'Size'),
- array('Fred', 'Blue', 'Small'),
- array('Mary', 'Red', 'Large'),
- array('John', 'Green', 'Medium')
- );
-
- $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);
-
- // 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);
- }
-
-}
-
-// We need this for the _set_from_db_result() test
-class DB_result_dummy extends CI_DB_result
-{
- public function list_fields()
- {
- return array('name', 'email');
- }
-
- public function result_array()
- {
- return array(
- array('name' => 'John Doe', 'email' => 'john@doe.com'),
- array('name' => 'Foo Bar', 'email' => 'foo@bar.com')
- );
- }
-} \ No newline at end of file
diff --git a/tests/codeigniter/libraries/Typography_test.php b/tests/codeigniter/libraries/Typography_test.php
deleted file mode 100644
index e6ee7b05c..000000000
--- a/tests/codeigniter/libraries/Typography_test.php
+++ /dev/null
@@ -1,182 +0,0 @@
-<?php
-
-class Typography_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->type = new CI_Typography();
- $this->ci_instance('type', $this->type);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Tests the format_characters() function.
- *
- * this can and should grow.
- */
- public function test_format_characters()
- {
- $strs = array(
- '"double quotes"' => '&#8220;double quotes&#8221;',
- '"testing" in "theory" that is' => '&#8220;testing&#8221; in &#8220;theory&#8221; that is',
- "Here's what I'm" => 'Here&#8217;s what I&#8217;m',
- '&' => '&amp;',
- '&amp;' => '&amp;',
- '&nbsp;' => '&nbsp;',
- '--' => '&#8212;',
- 'foo...' => 'foo&#8230;',
- 'foo..' => 'foo..',
- 'foo...bar.' => 'foo&#8230;bar.',
- 'test. new' => 'test.&nbsp; new',
- );
-
- foreach ($strs as $str => $expected)
- {
- $this->assertEquals($expected, $this->type->format_characters($str));
- }
- }
-
- // --------------------------------------------------------------------
-
- public function test_nl2br_except_pre()
- {
- $str = <<<EOH
-Hello, I'm a happy string with some new lines.
-
-I like to skip.
-
-Jump
-
-and sing.
-
-<pre>
-I am inside a pre tag. Please don't mess with me.
-
-k?
-</pre>
-
-That's my story and I'm sticking to it.
-
-The End.
-EOH;
-
- $expected = <<<EOH
-Hello, I'm a happy string with some new lines. <br />
-<br />
-I like to skip.<br />
-<br />
-Jump<br />
-<br />
-and sing.<br />
-<br />
-<pre>
-I am inside a pre tag. Please don't mess with me.
-
-k?
-</pre><br />
-<br />
-That's my story and I'm sticking to it.<br />
-<br />
-The End.
-EOH;
-
- $this->assertEquals($expected, $this->type->nl2br_except_pre($str));
- }
-
- // --------------------------------------------------------------------
-
- public function test_auto_typography()
- {
- $this->_blank_string();
- $this->_standardize_new_lines();
- $this->_reduce_linebreaks();
- $this->_remove_comments();
- $this->_protect_pre();
- $this->_no_opening_block();
- $this->_protect_braced_quotes();
- }
-
- // --------------------------------------------------------------------
-
- private function _blank_string()
- {
- // Test blank string
- $this->assertEquals('', $this->type->auto_typography(''));
- }
-
- // --------------------------------------------------------------------
-
- private function _standardize_new_lines()
- {
- $strs = array(
- "My string\rhas return characters" => "<p>My string<br />\nhas return characters</p>",
- 'This one does not!' => '<p>This one does not!</p>'
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, $this->type->auto_typography($str));
- }
- }
-
- // --------------------------------------------------------------------
-
- private function _reduce_linebreaks()
- {
- $str = "This has way too many linebreaks.\n\n\n\nSee?";
- $expect = "<p>This has way too many linebreaks.</p>\n\n<p>See?</p>";
-
- $this->assertEquals($expect, $this->type->auto_typography($str, TRUE));
- }
-
- // --------------------------------------------------------------------
-
- private function _remove_comments()
- {
- $str = '<!-- I can haz comments? --> But no!';
- $expect = '<p><!-- I can haz comments? -->&nbsp; But no!</p>';
-
- $this->assertEquals($expect, $this->type->auto_typography($str));
- }
-
- // --------------------------------------------------------------------
-
- private function _protect_pre()
- {
- $str = '<p>My Sentence</p><pre>var_dump($this);</pre>';
- $expect = '<p>My Sentence</p><pre>var_dump($this);</pre>';
-
- $this->assertEquals($expect, $this->type->auto_typography($str));
- }
-
- // --------------------------------------------------------------------
-
- private function _no_opening_block()
- {
- $str = 'My Sentence<pre>var_dump($this);</pre>';
- $expect = '<p>My Sentence</p><pre>var_dump($this);</pre>';
-
- $this->assertEquals($expect, $this->type->auto_typography($str));
- }
-
- // --------------------------------------------------------------------
-
- public function _protect_braced_quotes()
- {
- $this->type->protect_braced_quotes = TRUE;
-
- $str = 'Test {parse="foobar"}';
- $expect = '<p>Test {parse="foobar"}</p>';
-
- $this->assertEquals($expect, $this->type->auto_typography($str));
-
- $this->type->protect_braced_quotes = FALSE;
-
- $str = 'Test {parse="foobar"}';
- $expect = '<p>Test {parse=&#8220;foobar&#8221;}</p>';
-
- $this->assertEquals($expect, $this->type->auto_typography($str));
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/libraries/Upload_test.php b/tests/codeigniter/libraries/Upload_test.php
deleted file mode 100644
index 8bac597b3..000000000
--- a/tests/codeigniter/libraries/Upload_test.php
+++ /dev/null
@@ -1,299 +0,0 @@
-<?php
-
-class Upload_test extends CI_TestCase {
-
- public function set_up()
- {
- $ci = $this->ci_instance();
- $ci->upload = new CI_Upload();
- $ci->security = new Mock_Core_Security();
- $ci->lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load', 'line'))->getMock();
- $ci->lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
- $this->upload = $ci->upload;
- }
-
- // --------------------------------------------------------------------
-
- public function test___construct_initialize()
- {
- // via __construct
-
- $upload = new CI_Upload(
- array(
- 'file_name' => 'foo',
- 'file_ext_tolower' => TRUE
- )
- );
-
- $reflection = new ReflectionClass($upload);
- $reflection = $reflection->getProperty('_file_name_override');
- $reflection->setAccessible(TRUE);
- $this->assertEquals('foo', $reflection->getValue($upload));
-
- $this->assertTrue($upload->file_ext_tolower);
-
- // reset (defaults to true)
-
- $upload->initialize(array('file_name' => 'bar'));
- $this->assertEquals('bar', $upload->file_name);
- $this->assertFalse($upload->file_ext_tolower);
-
- // no reset
-
- $upload->initialize(array('file_ext_tolower' => TRUE), FALSE);
- $this->assertTrue($upload->file_ext_tolower);
- $this->assertEquals('bar', $upload->file_name);
- }
-
- // --------------------------------------------------------------------
-
- public function test_do_upload()
- {
- $this->markTestSkipped("We can't test this at the moment because of the call to is_uploaded_file() in do_upload() which isn't supported by vfsStream.");
- }
-
- // --------------------------------------------------------------------
-
- function test_data()
- {
- $data = array(
- 'file_name' => 'hello.txt',
- 'file_type' => 'text/plain',
- 'file_path' => '/tmp/',
- 'full_path' => '/tmp/hello.txt',
- 'raw_name' => 'hello',
- 'orig_name' => 'hello.txt',
- 'client_name' => '',
- 'file_ext' => '.txt',
- 'file_size' => 100,
- 'is_image' => FALSE,
- 'image_width' => '',
- 'image_height' => '',
- 'image_type' => '',
- 'image_size_str' => ''
- );
-
- $this->upload->set_upload_path('/tmp/');
-
- foreach ($data as $k => $v)
- {
- $this->upload->{$k} = $v;
- }
-
- $this->assertEquals('hello.txt', $this->upload->data('file_name'));
- $this->assertEquals($data, $this->upload->data());
- }
-
- function test_set_upload_path()
- {
- $this->upload->set_upload_path('/tmp/');
- $this->assertEquals('/tmp/', $this->upload->upload_path);
-
- $this->upload->set_upload_path('/tmp');
- $this->assertEquals('/tmp/', $this->upload->upload_path);
- }
-
- function test_set_filename()
- {
- $dir = 'uploads';
- $isnew = 'helloworld.txt';
- $exists = 'hello-world.txt';
- $this->ci_vfs_create($exists, 'Hello world.', $this->ci_app_root, $dir);
- $path = $this->ci_vfs_path($dir.'/', APPPATH);
- $this->upload->file_ext = '.txt';
-
- $this->assertEquals($isnew, $this->upload->set_filename($path, $isnew));
- $this->assertEquals('hello-world1.txt', $this->upload->set_filename($path, $exists));
- }
-
- function test_set_max_filesize()
- {
- $this->upload->set_max_filesize(100);
- $this->assertEquals(100, $this->upload->max_size);
- }
-
- function test_set_max_filename()
- {
- $this->upload->set_max_filename(100);
- $this->assertEquals(100, $this->upload->max_filename);
- }
-
- function test_set_max_width()
- {
- $this->upload->set_max_width(100);
- $this->assertEquals(100, $this->upload->max_width);
- }
-
- function test_set_max_height()
- {
- $this->upload->set_max_height(100);
- $this->assertEquals(100, $this->upload->max_height);
- }
-
- function test_set_allowed_types()
- {
- $this->upload->set_allowed_types('*');
- $this->assertEquals('*', $this->upload->allowed_types);
-
- $this->upload->set_allowed_types('foo|bar');
- $this->assertEquals(array('foo', 'bar'), $this->upload->allowed_types);
- }
-
- function test_set_image_properties()
- {
- $this->upload->file_type = 'image/gif';
- $this->upload->file_temp = realpath(PROJECT_BASE.'tests/mocks/uploads/ci_logo.gif');
-
- $props = array(
- 'image_width' => 170,
- 'image_height' => 73,
- 'image_type' => 'gif',
- 'image_size_str' => 'width="170" height="73"'
- );
-
- $this->upload->set_image_properties($this->upload->file_temp);
-
- $this->assertEquals($props['image_width'], $this->upload->image_width);
- $this->assertEquals($props['image_height'], $this->upload->image_height);
- $this->assertEquals($props['image_type'], $this->upload->image_type);
- $this->assertEquals($props['image_size_str'], $this->upload->image_size_str);
- }
-
- function test_set_xss_clean()
- {
- $this->upload->set_xss_clean(TRUE);
- $this->assertTrue($this->upload->xss_clean);
-
- $this->upload->set_xss_clean(FALSE);
- $this->assertFalse($this->upload->xss_clean);
- }
-
- function test_is_image()
- {
- $this->upload->file_type = 'image/x-png';
- $this->assertTrue($this->upload->is_image());
-
- $this->upload->file_type = 'text/plain';
- $this->assertFalse($this->upload->is_image());
- }
-
- function test_is_allowed_filetype()
- {
- $this->upload->allowed_types = array('html', 'gif');
-
- $this->upload->file_ext = '.txt';
- $this->upload->file_type = 'text/plain';
- $this->assertFalse($this->upload->is_allowed_filetype(FALSE));
- $this->assertFalse($this->upload->is_allowed_filetype(TRUE));
-
- $this->upload->file_ext = '.html';
- $this->upload->file_type = 'text/html';
- $this->assertTrue($this->upload->is_allowed_filetype(FALSE));
- $this->assertTrue($this->upload->is_allowed_filetype(TRUE));
-
- $this->upload->file_temp = realpath(PROJECT_BASE.'tests/mocks/uploads/ci_logo.gif');
- $this->upload->file_ext = '.gif';
- $this->upload->file_type = 'image/gif';
- $this->assertTrue($this->upload->is_allowed_filetype());
- }
-
- function test_is_allowed_filesize()
- {
- $this->upload->max_size = 100;
- $this->upload->file_size = 99;
-
- $this->assertTrue($this->upload->is_allowed_filesize());
-
- $this->upload->file_size = 101;
- $this->assertFalse($this->upload->is_allowed_filesize());
- }
-
- function test_is_allowed_dimensions()
- {
- $this->upload->file_type = 'text/plain';
- $this->assertTrue($this->upload->is_allowed_dimensions());
-
- $this->upload->file_type = 'image/gif';
- $this->upload->file_temp = realpath(PROJECT_BASE.'tests/mocks/uploads/ci_logo.gif');
-
- $this->upload->max_width = 10;
- $this->assertFalse($this->upload->is_allowed_dimensions());
-
- $this->upload->max_width = 170;
- $this->upload->max_height = 10;
- $this->assertFalse($this->upload->is_allowed_dimensions());
-
- $this->upload->max_height = 73;
- $this->assertTrue($this->upload->is_allowed_dimensions());
- }
-
- function test_validate_upload_path()
- {
- $this->upload->upload_path = '';
- $this->assertFalse($this->upload->validate_upload_path());
-
- $dir = 'uploads';
- $this->ci_vfs_mkdir($dir);
- $this->upload->upload_path = $this->ci_vfs_path($dir);
- $this->assertTrue($this->upload->validate_upload_path());
- }
-
- function test_get_extension()
- {
- $this->assertEquals('.txt', $this->upload->get_extension('hello.txt'));
- $this->assertEquals('.htaccess', $this->upload->get_extension('.htaccess'));
- $this->assertEquals('', $this->upload->get_extension('hello'));
- }
-
- function test_limit_filename_length()
- {
- $this->assertEquals('hello.txt', $this->upload->limit_filename_length('hello.txt', 10));
- $this->assertEquals('hello.txt', $this->upload->limit_filename_length('hello-world.txt', 9));
- }
-
- function test_do_xss_clean()
- {
- $dir = 'uploads';
- $file1 = 'file1.txt';
- $file2 = 'file2.txt';
- $file3 = 'file3.txt';
- $this->ci_vfs_create($file1, 'The billy goat was waiting for them.', $this->ci_vfs_root, $dir);
- $this->ci_vfs_create($file2, '', $this->ci_vfs_root, $dir);
- $this->ci_vfs_create($file3, '<script type="text/javascript">alert("Boo! said the billy goat")</script>', $this->ci_vfs_root, $dir);
-
- $this->upload->file_temp = $this->ci_vfs_path($file1, $dir);
- $this->assertTrue($this->upload->do_xss_clean());
-
- $this->upload->file_temp = $this->ci_vfs_path($file2, $dir);
- $this->assertFalse($this->upload->do_xss_clean());
-
- $this->upload->file_temp = $this->ci_vfs_path($file3, $dir);
- $this->assertFalse($this->upload->do_xss_clean());
-
- $this->upload->file_temp = realpath(PROJECT_BASE.'tests/mocks/uploads/ci_logo.gif');
- $this->assertTrue($this->upload->do_xss_clean());
- }
-
- function test_set_error()
- {
- $errors = array(
- 'An error!'
- );
-
- $another = 'Another error!';
-
- $this->upload->set_error($errors);
- $this->assertEquals($errors, $this->upload->error_msg);
-
- $errors[] = $another;
- $this->upload->set_error($another);
- $this->assertEquals($errors, $this->upload->error_msg);
- }
-
- function test_display_errors()
- {
- $this->upload->error_msg[] = 'Error test';
- $this->assertEquals('<p>Error test</p>', $this->upload->display_errors());
- }
-
-}
diff --git a/tests/codeigniter/libraries/Useragent_test.php b/tests/codeigniter/libraries/Useragent_test.php
deleted file mode 100644
index c02f2bd9d..000000000
--- a/tests/codeigniter/libraries/Useragent_test.php
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php
-
-class UserAgent_test extends CI_TestCase {
-
- protected $_user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27';
- protected $_mobile_ua = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7';
-
- public function set_up()
- {
- // set a baseline user agent
- $_SERVER['HTTP_USER_AGENT'] = $this->_user_agent;
-
- $this->ci_vfs_clone('application/config/user_agents.php');
- $this->agent = new CI_User_agent();
- $this->ci_instance_var('agent', $this->agent);
- }
-
- // --------------------------------------------------------------------
-
- public function test_accept_lang()
- {
- $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en';
- $this->assertTrue($this->agent->accept_lang());
- unset($_SERVER['HTTP_ACCEPT_LANGUAGE']);
- $this->assertTrue($this->agent->accept_lang('en'));
- $this->assertFalse($this->agent->accept_lang('fr'));
- }
-
- // --------------------------------------------------------------------
-
- public function test_mobile()
- {
- // Mobile Not Set
- $_SERVER['HTTP_USER_AGENT'] = $this->_mobile_ua;
- $this->assertEquals('', $this->agent->mobile());
- unset($_SERVER['HTTP_USER_AGENT']);
- }
-
- // --------------------------------------------------------------------
-
- public function test_is_functions()
- {
- $this->assertTrue($this->agent->is_browser());
- $this->assertTrue($this->agent->is_browser('Safari'));
- $this->assertFalse($this->agent->is_browser('Firefox'));
- $this->assertFalse($this->agent->is_robot());
- $this->assertFalse($this->agent->is_mobile());
- }
-
- // --------------------------------------------------------------------
-
- public function test_referrer()
- {
- $_SERVER['HTTP_REFERER'] = 'http://codeigniter.com/user_guide/';
- $this->assertTrue($this->agent->is_referral());
- $this->assertEquals('http://codeigniter.com/user_guide/', $this->agent->referrer());
-
- $this->agent->referer = NULL;
- unset($_SERVER['HTTP_REFERER']);
- $this->assertFalse($this->agent->is_referral());
- $this->assertEquals('', $this->agent->referrer());
- }
-
- // --------------------------------------------------------------------
-
- public function test_agent_string()
- {
- $this->assertEquals($this->_user_agent, $this->agent->agent_string());
- }
-
- // --------------------------------------------------------------------
-
- public function test_browser_info()
- {
- $this->assertEquals('Mac OS X', $this->agent->platform());
- $this->assertEquals('Safari', $this->agent->browser());
- $this->assertEquals('533.20.27', $this->agent->version());
- $this->assertEquals('', $this->agent->robot());
- }
-
- // --------------------------------------------------------------------
-
- public function test_charsets()
- {
- $_SERVER['HTTP_ACCEPT_CHARSET'] = 'utf8';
- $this->agent->charsets = array();
- $this->agent->charsets();
- $this->assertTrue($this->agent->accept_charset('utf8'));
- $this->assertFalse($this->agent->accept_charset('foo'));
- $this->assertEquals('utf8', $this->agent->charsets[0]);
-
- $_SERVER['HTTP_ACCEPT_CHARSET'] = '';
- $this->agent->charsets = array();
- $this->assertFalse($this->agent->accept_charset());
- $this->assertEquals('Undefined', $this->agent->charsets[0]);
-
- $_SERVER['HTTP_ACCEPT_CHARSET'] = 'iso-8859-5, unicode-1-1; q=0.8';
- $this->agent->charsets = array();
- $this->assertTrue($this->agent->accept_charset('iso-8859-5'));
- $this->assertTrue($this->agent->accept_charset('unicode-1-1'));
- $this->assertFalse($this->agent->accept_charset('foo'));
- $this->assertEquals('iso-8859-5', $this->agent->charsets[0]);
- $this->assertEquals('unicode-1-1', $this->agent->charsets[1]);
-
- unset($_SERVER['HTTP_ACCEPT_CHARSET']);
- }
-
- public function test_parse()
- {
- $new_agent = 'Mozilla/5.0 (Android; Mobile; rv:13.0) Gecko/13.0 Firefox/13.0';
- $this->agent->parse($new_agent);
-
- $this->assertEquals('Android', $this->agent->platform());
- $this->assertEquals('Firefox', $this->agent->browser());
- $this->assertEquals('13.0', $this->agent->version());
- $this->assertEquals('', $this->agent->robot());
- $this->assertEquals('Android', $this->agent->mobile());
- $this->assertEquals($new_agent, $this->agent->agent_string());
- $this->assertTrue($this->agent->is_browser());
- $this->assertFalse($this->agent->is_robot());
- $this->assertTrue($this->agent->is_mobile());
- $this->assertTrue($this->agent->is_mobile('android'));
- }
-
-} \ No newline at end of file
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 @@
-<?php
-
-// This autoloader provide convenient way to working with mock object
-// make the test looks natural. This autoloader support cascade file loading as well
-// within mocks directory.
-//
-// Prototype :
-//
-// $mock_table = new Mock_Libraries_Table(); // Will load ./mocks/libraries/table.php
-// $mock_database_driver = new Mock_Database_Driver(); // Will load ./mocks/database/driver.php
-// and so on...
-function autoload($class)
-{
- $dir = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR;
-
- $ci_core = array(
- 'Benchmark',
- 'Config',
- 'Controller',
- 'Exceptions',
- 'Hooks',
- 'Input',
- 'Lang',
- 'Loader',
- 'Log',
- 'Model',
- 'Output',
- 'Router',
- 'Security',
- 'URI',
- 'Utf8'
- );
-
- $ci_libraries = array(
- 'Calendar',
- 'Cart',
- 'Driver_Library',
- 'Email',
- 'Encrypt',
- 'Encryption',
- 'Form_validation',
- 'Ftp',
- 'Image_lib',
- 'Javascript',
- 'Migration',
- 'Pagination',
- 'Parser',
- 'Profiler',
- 'Table',
- 'Trackback',
- 'Typography',
- 'Unit_test',
- 'Upload',
- 'User_agent',
- 'Xmlrpc',
- 'Zip'
- );
-
- $ci_drivers = array('Session', 'Cache');
-
- if (strpos($class, 'Mock_') === 0)
- {
- $class = strtolower(str_replace(array('Mock_', '_'), array('', DIRECTORY_SEPARATOR), $class));
- }
- elseif (strpos($class, 'CI_') === 0)
- {
- $subclass = substr($class, 3);
-
- if (in_array($subclass, $ci_core))
- {
- $dir = SYSTEM_PATH.'core'.DIRECTORY_SEPARATOR;
- $class = $subclass;
- }
- elseif (in_array($subclass, $ci_libraries))
- {
- $dir = SYSTEM_PATH.'libraries'.DIRECTORY_SEPARATOR;
- $class = ($subclass === 'Driver_Library') ? 'Driver' : $subclass;
- }
- elseif (in_array($subclass, $ci_drivers))
- {
- $dir = SYSTEM_PATH.'libraries'.DIRECTORY_SEPARATOR.$subclass.DIRECTORY_SEPARATOR;
- $class = $subclass;
- }
- elseif (in_array(($parent = strtok($subclass, '_')), $ci_drivers)) {
- $dir = SYSTEM_PATH.'libraries'.DIRECTORY_SEPARATOR.$parent.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR;
- $class = $subclass;
- }
- elseif (preg_match('/^CI_DB_(.+)_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) === 4)
- {
- $driver_path = SYSTEM_PATH.'database'.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR;
- $dir = $driver_path.$m[1].DIRECTORY_SEPARATOR.'subdrivers'.DIRECTORY_SEPARATOR;
- $file = $dir.$m[1].'_'.$m[2].'_'.$m[3].'.php';
- }
- elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) === 3)
- {
- $driver_path = SYSTEM_PATH.'database'.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR;
- $dir = $driver_path.$m[1].DIRECTORY_SEPARATOR;
- $file = $dir.$m[1].'_'.$m[2].'.php';
- }
- elseif (strpos($class, 'CI_DB') === 0)
- {
- $dir = SYSTEM_PATH.'database'.DIRECTORY_SEPARATOR;
- $file = $dir.str_replace(array('CI_DB','active_record'), array('DB', 'active_rec'), $subclass).'.php';
- }
- else
- {
- $class = strtolower($class);
- }
- }
-
- $file = isset($file) ? $file : $dir.$class.'.php';
-
- if ( ! file_exists($file))
- {
- return FALSE;
- }
-
- include_once($file);
-}
diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php
deleted file mode 100644
index a2c37b92e..000000000
--- a/tests/mocks/ci_testcase.php
+++ /dev/null
@@ -1,386 +0,0 @@
-<?php
-
-class CI_TestCase extends PHPUnit_Framework_TestCase {
-
- public $ci_vfs_root;
- public $ci_app_root;
- public $ci_base_root;
- protected $ci_instance;
- protected static $ci_test_instance;
-
- private $global_map = array(
- 'benchmark' => 'bm',
- 'config' => 'cfg',
- 'hooks' => 'ext',
- 'utf8' => 'uni',
- 'router' => 'rtr',
- 'output' => 'out',
- 'security' => 'sec',
- 'input' => 'in',
- 'lang' => 'lang',
- 'loader' => 'load',
- 'model' => 'model'
- );
-
- // --------------------------------------------------------------------
-
- public function __construct()
- {
- parent::__construct();
- $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);
- }
- else
- {
- 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 @@
-<?php
-
-class CI_TestConfig extends CI_Config {
-
- public $config = array();
- public $_config_paths = array(APPPATH);
- public $loaded = array();
-
- public function item($key, $index = '')
- {
- return isset($this->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 @@
-<?php
-
-// Set up the global CI functions in their most minimal core representation
-
-if ( ! function_exists('get_instance'))
-{
- function &get_instance()
- {
- $test = CI_TestCase::instance();
- $test = $test->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 @@
-<?php
-
-class Mock_Core_Input extends CI_Input {
-
- /**
- * Since we use GLOBAL to fetch Security and Utf8 classes,
- * we need to use inversion of control to mock up
- * the same process within CI_Input class constructor.
- *
- * @covers CI_Input::__construct()
- */
- public function __construct($security, $utf8)
- {
- $this->_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 @@
-<?php
-
-class Mock_Core_Security extends CI_Security {
-
- public function csrf_set_cookie()
- {
- // We cannot set cookie in CLI mode, so for csrf test, who rely on $_COOKIE,
- // we superseded set_cookie with directly set the cookie variable,
- // @see : ./tests/codeigniter/core/Security_test.php, line 8
- return $this;
- }
-
- // Override inaccessible protected properties
- public function __get($property)
- {
- return isset($this->{'_'.$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 @@
-<?php
-
-class Mock_Core_URI extends CI_URI {
-
- public function __construct()
- {
- $test = CI_TestCase::instance();
- $cls =& $test->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 @@
-<?php
-
-class Mock_Core_Utf8 extends CI_Utf8 {
-
- /**
- * We need to define UTF8_ENABLED the same way that
- * CI_Utf8 constructor does.
- */
- public function __construct()
- {
- if (defined('UTF8_ENABLED'))
- {
- return;
- }
-
- parent::__construct();
- }
-
-} \ No newline at end of file
diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite
deleted file mode 100755
index 574d3ae53..000000000
--- a/tests/mocks/database/ci_test.sqlite
+++ /dev/null
Binary files differ
diff --git a/tests/mocks/database/config/mysql.php b/tests/mocks/database/config/mysql.php
deleted file mode 100644
index a590b9f53..000000000
--- a/tests/mocks/database/config/mysql.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-return array(
-
- // Typical Database configuration
- 'mysql' => 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 @@
-<?php
-
-return array(
-
- // Typical Database configuration
- 'mysqli' => 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 @@
-<?php
-
-return array(
-
- // Typical Database configuration
- 'pdo/mysql' => 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 @@
-<?php
-
-return array(
-
- // Typical Database configuration
- 'pdo/pgsql' => 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 @@
-<?php
-
-return array(
-
- // Typical Database configuration
- 'pdo/sqlite' => 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 @@
-<?php
-
-return array(
-
- // Typical Database configuration
- 'pgsql' => 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 @@
-<?php
-
-return array(
-
- // Typical Database configuration
- 'sqlite' => 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 @@
-<?php
-
-class Mock_Database_DB {
-
- /**
- * @var array DB configuration
- */
- private $config = array();
-
- /**
- * @var string DB driver name
- */
- private static $dbdriver = '';
-
- /**
- * @var string DB sub-driver name
- */
- private static $subdriver = '';
-
- /**
- * Prepare database configuration skeleton
- *
- * @param array DB configuration to set
- * @return void
- */
- public function __construct($config = array())
- {
- $this->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 @@
-<?php
-
-class Mock_Database_DB_Driver extends CI_DB_driver {
-
- /**
- * @var object The actual Driver
- */
- protected $ci_db_driver;
-
- /**
- * Instantiate the database driver
- *
- * @param string DB Driver class name
- * @param array DB configuration to set
- * @return void
- */
- public function __construct($driver_class, $config = array())
- {
- if (is_string($driver_class))
- {
- $this->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 @@
-<?php
-
-class Mock_Database_Drivers_Mysql extends Mock_Database_DB_Driver {
-
- /**
- * Instantiate the database driver
- *
- * @param array DB configuration to set
- * @return void
- */
- public function __construct($config = array())
- {
- parent::__construct('CI_DB_mysql_driver', $config);
- }
-
-} \ No newline at end of file
diff --git a/tests/mocks/database/drivers/mysqli.php b/tests/mocks/database/drivers/mysqli.php
deleted file mode 100644
index f747aad46..000000000
--- a/tests/mocks/database/drivers/mysqli.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-class Mock_Database_Drivers_Mysqli extends Mock_Database_DB_Driver {
-
- /**
- * Instantiate the database driver
- *
- * @param array DB configuration to set
- * @return void
- */
- public function __construct($config = array())
- {
- parent::__construct('CI_DB_mysqli_driver', $config);
- }
-
-} \ No newline at end of file
diff --git a/tests/mocks/database/drivers/pdo.php b/tests/mocks/database/drivers/pdo.php
deleted file mode 100644
index af1958aea..000000000
--- a/tests/mocks/database/drivers/pdo.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-class Mock_Database_Drivers_PDO extends Mock_Database_DB_Driver {
-
- /**
- * Instantiate the database driver
- *
- * @param array DB configuration to set
- * @return void
- */
- public function __construct($config = array())
- {
- parent::__construct('CI_DB_pdo_driver', $config);
- }
-} \ No newline at end of file
diff --git a/tests/mocks/database/drivers/postgre.php b/tests/mocks/database/drivers/postgre.php
deleted file mode 100644
index 8c91e54a9..000000000
--- a/tests/mocks/database/drivers/postgre.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-class Mock_Database_Drivers_Postgre extends Mock_Database_DB_Driver {
-
- /**
- * Instantiate the database driver
- *
- * @param array DB configuration to set
- * @return void
- */
- public function __construct($config = array())
- {
- parent::__construct('CI_DB_postgre_driver', $config);
- }
-
-} \ No newline at end of file
diff --git a/tests/mocks/database/drivers/sqlite.php b/tests/mocks/database/drivers/sqlite.php
deleted file mode 100644
index b2aec28e6..000000000
--- a/tests/mocks/database/drivers/sqlite.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-class Mock_Database_Drivers_Sqlite extends Mock_Database_DB_Driver {
-
- /**
- * Instantiate the database driver
- *
- * @param array DB configuration to set
- * @return void
- */
- public function __construct($config = array())
- {
- parent::__construct('CI_DB_sqlite3_driver', $config);
- }
-
-} \ No newline at end of file
diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php
deleted file mode 100644
index 888236ff3..000000000
--- a/tests/mocks/database/schema/skeleton.php
+++ /dev/null
@@ -1,155 +0,0 @@
-<?php
-
-class Mock_Database_Schema_Skeleton {
-
- /**
- * @var object Database Holder
- */
- public static $db;
-
- /**
- * @var object Forge Holder
- */
- public static $forge;
-
- /**
- * @var object Driver Holder
- */
- public static $driver;
-
- /**
- * Initialize both database and forge components
- */
- public static function init($driver)
- {
- if (empty(self::$db) && empty(self::$forge))
- {
- // E_DEPRECATED notices thrown by mysql_connect(), mysql_pconnect()
- // on PHP 5.5+ cause the tests to fail
- if ($driver === 'mysql' && version_compare(PHP_VERSION, '5.5', '>='))
- {
- 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 @@
-<?php
-
-/**
- * Mock library to subclass Driver for testing
- */
-class Mock_Libraries_Driver extends CI_Driver_Library {
- /**
- * Set valid drivers list
- */
- public function driver_list($drivers = NULL)
- {
- if (empty($drivers))
- {
- return $this->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 @@
-<?php
-
-class Mock_Libraries_Encrypt extends CI_Encrypt {
-
- // 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/libraries/encryption.php b/tests/mocks/libraries/encryption.php
deleted file mode 100644
index 028eecc72..000000000
--- a/tests/mocks/libraries/encryption.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-class Mock_Libraries_Encryption extends CI_Encryption {
-
- /**
- * __get_params()
- *
- * Allows public calls to the otherwise protected _get_params().
- */
- public function __get_params($params)
- {
- return $this->_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 @@
-<?php
-
-/**
- * Mock library to add testing features to Session driver library
- */
-class Mock_Libraries_Session extends CI_Session {
- /**
- * Simulate new page load
- */
- public function reload()
- {
- $this->_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 @@
-<?php
-
-class Mock_Libraries_Table extends CI_Table {
-
- // 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/uploads/ci_logo.gif b/tests/mocks/uploads/ci_logo.gif
deleted file mode 100644
index 073ec14b4..000000000
--- a/tests/mocks/uploads/ci_logo.gif
+++ /dev/null
Binary files differ
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
deleted file mode 100644
index 875198c4e..000000000
--- a/tests/phpunit.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit
- bootstrap="./Bootstrap.php"
- colors="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- stopOnError="false"
- stopOnFailure="false"
- stopOnIncomplete="false"
- stopOnSkipped="false">
- <testsuites>
- <testsuite name="CodeIgniter Core Test Suite">
- <directory suffix="test.php">./codeigniter/core</directory>
- <directory suffix="test.php">./codeigniter/helpers</directory>
- <directory suffix="test.php">./codeigniter/libraries</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist>
- <directory suffix=".php">../system/</directory>
- </whitelist>
- </filter>
-</phpunit>
diff --git a/tests/travis/mysql.phpunit.xml b/tests/travis/mysql.phpunit.xml
deleted file mode 100644
index 06d4a011b..000000000
--- a/tests/travis/mysql.phpunit.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit
- bootstrap="../Bootstrap.php"
- colors="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- stopOnError="false"
- stopOnFailure="false"
- stopOnIncomplete="false"
- stopOnSkipped="false">
- <php>
- <const name="DB_DRIVER" value="mysql"/>
- </php>
- <testsuites>
- <testsuite name="CodeIgniter Core Test Suite">
- <directory suffix="test.php">../codeigniter</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist addUncoveredFilesFromWhitelist="false">
- <directory suffix=".php">../../system</directory>
- </whitelist>
- </filter>
-</phpunit> \ No newline at end of file
diff --git a/tests/travis/mysqli.phpunit.xml b/tests/travis/mysqli.phpunit.xml
deleted file mode 100644
index 1364f8bfa..000000000
--- a/tests/travis/mysqli.phpunit.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit
- bootstrap="../Bootstrap.php"
- colors="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- stopOnError="false"
- stopOnFailure="false"
- stopOnIncomplete="false"
- stopOnSkipped="false">
- <php>
- <const name="DB_DRIVER" value="mysqli"/>
- </php>
- <testsuites>
- <testsuite name="CodeIgniter Core Test Suite">
- <directory suffix="test.php">../codeigniter</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist addUncoveredFilesFromWhitelist="false">
- <directory suffix=".php">../../system</directory>
- </whitelist>
- </filter>
-</phpunit> \ No newline at end of file
diff --git a/tests/travis/pdo/mysql.phpunit.xml b/tests/travis/pdo/mysql.phpunit.xml
deleted file mode 100644
index 7121edc45..000000000
--- a/tests/travis/pdo/mysql.phpunit.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit
- bootstrap="../../Bootstrap.php"
- colors="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- stopOnError="false"
- stopOnFailure="false"
- stopOnIncomplete="false"
- stopOnSkipped="false">
- <php>
- <const name="DB_DRIVER" value="pdo/mysql"/>
- </php>
- <testsuites>
- <testsuite name="CodeIgniter Core Test Suite">
- <directory suffix="test.php">../../codeigniter</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist addUncoveredFilesFromWhitelist="false">
- <directory suffix=".php">../../../system</directory>
- </whitelist>
- </filter>
-</phpunit> \ No newline at end of file
diff --git a/tests/travis/pdo/pgsql.phpunit.xml b/tests/travis/pdo/pgsql.phpunit.xml
deleted file mode 100644
index df3ff986e..000000000
--- a/tests/travis/pdo/pgsql.phpunit.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit
- bootstrap="../../Bootstrap.php"
- colors="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- stopOnError="false"
- stopOnFailure="false"
- stopOnIncomplete="false"
- stopOnSkipped="false">
- <php>
- <const name="DB_DRIVER" value="pdo/pgsql"/>
- </php>
- <testsuites>
- <testsuite name="CodeIgniter Core Test Suite">
- <directory suffix="test.php">../../codeigniter</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist addUncoveredFilesFromWhitelist="false">
- <directory suffix=".php">../../../system</directory>
- </whitelist>
- </filter>
-</phpunit> \ No newline at end of file
diff --git a/tests/travis/pdo/sqlite.phpunit.xml b/tests/travis/pdo/sqlite.phpunit.xml
deleted file mode 100644
index 7d867f6d1..000000000
--- a/tests/travis/pdo/sqlite.phpunit.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit
- bootstrap="../../Bootstrap.php"
- colors="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- stopOnError="false"
- stopOnFailure="false"
- stopOnIncomplete="false"
- stopOnSkipped="false">
- <php>
- <const name="DB_DRIVER" value="pdo/sqlite"/>
- </php>
- <testsuites>
- <testsuite name="CodeIgniter Core Test Suite">
- <directory suffix="test.php">../../codeigniter</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist addUncoveredFilesFromWhitelist="false">
- <directory suffix=".php">../../../system</directory>
- </whitelist>
- </filter>
-</phpunit> \ No newline at end of file
diff --git a/tests/travis/pgsql.phpunit.xml b/tests/travis/pgsql.phpunit.xml
deleted file mode 100644
index bfddbf6b5..000000000
--- a/tests/travis/pgsql.phpunit.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit
- bootstrap="../Bootstrap.php"
- colors="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- stopOnError="false"
- stopOnFailure="false"
- stopOnIncomplete="false"
- stopOnSkipped="false">
- <php>
- <const name="DB_DRIVER" value="pgsql"/>
- </php>
- <testsuites>
- <testsuite name="CodeIgniter Core Test Suite">
- <directory suffix="test.php">../codeigniter</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist addUncoveredFilesFromWhitelist="false">
- <directory suffix=".php">../../system</directory>
- </whitelist>
- </filter>
-</phpunit> \ No newline at end of file
diff --git a/tests/travis/sqlite.phpunit.xml b/tests/travis/sqlite.phpunit.xml
deleted file mode 100644
index 75c946aee..000000000
--- a/tests/travis/sqlite.phpunit.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit
- bootstrap="../Bootstrap.php"
- colors="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- stopOnError="false"
- stopOnFailure="false"
- stopOnIncomplete="false"
- stopOnSkipped="false">
- <php>
- <const name="DB_DRIVER" value="sqlite"/>
- </php>
- <testsuites>
- <testsuite name="CodeIgniter Core Test Suite">
- <directory suffix="test.php">../codeigniter</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist addUncoveredFilesFromWhitelist="false">
- <directory suffix=".php">../../system</directory>
- </whitelist>
- </filter>
-</phpunit> \ No newline at end of file