From 7c4d10660a0a47446474bf97e3cb65f80693f1ee Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 15:14:34 +0200 Subject: Fix issue #1953 (form values being escaped twice) Re-instaing an improved form_prep() function, reverting most of the changes from 74ffd17ab06327ca62ddfe28a186cae7ba6bd459. --- tests/codeigniter/helpers/form_helper_test.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/codeigniter/helpers/form_helper_test.php b/tests/codeigniter/helpers/form_helper_test.php index 03278581d..89165271e 100644 --- a/tests/codeigniter/helpers/form_helper_test.php +++ b/tests/codeigniter/helpers/form_helper_test.php @@ -272,6 +272,21 @@ EOH; $this->assertEquals($expected, form_close('')); } + // ------------------------------------------------------------------------ + + public function test_form_prep() + { + $this->assertEquals( + 'Here is a string containing "quoted" text.', + form_prep('Here is a string containing "quoted" text.') + ); + + $this->assertEquals( + 'Here is a string containing a <tag>.', + form_prep('Here is a string containing a .', TRUE) + ); + } + } /* End of file form_helper_test.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From e24eed7e4e410fabf7479a67d3a27e2596444505 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Nov 2012 23:33:45 +0200 Subject: Some micro-optimizations --- tests/codeigniter/database/DB_driver_test.php | 2 +- tests/mocks/autoloader.php | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/database/DB_driver_test.php b/tests/codeigniter/database/DB_driver_test.php index 9e16e29b4..1f48ca984 100644 --- a/tests/codeigniter/database/DB_driver_test.php +++ b/tests/codeigniter/database/DB_driver_test.php @@ -5,7 +5,7 @@ class DB_driver_test extends CI_TestCase { public function test_initialize() { $config = Mock_Database_DB::config(DB_DRIVER); - $driver_name = current(explode('/', DB_DRIVER)); + sscanf(DB_DRIVER, '%[^/]/', $driver_name); $driver = $this->$driver_name($config[DB_DRIVER]); $this->assertTrue($driver->initialize()); diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php index 5b202f159..4fc9c63b6 100644 --- a/tests/mocks/autoloader.php +++ b/tests/mocks/autoloader.php @@ -38,13 +38,11 @@ function autoload($class) if (strpos($class, 'Mock_') === 0) { - $class = str_replace(array('Mock_', '_'), array('', DIRECTORY_SEPARATOR), $class); - $class = strtolower($class); + $class = strtolower(str_replace(array('Mock_', '_'), array('', DIRECTORY_SEPARATOR), $class)); } elseif (strpos($class, 'CI_') === 0) { - $fragments = explode('_', $class, 2); - $subclass = next($fragments); + $subclass = substr($class, 3); if (in_array($subclass, $ci_core)) { @@ -88,7 +86,7 @@ function autoload($class) } } - $file = (isset($file)) ? $file : $dir.$class.'.php'; + $file = isset($file) ? $file : $dir.$class.'.php'; if ( ! file_exists($file)) { -- cgit v1.2.3-24-g4f1b From 1712f1191f0027b61ca06dae7be303ea1b52f867 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 3 Nov 2012 00:40:33 +0200 Subject: An attempt to fix Loader tests --- tests/codeigniter/core/Loader_test.php | 73 ++++++++++++++++------------------ 1 file changed, 35 insertions(+), 38 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 816587a49..02629908f 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -6,6 +6,41 @@ class Loader_test extends CI_TestCase { public function set_up() { + // Create helper in VFS + $helper = 'autohelp'; + $hlp_func = '_autohelp_test_func'; + $content = '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($lib, 'ci_base_root, 'libraries'); + + // Create driver in VFS + $drv = 'autodrv'; + $subdir = ucfirst($drv); + $drv_class = 'CI_'.$subdir; + $this->ci_vfs_create($drv, 'ci_base_root, array('libraries', $subdir)); + + // Create model in VFS package path + $dir = 'testdir'; + $path = APPPATH.$dir.'/'; + $model = 'automod'; + $mod_class = ucfirst($model); + $this->ci_vfs_create($model, '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', 'ci_app_root, 'config'); + // Instantiate a new loader $loader = $this->ci_core_class('loader'); $this->load = new $loader(); @@ -458,44 +493,6 @@ class Loader_test extends CI_TestCase { public function test_initialize() { - // Create helper in VFS - $helper = 'autohelp'; - $hlp_func = '_autohelp_test_func'; - $content = '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($lib, 'ci_base_root, 'libraries'); - - // Create driver in VFS - $drv = 'autodrv'; - $subdir = ucfirst($drv); - $drv_class = 'CI_'.$subdir; - $this->ci_vfs_create($drv, 'ci_base_root, array('libraries', $subdir)); - - // Create model in VFS package path - $dir = 'testdir'; - $path = APPPATH.$dir.'/'; - $model = 'automod'; - $mod_class = ucfirst($model); - $this->ci_vfs_create($model, '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', 'ci_app_root, 'config'); - - // Run initialize and autoloader - $this->load->initialize(); - // Verify path $this->assertContains($path, $this->load->get_package_paths()); -- cgit v1.2.3-24-g4f1b From dd8d3d366bef1bc3fcb4476e88e8e6af44b89973 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 3 Nov 2012 02:09:05 +0200 Subject: Fix the bloody tests --- tests/codeigniter/core/Loader_test.php | 72 +++++++++++++++++----------------- tests/mocks/ci_testcase.php | 2 + 2 files changed, 39 insertions(+), 35 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 02629908f..be223f97d 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -6,41 +6,6 @@ class Loader_test extends CI_TestCase { public function set_up() { - // Create helper in VFS - $helper = 'autohelp'; - $hlp_func = '_autohelp_test_func'; - $content = '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($lib, 'ci_base_root, 'libraries'); - - // Create driver in VFS - $drv = 'autodrv'; - $subdir = ucfirst($drv); - $drv_class = 'CI_'.$subdir; - $this->ci_vfs_create($drv, 'ci_base_root, array('libraries', $subdir)); - - // Create model in VFS package path - $dir = 'testdir'; - $path = APPPATH.$dir.'/'; - $model = 'automod'; - $mod_class = ucfirst($model); - $this->ci_vfs_create($model, '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', 'ci_app_root, 'config'); - // Instantiate a new loader $loader = $this->ci_core_class('loader'); $this->load = new $loader(); @@ -493,6 +458,43 @@ class Loader_test extends CI_TestCase { public function test_initialize() { + // Create helper in VFS + $helper = 'autohelp'; + $hlp_func = '_autohelp_test_func'; + $content = '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($lib, 'ci_base_root, 'libraries'); + + // Create driver in VFS + $drv = 'autodrv'; + $subdir = ucfirst($drv); + $drv_class = 'CI_'.$subdir; + $this->ci_vfs_create($drv, 'ci_base_root, array('libraries', $subdir)); + + // Create model in VFS package path + $dir = 'testdir'; + $path = APPPATH.$dir.'/'; + $model = 'automod'; + $mod_class = ucfirst($model); + $this->ci_vfs_create($model, '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', 'ci_app_root, 'config'); + + $this->load->__construct(); + // Verify path $this->assertContains($path, $this->load->get_package_paths()); diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php index f16492945..2d0a26830 100644 --- a/tests/mocks/ci_testcase.php +++ b/tests/mocks/ci_testcase.php @@ -39,6 +39,8 @@ class CI_TestCase extends PHPUnit_Framework_TestCase { $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); + vfsStream::newDirectory('config')->at($this->ci_app_root); + $this->ci_vfs_clone('application/config/autoload.php'); if (method_exists($this, 'set_up')) { -- cgit v1.2.3-24-g4f1b From cdac248e9cf7a8ea3ed426f189bb52254800bc2a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 3 Nov 2012 18:09:01 +0200 Subject: Revert 679525d0237ac2e0a94d7b05377eb31eb3398f19 It appears to break get_instance()->*_package_path*() usage which is very common. Need to figure out how to resolve this. --- tests/codeigniter/core/Loader_test.php | 2 +- tests/mocks/ci_testcase.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index be223f97d..ecc5ca933 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -493,7 +493,7 @@ class Loader_test extends CI_TestCase { ); $this->ci_vfs_create('autoload', 'ci_app_root, 'config'); - $this->load->__construct(); + $this->load->initialize(); // Verify path $this->assertContains($path, $this->load->get_package_paths()); diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php index 2d0a26830..f16492945 100644 --- a/tests/mocks/ci_testcase.php +++ b/tests/mocks/ci_testcase.php @@ -39,8 +39,6 @@ class CI_TestCase extends PHPUnit_Framework_TestCase { $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); - vfsStream::newDirectory('config')->at($this->ci_app_root); - $this->ci_vfs_clone('application/config/autoload.php'); if (method_exists($this, 'set_up')) { -- cgit v1.2.3-24-g4f1b From a287a34c215903d3452023d74149eb5880125715 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 5 Nov 2012 23:19:59 +0200 Subject: Refactored DB Forge - PDO subdrivers are isolated from each other now. - Added compatibility for pretty much all of the features, for every DB platform. - Unified the way that stuff works in general. - Fixes issue #1005. --- tests/mocks/database/db/driver.php | 1 + tests/mocks/database/schema/skeleton.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/mocks/database/db/driver.php b/tests/mocks/database/db/driver.php index 65ac2c4cc..2cf54b97b 100644 --- a/tests/mocks/database/db/driver.php +++ b/tests/mocks/database/db/driver.php @@ -34,6 +34,7 @@ class Mock_Database_DB_Driver extends CI_DB_driver { return call_user_func_array(array($this->ci_db_driver, $method), $arguments); } + } class CI_DB extends Mock_Database_DB_QueryBuilder {} \ No newline at end of file diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php index d72244528..e5c536090 100644 --- a/tests/mocks/database/schema/skeleton.php +++ b/tests/mocks/database/schema/skeleton.php @@ -69,7 +69,7 @@ class Mock_Database_Schema_Skeleton { ) )); static::$forge->add_key('id', TRUE); - static::$forge->create_table('user', (strpos(static::$driver, 'pgsql') === FALSE)); + static::$forge->create_table('user', TRUE); // Job Table static::$forge->add_field(array( @@ -86,7 +86,7 @@ class Mock_Database_Schema_Skeleton { ) )); static::$forge->add_key('id', TRUE); - static::$forge->create_table('job', (strpos(static::$driver, 'pgsql') === FALSE)); + static::$forge->create_table('job', TRUE); // Misc Table static::$forge->add_field(array( @@ -103,7 +103,7 @@ class Mock_Database_Schema_Skeleton { ) )); static::$forge->add_key('id', TRUE); - static::$forge->create_table('misc', (strpos(static::$driver, 'pgsql') === FALSE)); + static::$forge->create_table('misc', TRUE); } /** -- cgit v1.2.3-24-g4f1b From ac68a3cadae94324d7de00bcb183ba19025e9ca2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Nov 2012 15:44:00 +0200 Subject: Fix directory_map() tests --- tests/codeigniter/helpers/directory_helper_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/helpers/directory_helper_test.php b/tests/codeigniter/helpers/directory_helper_test.php index c39ccd8d0..b7d52661f 100644 --- a/tests/codeigniter/helpers/directory_helper_test.php +++ b/tests/codeigniter/helpers/directory_helper_test.php @@ -28,7 +28,7 @@ class Directory_helper_test extends CI_TestCase { // test default recursive behavior $expected = array( - 'libraries' => array( + 'libraries/' => array( 'benchmark.html', 'database' => array('active_record.html', 'binds.html'), 'email.html', @@ -39,12 +39,12 @@ class Directory_helper_test extends CI_TestCase { $this->assertEquals($expected, directory_map(vfsStream::url('testDir'))); // test detection of hidden files - $expected['libraries'][] = '.hiddenfile.txt'; + $expected['libraries/'][] = '.hiddenfile.txt'; $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), FALSE, TRUE)); // test recursion depth behavior - $this->assertEquals(array('libraries'), directory_map(vfsStream::url('testDir'), 1)); + $this->assertEquals(array('libraries/'), directory_map(vfsStream::url('testDir'), 1)); } } -- cgit v1.2.3-24-g4f1b From e8b8904bdfd6f8320beb67fb6daa96ee14c3b917 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Nov 2012 15:50:17 +0200 Subject: directory_map() ... the final one --- tests/codeigniter/helpers/directory_helper_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/helpers/directory_helper_test.php b/tests/codeigniter/helpers/directory_helper_test.php index b7d52661f..41370e6e7 100644 --- a/tests/codeigniter/helpers/directory_helper_test.php +++ b/tests/codeigniter/helpers/directory_helper_test.php @@ -30,7 +30,7 @@ class Directory_helper_test extends CI_TestCase { $expected = array( 'libraries/' => array( 'benchmark.html', - 'database' => array('active_record.html', 'binds.html'), + 'database/' => array('active_record.html', 'binds.html'), 'email.html', '0' ) -- cgit v1.2.3-24-g4f1b From 1f884d6fece302ba53f106516880da4dd91f5660 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Nov 2012 19:57:14 +0200 Subject: Move Log class to core in tests as well --- tests/mocks/autoloader.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php index 4fc9c63b6..3d216da1f 100644 --- a/tests/mocks/autoloader.php +++ b/tests/mocks/autoloader.php @@ -16,7 +16,7 @@ function autoload($class) $ci_core = array( 'Benchmark', 'Config', 'Controller', 'Exceptions', 'Hooks', 'Input', - 'Lang', 'Loader', 'Model', + 'Lang', 'Loader', 'Log', 'Model', 'Output', 'Router', 'Security', 'URI', 'Utf8', ); @@ -25,11 +25,10 @@ function autoload($class) 'Calendar', 'Cart', 'Driver_Library', 'Email', 'Encrypt', 'Form_validation', 'Ftp', 'Image_lib', 'Javascript', - 'Log', 'Migration', 'Pagination', - 'Parser', 'Profiler', 'Table', - 'Trackback', 'Typography', 'Unit_test', - 'Upload', 'User_agent', 'Xmlrpc', - 'Zip', + 'Migration', 'Pagination', 'Parser', + 'Profiler', 'Table', 'Trackback', + 'Typography', 'Unit_test', 'Upload', + 'User_agent', 'Xmlrpc', 'Zip' ); $ci_drivers = array( -- cgit v1.2.3-24-g4f1b