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/codeigniter') 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/codeigniter') 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()); -- 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/codeigniter') 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 +++++++++++++++++----------------- 1 file changed, 37 insertions(+), 35 deletions(-) (limited to 'tests/codeigniter') 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()); -- 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/codeigniter') 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()); -- 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/codeigniter') 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/codeigniter') 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