diff options
Diffstat (limited to 'tests/codeigniter')
-rw-r--r-- | tests/codeigniter/core/Config_test.php | 2 | ||||
-rw-r--r-- | tests/codeigniter/core/Input_test.php | 6 | ||||
-rw-r--r-- | tests/codeigniter/libraries/Form_validation_test.php | 17 |
3 files changed, 22 insertions, 3 deletions
diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php index 26a5f32f5..b5c9e849d 100644 --- a/tests/codeigniter/core/Config_test.php +++ b/tests/codeigniter/core/Config_test.php @@ -127,6 +127,8 @@ class Config_test extends CI_TestCase { $this->assertEquals($index_page.'/'.$uri, $this->config->site_url($uri)); $this->assertEquals($index_page.'/'.$uri.'/'.$uri2, $this->config->site_url(array($uri, $uri2))); + $this->assertEquals($index_page.'/test/', $this->config->site_url('test/')); + $suffix = 'ing'; $this->config->set_item('url_suffix', $suffix); diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index c56900d22..e1f4011b5 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -262,6 +262,12 @@ class Input_test extends CI_TestCase { $this->assertEquals('FE80:0000:0000:0000:0202:B3FF:FE1E:8300', $this->input->ip_address()); $this->input->ip_address = FALSE; + $this->ci_set_config('proxy_ips', '0::/32'); + $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.7'; + $_SERVER['REMOTE_ADDR'] = '0000:0000:0000:0000:0000:0000:0000:0001'; + $this->assertEquals('127.0.0.7', $this->input->ip_address()); + + $this->input->ip_address = FALSE; $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // back to reality } diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index 3537eb355..b87ca65ff 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -40,11 +40,22 @@ class Form_validation_test extends CI_TestCase { public function test_rule_required() { - $rules = array(array('field' => 'foo', 'label' => 'foo_label', 'rules' => 'required')); - $this->assertTrue($this->run_rules($rules, array('foo' => 'bar'))); + $rules = array(array('field' => 'foo', 'label' => 'Foo', 'rules' => 'is_numeric')); + // Empty, not required + $this->assertTrue($this->run_rules($rules, array('foo' => ''))); + + + // Not required, but also not empty + $this->assertTrue($this->run_rules($rules, array('foo' => '123'))); + $this->assertFalse($this->run_rules($rules, array('foo' => 'bar'))); + + // Required variations + $rules[0]['rules'] .= '|required'; + $this->assertTrue($this->run_rules($rules, array('foo' => '123'))); $this->assertFalse($this->run_rules($rules, array('foo' => ''))); $this->assertFalse($this->run_rules($rules, array('foo' => ' '))); + $this->assertFalse($this->run_rules($rules, array('foo' => 'bar'))); } public function test_rule_matches() @@ -55,9 +66,9 @@ class Form_validation_test extends CI_TestCase { ); $values_base = array('foo' => 'sample'); - $this->assertTrue($this->run_rules($rules, array_merge($values_base, array('bar' => '')))); $this->assertTrue($this->run_rules($rules, array_merge($values_base, array('bar' => 'sample')))); + $this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => '')))); $this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => 'Sample')))); $this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => ' sample')))); } |