From 391d339b921623ce921bdb5520fb93f9cf62fac5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 30 Jan 2016 22:43:41 +0200 Subject: Fix #4415 and add unit tests for https://bugs.php.net/bug.php?id=51192 --- tests/codeigniter/libraries/Form_validation_test.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php index 65a3bbff7..f455b9146 100644 --- a/tests/codeigniter/libraries/Form_validation_test.php +++ b/tests/codeigniter/libraries/Form_validation_test.php @@ -231,6 +231,13 @@ class Form_validation_test extends CI_TestCase { $this->assertTrue($this->form_validation->valid_url('www.codeigniter.com')); $this->assertTrue($this->form_validation->valid_url('http://codeigniter.com')); + // https://bugs.php.net/bug.php?id=51192 + $this->assertTrue($this->form_validation->valid_url('http://accept-dashes.tld')); + $this->assertFalse($this->form_validation->valid_url('http://reject_underscores.tld')); + + // https://github.com/bcit-ci/CodeIgniter/issues/4415 + $this->assertTrue($this->form_validation->valid_url('http://[::1]/ipv6')); + $this->assertFalse($this->form_validation->valid_url('htt://www.codeIgniter.com')); $this->assertFalse($this->form_validation->valid_url('')); $this->assertFalse($this->form_validation->valid_url('code igniter')); -- cgit v1.2.3-24-g4f1b From 95bd763784f215a5cb4c38a4bc1caf5ac3c8f72d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 5 Feb 2016 14:15:45 +0200 Subject: Fix another regression caused by 805eddaefd9503b5dbbd924bd6da66e29c4768f3 Also added a unit test for #4431 --- .../codeigniter/database/query_builder/join_test.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php index 25bd4accb..58cb21492 100644 --- a/tests/codeigniter/database/query_builder/join_test.php +++ b/tests/codeigniter/database/query_builder/join_test.php @@ -55,4 +55,24 @@ class Join_test extends CI_TestCase { $this->assertEquals($expected, $result); } + // ------------------------------------------------------------------------ + + public function test_join_escape_multiple_conditions_with_parentheses() + { + // We just need a valid query produced, not one that makes sense + $fields = array($this->db->protect_identifiers('table1.field1'), $this->db->protect_identifiers('table2.field2')); + + $expected = 'SELECT '.implode(', ', $fields) + ."\nFROM ".$this->db->escape_identifiers('table1') + ."\nRIGHT JOIN ".$this->db->escape_identifiers('table2').' ON '.implode(' = ', $fields) + .' AND ('.$fields[0]." = 'foo' OR ".$fields[1].' = 0)'; + + $result = $this->db->select('table1.field1, table2.field2') + ->from('table1') + ->join('table2', "table1.field1 = table2.field2 AND (table1.field1 = 'foo' OR table2.field2 = 0)", 'RIGHT') + ->get_compiled_select(); + + $this->assertEquals($expected, $result); + } + } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 39967987ebcc79fc867c1f7fa8d69cc65801f594 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 9 Feb 2016 23:34:04 +0200 Subject: Add CI_Log test cases --- tests/codeigniter/core/Log_test.php | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/codeigniter/core/Log_test.php (limited to 'tests') diff --git a/tests/codeigniter/core/Log_test.php b/tests/codeigniter/core/Log_test.php new file mode 100644 index 000000000..01e90f5fc --- /dev/null +++ b/tests/codeigniter/core/Log_test.php @@ -0,0 +1,64 @@ +setAccessible(TRUE); + $threshold = new ReflectionProperty('CI_Log', '_threshold'); + $threshold->setAccessible(TRUE); + $date_fmt = new ReflectionProperty('CI_Log', '_date_fmt'); + $date_fmt->setAccessible(TRUE); + $file_ext = new ReflectionProperty('CI_Log', '_file_ext'); + $file_ext->setAccessible(TRUE); + $file_perms = new ReflectionProperty('CI_Log', '_file_permissions'); + $file_perms->setAccessible(TRUE); + $enabled = new ReflectionProperty('CI_Log', '_enabled'); + $enabled->setAccessible(TRUE); + + $this->ci_set_config('log_path', '/root/'); + $this->ci_set_config('log_threshold', 'z'); + $this->ci_set_config('log_date_format', 'd.m.Y'); + $this->ci_set_config('log_file_extension', ''); + $this->ci_set_config('log_file_permissions', ''); + $instance = new CI_Log(); + + $this->assertEquals($path->getValue($instance), '/root/'); + $this->assertEquals($threshold->getValue($instance), 1); + $this->assertEquals($date_fmt->getValue($instance), 'd.m.Y'); + $this->assertEquals($file_ext->getValue($instance), 'php'); + $this->assertEquals($file_perms->getValue($instance), 0644); + $this->assertEquals($enabled->getValue($instance), FALSE); + + $this->ci_set_config('log_path', ''); + $this->ci_set_config('log_threshold', '0'); + $this->ci_set_config('log_date_format', ''); + $this->ci_set_config('log_file_extension', '.log'); + $this->ci_set_config('log_file_permissions', 0600); + $instance = new CI_Log(); + + $this->assertEquals($path->getValue($instance), APPPATH.'logs/'); + $this->assertEquals($threshold->getValue($instance), 0); + $this->assertEquals($date_fmt->getValue($instance), 'Y-m-d H:i:s'); + $this->assertEquals($file_ext->getValue($instance), 'log'); + $this->assertEquals($file_perms->getValue($instance), 0600); + $this->assertEquals($enabled->getValue($instance), TRUE); + } + + // -------------------------------------------------------------------- + + public function test_format_line() + { + $this->ci_set_config('log_path', ''); + $this->ci_set_config('log_threshold', 0); + $instance = new CI_Log(); + + $format_line = new ReflectionMethod($instance, '_format_line'); + $format_line->setAccessible(TRUE); + $this->assertEquals( + $format_line->invoke($instance, 'LEVEL', 'Timestamp', 'Message'), + "LEVEL - Timestamp --> Message\n" + ); + } +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b