From 5bc1dc5257577f2afd562f5b039ad95d57befdb1 Mon Sep 17 00:00:00 2001 From: David Woods Date: Fri, 27 Mar 2015 22:41:58 -0700 Subject: Added more units tests for Form_validation Up to 65% coverage Signed-off-by: David Woods --- .../codeigniter/libraries/Form_validation_test.php | 110 ++++++++++++++++++++- 1 file changed, 108 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index 1bbd1758b..19e7beeee 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -248,7 +248,7 @@ class Form_validation_test extends CI_TestCase { $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('valid_email', '@sample.com')); $this->assertFalse($this->form_validation->valid_emails('@sample.com,2@sample.com,validemail@email.ca')); } @@ -313,7 +313,7 @@ class Form_validation_test extends CI_TestCase { $this->form_validation->set_data($erroneous_data); $this->form_validation->set_rules($rules); $this->form_validation->run(); - $this->assertEquals('

'.$err_message.'

', $this->form_validation->error('req_field')); + $this->assertEquals('

' . $err_message . '

', $this->form_validation->error('req_field')); $this->form_validation->reset_validation(); $this->form_validation->set_message('required', $err_message); @@ -323,6 +323,111 @@ class Form_validation_test extends CI_TestCase { $this->assertEquals('', $this->form_validation->error('req_field')); } + public function test_set_error_delimiters() + { + $this->form_validation->reset_validation(); + $prefix = '
'; + $suffix = '
'; + $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(); + $this->assertEquals($error_message, $this->form_validation->error_array()['foo']); + } + + public function test_error_string() + { + $this->form_validation->reset_validation(); + $error_message = 'What a terrible error!'; + $prefix_default = ''; + $suffix_default = ''; + $prefix_test = ''; + $suffix_test = ''; + $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)); + } + /** * Run rules * @@ -342,4 +447,5 @@ class Form_validation_test extends CI_TestCase { return $this->form_validation->run(); } + } -- cgit v1.2.3-24-g4f1b From cbc21b9bdbaeb2defd47c0808d47801ab1a14ede Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Sun, 29 Mar 2015 13:59:16 -0400 Subject: Increased code coverage Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Lang_test.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 929bc2ffd..3c1e19db3 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -38,7 +38,7 @@ class Lang_test extends CI_TestCase { $this->ci_vfs_clone('system/language/english/number_lang.php'); $this->assertTrue($this->lang->load('number')); $this->assertEquals('Bytes', $this->lang->language['bytes']); - + // Non-existent file $this->setExpectedException( 'RuntimeException', @@ -46,7 +46,30 @@ class Lang_test extends CI_TestCase { ); $this->lang->load('nonexistent'); } + + // -------------------------------------------------------------------- + + public function test_multiple_file_load() + { + // Multiple files + $this->ci_vfs_clone('system/language/english/profiler_lang.php'); + $files = Array('profiler', 'nonexistent'); + $this->setExpectedException( + 'RuntimeException', + 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php' + ); + $this->assertTrue($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/')); + } + // -------------------------------------------------------------------- /** -- cgit v1.2.3-24-g4f1b From 4924115bdf8042850e7934d0ab66fe451e7c778b Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Sun, 29 Mar 2015 15:10:16 -0400 Subject: removed space Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Lang_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 3c1e19db3..a4db7a9c2 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -38,7 +38,7 @@ class Lang_test extends CI_TestCase { $this->ci_vfs_clone('system/language/english/number_lang.php'); $this->assertTrue($this->lang->load('number')); $this->assertEquals('Bytes', $this->lang->language['bytes']); - + // Non-existent file $this->setExpectedException( 'RuntimeException', -- cgit v1.2.3-24-g4f1b From 7df6771e33c43b86a9e0bb8beb9d55aafec3b978 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Sun, 29 Mar 2015 16:27:06 -0400 Subject: Improved unit test code coverage. Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Loader_test.php | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'tests') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 9e2092e05..64632c056 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -22,6 +22,9 @@ class Loader_test extends CI_TestCase { 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); @@ -34,6 +37,13 @@ class Loader_test extends CI_TestCase { $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, ' ')); @@ -316,6 +326,24 @@ class Loader_test extends CI_TestCase { $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)); + } // -------------------------------------------------------------------- @@ -443,6 +471,24 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- + 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'; -- cgit v1.2.3-24-g4f1b From 4b02f1d9545d40fb97c271078e4352693791abaf Mon Sep 17 00:00:00 2001 From: David Woods Date: Sun, 29 Mar 2015 22:46:14 -0700 Subject: Added more unit tests to CI_Form_validation Unit tests for set_select, set_checkbox, and set_radio currently all fail for the same reason. Signed-off-by: David Woods --- .../codeigniter/libraries/Form_validation_test.php | 147 +++++++++++++++++++++ 1 file changed, 147 insertions(+) (limited to 'tests') diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index 19e7beeee..38eb11a34 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -428,6 +428,153 @@ class Form_validation_test extends CI_TestCase { $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(); + $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $_POST = array(); + $this->form_validation->run(); + + $this->assertEquals('', $this->form_validation->set_select('select', 'foo')); + // This fails. Default is only used when no rules are defined. Is this really the desired behaviour? + $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(); + $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $_POST = array(); + $this->form_validation->run(); + + $this->assertEquals('', $this->form_validation->set_radio('select', 'foo')); + // This fails. Default is only used when no rules are defined. Is this really the desired behaviour? + $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(); + $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $_POST = array(); + $this->form_validation->run(); + + $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foo')); + // This fails. Default is only used when no rules are defined. Is this really the desired behaviour? + $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(); + $err_msg_unprepped = ''; + $err_msg_prepped = '<error ='foobar'">'; + $this->form_validation->set_rules('foo', 'label', 'required', array('required' => $err_msg_unprepped)); + $_POST = array('foo' => ''); + $this->form_validation->run(); + $err_arr = $this->form_validation->error_array(); + + $this->assertEquals('', $this->form_validation->prep_for_form('')); + $this->assertEquals(array('foo' => $err_msg_prepped), $this->form_validation->prep_for_form($err_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("<?php", $this->form_validation->encode_php_tags('assertEquals('?>', $this->form_validation->encode_php_tags('?>')); + } + /** * Run rules * -- cgit v1.2.3-24-g4f1b From aa11370ba3d326eef259fedd5a67481b3aa95df6 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 10:05:47 -0400 Subject: added spaces Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Loader_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 64632c056..6028521d1 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -39,7 +39,7 @@ class Loader_test extends CI_TestCase { $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); // Create library in VFS - $lib = Array('unit_test_lib'=>'unit_test_lib'); + $lib = Array('unit_test_lib' => 'unit_test_lib'); // Test loading as an array (int). $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); -- cgit v1.2.3-24-g4f1b From d1f39fdef53fc510a6a5d19ec2991e5bc474bc29 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 10:11:32 -0400 Subject: updated array style and removed assert true Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Lang_test.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index a4db7a9c2..3fccf096d 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -53,12 +53,15 @@ class Lang_test extends CI_TestCase { { // Multiple files $this->ci_vfs_clone('system/language/english/profiler_lang.php'); - $files = Array('profiler', 'nonexistent'); + $files = Array( + 0 => 'profiler', + 1 => 'nonexistent' + ); $this->setExpectedException( 'RuntimeException', 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php' ); - $this->assertTrue($this->lang->load($files, 'english')); + $this->lang->load($files, 'english'); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From fc67a701a574641b5dfd7afe00d4c5d403111626 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 12:08:11 -0400 Subject: changed to lowercase array and space. Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Lang_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 3fccf096d..0f6ffd3fa 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -53,9 +53,9 @@ class Lang_test extends CI_TestCase { { // Multiple files $this->ci_vfs_clone('system/language/english/profiler_lang.php'); - $files = Array( - 0 => 'profiler', - 1 => 'nonexistent' + $files = array( + 0 => 'profiler', + 1 => 'nonexistent' ); $this->setExpectedException( 'RuntimeException', -- cgit v1.2.3-24-g4f1b From 90e07bdaa034d98e23378c51105a8aea85878d07 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 12:10:00 -0400 Subject: changed to lowercase array. Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Loader_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 6028521d1..5e64b62b9 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -39,7 +39,7 @@ class Loader_test extends CI_TestCase { $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); // Create library in VFS - $lib = Array('unit_test_lib' => 'unit_test_lib'); + $lib = array('unit_test_lib' => 'unit_test_lib'); // Test loading as an array (int). $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); -- cgit v1.2.3-24-g4f1b From 928134324d75ed4a876237ec00d4374b2213586a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 30 Mar 2015 19:27:06 +0300 Subject: [ci skip] Whitespace cleanup following PRs #3713 #3714 --- tests/codeigniter/core/Lang_test.php | 12 ++++++------ tests/codeigniter/core/Loader_test.php | 19 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 0f6ffd3fa..d2dd7598a 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -46,15 +46,15 @@ class Lang_test extends CI_TestCase { ); $this->lang->load('nonexistent'); } - + // -------------------------------------------------------------------- - + public function test_multiple_file_load() - { + { // Multiple files $this->ci_vfs_clone('system/language/english/profiler_lang.php'); $files = array( - 0 => 'profiler', + 0 => 'profiler', 1 => 'nonexistent' ); $this->setExpectedException( @@ -65,14 +65,14 @@ class Lang_test extends CI_TestCase { } // -------------------------------------------------------------------- - + 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/')); } - + // -------------------------------------------------------------------- /** diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 5e64b62b9..cfaf6c74b 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -24,7 +24,7 @@ class Loader_test extends CI_TestCase { { // 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); @@ -37,10 +37,10 @@ class Loader_test extends CI_TestCase { $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'); @@ -326,7 +326,7 @@ class Loader_test extends CI_TestCase { $this->assertEquals($val1, $this->load->get_var($key1)); $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); } - + // -------------------------------------------------------------------- public function test_clear_vars() @@ -339,7 +339,7 @@ class Loader_test extends CI_TestCase { $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)); @@ -477,18 +477,18 @@ class Loader_test extends CI_TestCase { $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'; @@ -557,5 +557,4 @@ class Loader_test extends CI_TestCase { // Verify config calls $this->assertEquals($cfg['config'], $this->ci_obj->config->loaded); } - -} \ No newline at end of file +} -- cgit v1.2.3-24-g4f1b From 29704f8890bac6b0173ff60cbf3c3c383448cee2 Mon Sep 17 00:00:00 2001 From: David Woods Date: Mon, 30 Mar 2015 10:37:57 -0700 Subject: Corrected unit tests for set_select, set_radio, and set_checkbox Coverage now at ~75% --- .../codeigniter/libraries/Form_validation_test.php | 59 ++++++++++------------ 1 file changed, 27 insertions(+), 32 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index 38eb11a34..9ab16a00f 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -431,13 +431,11 @@ class Form_validation_test extends CI_TestCase { public function test_set_select() { // Test 1: No options selected - $this->form_validation->reset_validation(); - $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $this->form_validation->reset_validation(); $_POST = array(); $this->form_validation->run(); - $this->assertEquals('', $this->form_validation->set_select('select', 'foo')); - // This fails. Default is only used when no rules are defined. Is this really the desired behaviour? + $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 @@ -453,28 +451,27 @@ class Form_validation_test extends CI_TestCase { // Test 3: Multiple options selected $this->form_validation->reset_validation(); - $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $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)); + $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(); - $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $this->form_validation->reset_validation(); $_POST = array(); $this->form_validation->run(); $this->assertEquals('', $this->form_validation->set_radio('select', 'foo')); - // This fails. Default is only used when no rules are defined. Is this really the desired behaviour? + // 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 @@ -490,28 +487,26 @@ class Form_validation_test extends CI_TestCase { // Test 3: Multiple options checked $this->form_validation->reset_validation(); - $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $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)); + $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(); - $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $this->form_validation->reset_validation(); $_POST = array(); $this->form_validation->run(); - $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foo')); - // This fails. Default is only used when no rules are defined. Is this really the desired behaviour? + $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 @@ -527,16 +522,16 @@ class Form_validation_test extends CI_TestCase { // Test 3: Multiple options selected $this->form_validation->reset_validation(); - $this->form_validation->set_rules('select', 'label', 'alpha_numeric'); + $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)); + $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() -- cgit v1.2.3-24-g4f1b From 7f6f3e3485c1ba9762a239cf279af49bb9bfc755 Mon Sep 17 00:00:00 2001 From: David Woods Date: Mon, 30 Mar 2015 12:25:27 -0700 Subject: Fix for parsing error in PHP 5.2 and 5.3 --- tests/codeigniter/libraries/Form_validation_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index 9ab16a00f..a25dcf747 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -346,7 +346,8 @@ class Form_validation_test extends CI_TestCase { $this->form_validation->set_rules('foo', 'label', 'required'); $_POST = array('foo' => ''); $this->form_validation->run(); - $this->assertEquals($error_message, $this->form_validation->error_array()['foo']); + $err_arr = $this->form_validation->error_array(); + $this->assertEquals($error_message, $err_arr['foo']); } public function test_error_string() -- cgit v1.2.3-24-g4f1b From c6ac5592006935eefab2cc88b808497548105953 Mon Sep 17 00:00:00 2001 From: David Woods Date: Tue, 31 Mar 2015 20:19:39 -0700 Subject: Style changes and variable name changes --- .../codeigniter/libraries/Form_validation_test.php | 43 +++++++++++----------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index a25dcf747..b2d401ee5 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -313,7 +313,7 @@ class Form_validation_test extends CI_TestCase { $this->form_validation->set_data($erroneous_data); $this->form_validation->set_rules($rules); $this->form_validation->run(); - $this->assertEquals('

' . $err_message . '

', $this->form_validation->error('req_field')); + $this->assertEquals('

'.$err_message.'

', $this->form_validation->error('req_field')); $this->form_validation->reset_validation(); $this->form_validation->set_message('required', $err_message); @@ -346,8 +346,8 @@ class Form_validation_test extends CI_TestCase { $this->form_validation->set_rules('foo', 'label', 'required'); $_POST = array('foo' => ''); $this->form_validation->run(); - $err_arr = $this->form_validation->error_array(); - $this->assertEquals($error_message, $err_arr['foo']); + $error_array = $this->form_validation->error_array(); + $this->assertEquals($error_message, $error_array['foo']); } public function test_error_string() @@ -364,16 +364,16 @@ class Form_validation_test extends CI_TestCase { $_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->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()); + $this->assertEquals('', $this->form_validation->error_string()); } public function test_run() @@ -399,27 +399,27 @@ class Form_validation_test extends CI_TestCase { $_POST = array('username' => 'foo42'); $form_validation = new CI_Form_validation($config); $this->assertTrue($form_validation->run('pass')); - - $form_validation = new CI_Form_validation($config); + + $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')); @@ -545,15 +545,15 @@ class Form_validation_test extends CI_TestCase { public function test_prep_for_form() { $this->form_validation->reset_validation(); - $err_msg_unprepped = ''; - $err_msg_prepped = '<error ='foobar'">'; - $this->form_validation->set_rules('foo', 'label', 'required', array('required' => $err_msg_unprepped)); + $error_msg_unprepped = ''; + $error_msg_prepped = '<error ='foobar'">'; + $this->form_validation->set_rules('foo', 'label', 'required', array('required' => $error_msg_unprepped)); $_POST = array('foo' => ''); $this->form_validation->run(); - $err_arr = $this->form_validation->error_array(); - + $error_arr = $this->form_validation->error_array(); + $this->assertEquals('', $this->form_validation->prep_for_form('')); - $this->assertEquals(array('foo' => $err_msg_prepped), $this->form_validation->prep_for_form($err_arr)); + $this->assertEquals(array('foo' => $error_msg_prepped), $this->form_validation->prep_for_form($error_arr)); } public function test_prep_url() @@ -590,5 +590,4 @@ class Form_validation_test extends CI_TestCase { return $this->form_validation->run(); } - } -- cgit v1.2.3-24-g4f1b From 2e9ae00efbc8441e7019a7ab68a866798df42800 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 1 Apr 2015 14:45:16 +0300 Subject: [ci skip] Whitespace cleanup following PR #3716 --- .../codeigniter/libraries/Form_validation_test.php | 58 +++++++++++----------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index b2d401ee5..26d82ec93 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -428,34 +428,34 @@ class Form_validation_test extends CI_TestCase { $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(); + $this->form_validation->reset_validation(); $_POST = array(); $this->form_validation->run(); - - $this->assertEquals('', $this->form_validation->set_select('select', 'foo')); + + $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')); @@ -463,35 +463,35 @@ class Form_validation_test extends CI_TestCase { $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(); + $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')); @@ -499,34 +499,34 @@ class Form_validation_test extends CI_TestCase { $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(); + $this->form_validation->reset_validation(); $_POST = array(); $this->form_validation->run(); - - $this->assertEquals('', $this->form_validation->set_checkbox('select', 'foo')); + + $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')); @@ -534,14 +534,14 @@ class Form_validation_test extends CI_TestCase { $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)); + $this->assertFalse($this->form_validation->regex_match('bar', $regex)); } - + public function test_prep_for_form() { $this->form_validation->reset_validation(); @@ -555,7 +555,7 @@ class Form_validation_test extends CI_TestCase { $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('')); @@ -564,13 +564,13 @@ class Form_validation_test extends CI_TestCase { $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("<?php", $this->form_validation->encode_php_tags('assertEquals('?>', $this->form_validation->encode_php_tags('?>')); } - + /** * Run rules * -- cgit v1.2.3-24-g4f1b