summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-07-26 20:03:12 +0200
committerAndrey Andreev <narf@devilix.net>2016-07-26 20:03:12 +0200
commit77266bc6a01668b2106b9974da02e2a7ceaf2fe6 (patch)
tree955346c3278c03a2ff4174b9d078e9416a298ee9 /tests/codeigniter
parenta9874a638970ef826f835718e58b197ff3672566 (diff)
parent0b9540209499fbd0515e13fdc66e85dea4b6baad (diff)
Merge branch '3.1-stable' into develop
Conflicts resolved: .travis.yml system/core/CodeIgniter.php system/database/drivers/oci8/oci8_forge.php system/database/drivers/pdo/subdrivers/pdo_oci_forge.php system/helpers/path_helper.php system/libraries/Email.php user_guide_src/source/changelog.rst user_guide_src/source/conf.py user_guide_src/source/contributing/index.rst user_guide_src/source/general/requirements.rst user_guide_src/source/general/styleguide.rst user_guide_src/source/installation/downloads.rst user_guide_src/source/installation/upgrade_310.rst user_guide_src/source/installation/upgrading.rst
Diffstat (limited to 'tests/codeigniter')
-rw-r--r--tests/codeigniter/core/Config_test.php2
-rw-r--r--tests/codeigniter/core/Input_test.php6
-rw-r--r--tests/codeigniter/libraries/Form_validation_test.php17
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'))));
}