summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codeigniter')
-rw-r--r--tests/codeigniter/libraries/Form_validation_test.php58
1 files changed, 29 insertions, 29 deletions
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("&lt;?php", $this->form_validation->encode_php_tags('<?php'));
$this->assertEquals('?&gt;', $this->form_validation->encode_php_tags('?>'));
}
-
+
/**
* Run rules
*