From 763847931d421753f503608018b0da2bbaa9bfd6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Jan 2013 11:22:05 +0200 Subject: Add ENVIRONMENT constant to unit tests --- tests/Bootstrap.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 8ce80b3fd..c98d88531 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -32,6 +32,7 @@ if ( ! class_exists('vfsStream') && file_exists(PROJECT_BASE.'vendor/autoload.ph 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'; -- cgit v1.2.3-24-g4f1b From 606fee0e2e0aa6a906db82e77090e91f133d7378 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Jan 2013 12:57:13 +0200 Subject: Fix auto_link() for the Nth time - anchor() is for local links and breaks ones that don't have a protocol prefix - Allow :// links (no actual protocol specified) - Further simplified the URL regular expression --- tests/codeigniter/helpers/url_helper_test.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php index 5fc364238..24823a634 100644 --- a/tests/codeigniter/helpers/url_helper_test.php +++ b/tests/codeigniter/helpers/url_helper_test.php @@ -48,11 +48,12 @@ class Url_helper_test extends CI_TestCase { public function test_auto_link_url() { $strings = array( - 'www.codeigniter.com test' => 'http://www.codeigniter.com test', + 'www.codeigniter.com test' => 'www.codeigniter.com test', 'This is my noreply@codeigniter.com test' => 'This is my noreply@codeigniter.com test', - '
www.google.com' => '
http://www.google.com', - 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at http://www.codeigniter.com. Period test.', - 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at http://www.codeigniter.com, comma test' + '
www.google.com' => '
www.google.com', + 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at www.codeigniter.com. Period test.', + 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at www.codeigniter.com, comma test', + 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' => 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' ); foreach ($strings as $in => $out) @@ -66,7 +67,7 @@ class Url_helper_test extends CI_TestCase { public function test_pull_675() { $strings = array( - '
www.google.com' => '
http://www.google.com', + '
www.google.com' => '
www.google.com', ); foreach ($strings as $in => $out) -- cgit v1.2.3-24-g4f1b From bc92262992b606847eb1e764a0ab1cdef0aa12e3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Jan 2013 16:47:41 +0200 Subject: Update unit tests with the ucfirst-library-filename requirement --- tests/codeigniter/core/Loader_test.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index ecc5ca933..dea01a555 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -25,7 +25,7 @@ class Loader_test extends CI_TestCase { // Create library in VFS $lib = 'unit_test_lib'; $class = 'CI_'.ucfirst($lib); - $this->ci_vfs_create($lib, 'ci_base_root, 'libraries'); + $this->ci_vfs_create(ucfirst($lib), 'ci_base_root, 'libraries'); // Test is_loaded fail $this->assertFalse($this->load->is_loaded($lib)); @@ -48,7 +48,7 @@ class Loader_test extends CI_TestCase { // Test non-existent class $this->setExpectedException( 'RuntimeException', - 'CI Error: Non-existent class: '.$lib + 'CI Error: Unable to load the requested class: '.ucfirst($lib) ); $this->assertNull($this->load->library($lib)); } @@ -105,7 +105,7 @@ class Loader_test extends CI_TestCase { $lib = 'unit_test_config_lib'; $class = 'CI_'.ucfirst($lib); $content = 'config = $params; } }'; - $this->ci_vfs_create($lib, $content, $this->ci_base_root, 'libraries'); + $this->ci_vfs_create(ucfirst($lib), $content, $this->ci_base_root, 'libraries'); // Create config file $cfg = array( @@ -133,7 +133,7 @@ class Loader_test extends CI_TestCase { // Create library in VFS $lib = 'super_test_library'; $class = ucfirst($lib); - $this->ci_vfs_create($lib, 'ci_app_root, 'libraries'); + $this->ci_vfs_create(ucfirst($lib), 'ci_app_root, 'libraries'); // Load library $this->assertNull($this->load->library($lib)); @@ -152,7 +152,7 @@ class Loader_test extends CI_TestCase { $dir = ucfirst($driver); $class = 'CI_'.$dir; $content = 'ci_vfs_create($driver, $content, $this->ci_base_root, 'libraries/'.$dir); + $this->ci_vfs_create(ucfirst($driver), $content, $this->ci_base_root, 'libraries/'.$dir); // Test loading as an array. $this->assertNull($this->load->driver(array($driver))); @@ -410,7 +410,7 @@ class Loader_test extends CI_TestCase { $dir = 'third-party'; $lib = 'unit_test_package'; $class = 'CI_'.ucfirst($lib); - $this->ci_vfs_create($lib, 'ci_app_root, array($dir, 'libraries')); + $this->ci_vfs_create(ucfirst($lib), 'ci_app_root, array($dir, 'libraries')); // Get paths $paths = $this->load->get_package_paths(TRUE); @@ -440,7 +440,7 @@ class Loader_test extends CI_TestCase { // Test failed load without path $this->setExpectedException( 'RuntimeException', - 'CI Error: Unable to load the requested class: '.$lib + 'CI Error: Unable to load the requested class: '.ucfirst($lib) ); $this->load->library($lib); } @@ -467,13 +467,13 @@ class Loader_test extends CI_TestCase { // Create library in VFS $lib = 'autolib'; $lib_class = 'CI_'.ucfirst($lib); - $this->ci_vfs_create($lib, 'ci_base_root, 'libraries'); + $this->ci_vfs_create(ucfirst($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)); + $this->ci_vfs_create(ucfirst($drv), 'ci_base_root, array('libraries', $subdir)); // Create model in VFS package path $dir = 'testdir'; -- cgit v1.2.3-24-g4f1b From ed92580e028b17230723807c51503e42f07cdb8e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 30 Jan 2013 13:59:19 +0200 Subject: Remove tests for now non-existent method CI_Upload::clean_file_name() See 7e5597782a589e4171ca08abdd9ce1a185542ff4 --- tests/codeigniter/libraries/Upload_test.php | 6 ------ 1 file changed, 6 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/libraries/Upload_test.php b/tests/codeigniter/libraries/Upload_test.php index 1bd8f1430..4d9e4a46e 100644 --- a/tests/codeigniter/libraries/Upload_test.php +++ b/tests/codeigniter/libraries/Upload_test.php @@ -208,12 +208,6 @@ class Upload_test extends CI_TestCase { $this->assertEquals('', $this->upload->get_extension('hello')); } - function test_clean_file_name() - { - $this->assertEquals('hello.txt', $this->upload->clean_file_name('hello.txt')); - $this->assertEquals('hello.txt', $this->upload->clean_file_name('%253chell>o.txt')); - } - function test_limit_filename_length() { $this->assertEquals('hello.txt', $this->upload->limit_filename_length('hello.txt', 10)); -- cgit v1.2.3-24-g4f1b From 3567246091195e035ea4c8d3b2915eb6b45ad5e2 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Fri, 15 Feb 2013 01:36:04 +0100 Subject: Various cosmetic fixes --- tests/codeigniter/core/URI_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php index e2deabe51..7fa0e6265 100644 --- a/tests/codeigniter/core/URI_test.php +++ b/tests/codeigniter/core/URI_test.php @@ -91,7 +91,7 @@ class URI_test extends CI_TestCase { public function test_explode_segments() { - // Lets test the function's ability to clean up this mess + // Let's test the function's ability to clean up this mess $uris = array( 'test/uri' => array('test', 'uri'), '/test2/uri2' => array('test2', 'uri2'), -- cgit v1.2.3-24-g4f1b From e1d5a7a0a6078d0edb0b9ac6e5d60a4c746ae365 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 19 Feb 2013 13:38:43 +0200 Subject: Fix form_upload() test --- tests/codeigniter/helpers/form_helper_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/helpers/form_helper_test.php b/tests/codeigniter/helpers/form_helper_test.php index 89165271e..e234f9c83 100644 --- a/tests/codeigniter/helpers/form_helper_test.php +++ b/tests/codeigniter/helpers/form_helper_test.php @@ -58,7 +58,7 @@ EOH; public function test_form_upload() { $expected = << + EOH; -- cgit v1.2.3-24-g4f1b From e84c0144bbd15094cc19716222b691ed3a27d2e4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 15:28:13 +0200 Subject: Fix Session tests --- tests/mocks/libraries/session.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/mocks/libraries/session.php b/tests/mocks/libraries/session.php index 562033bbf..adbecb329 100644 --- a/tests/mocks/libraries/session.php +++ b/tests/mocks/libraries/session.php @@ -33,4 +33,6 @@ class Mock_Libraries_Session_cookie extends CI_Session_cookie { $_COOKIE[$name] = $value; } } -} \ No newline at end of file +} + +class Mock_Libraries_Session_native extends CI_Session_native {} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 8cf596b5eabe431572ec1c4f21b9c32101feb22f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 16:44:12 +0200 Subject: DB_result tests seem to also depend on autoloading via the class_exists() checks ... --- tests/mocks/database/ci_test.sqlite | Bin 19456 -> 19456 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'tests') diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite index 44dcef9ec..574d3ae53 100755 Binary files a/tests/mocks/database/ci_test.sqlite and b/tests/mocks/database/ci_test.sqlite differ -- cgit v1.2.3-24-g4f1b From 452b668d4edda5ae04c16f494bffe09114afc3ba Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 19:05:52 +0200 Subject: Add CI_Utf8::convert_to_utf8() test --- tests/codeigniter/core/Utf8_test.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/codeigniter/core/Utf8_test.php (limited to 'tests') diff --git a/tests/codeigniter/core/Utf8_test.php b/tests/codeigniter/core/Utf8_test.php new file mode 100644 index 000000000..caa7b6986 --- /dev/null +++ b/tests/codeigniter/core/Utf8_test.php @@ -0,0 +1,20 @@ +utf8 = new Mock_Core_Utf8(); + } + + // -------------------------------------------------------------------- + + public function test_convert_to_utf8() + { + $this->assertEquals( + $this->utf8->convert_to_utf8('', 'WINDOWS-1251'), + 'тест' + ); + } + +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b3a5d6e8ad90644760890182a43ed81a23b86efe Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 22:03:23 +0200 Subject: Some miscellaneous tests --- tests/codeigniter/core/Input_test.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index ca1c6dfd7..5cf25fefa 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -95,8 +95,8 @@ class Input_test extends CI_TestCase { public function test_cookie() { $_COOKIE['foo'] = 'bar'; - $this->assertEquals('bar', $this->input->cookie('foo')); + $this->assertNull($this->input->cookie('bar')); } // -------------------------------------------------------------------- @@ -138,4 +138,27 @@ class Input_test extends CI_TestCase { } } + // -------------------------------------------------------------------- + + 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()); + } + } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From eb291c1d1e1116a4420fa30e587adeea0451eeb7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 22:22:51 +0200 Subject: CI_Output [set/append/get]_output() tests --- tests/codeigniter/core/Output_test.php | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests') diff --git a/tests/codeigniter/core/Output_test.php b/tests/codeigniter/core/Output_test.php index 728df3bf6..0eeb93f7b 100644 --- a/tests/codeigniter/core/Output_test.php +++ b/tests/codeigniter/core/Output_test.php @@ -3,6 +3,16 @@ class Output_test extends CI_TestCase { public $output; + protected $_output_data = << + + Basic HTML + + + Test + + +HTML; public function set_up() { @@ -13,6 +23,31 @@ class Output_test extends CI_TestCase { // -------------------------------------------------------------------- + public function test_set_get_append_output() + { + $append = "\n"; + + $this->assertEquals( + $this->_output_data.$append, + $this->output + ->set_output($this->_output_data) + ->append_output("\n") + ->get_output() + ); + } + + // -------------------------------------------------------------------- + + public function test_minify() + { + $this->assertEquals( + str_replace(array("\t", "\n"), '', $this->_output_data), + $this->output->minify($this->_output_data) + ); + } + + // -------------------------------------------------------------------- + public function test_get_content_type() { $this->assertEquals('text/html', $this->output->get_content_type()); -- cgit v1.2.3-24-g4f1b