summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2016-03-11 20:04:43 +0100
committerAndrey Andreev <narf@devilix.net>2016-03-11 20:04:43 +0100
commita190d78a0238a0a6abd463823321bef15713e312 (patch)
treea4e49327f8e6ca1660018cebf3b06131ae3e5faf /tests
parent3b74f57cfa6c43eab4c7cce440a454d095974a45 (diff)
parent4f9b20ae507dda7379d392386fb7ce5702626a91 (diff)
Merge branch '3.0-stable' into develop
Resolved conflicts: system/core/CodeIgniter.php user_guide_src/source/changelog.rst user_guide_src/source/conf.py user_guide_src/source/installation/downloads.rst user_guide_src/source/installation/upgrading.rst
Diffstat (limited to 'tests')
-rw-r--r--tests/codeigniter/core/Log_test.php11
-rw-r--r--tests/codeigniter/core/Security_test.php6
-rw-r--r--tests/codeigniter/database/query_builder/join_test.php27
3 files changed, 39 insertions, 5 deletions
diff --git a/tests/codeigniter/core/Log_test.php b/tests/codeigniter/core/Log_test.php
index d44cbac0f..2dd9d90d2 100644
--- a/tests/codeigniter/core/Log_test.php
+++ b/tests/codeigniter/core/Log_test.php
@@ -1,9 +1,13 @@
<?php
-
class Log_test extends CI_TestCase {
public function test_configuration()
{
+ if ( ! is_php('5.3'))
+ {
+ return $this->markTestSkipped("PHP 5.2 doesn't have ReflectionProperty::setAccessible() and can't run this test");
+ }
+
$path = new ReflectionProperty('CI_Log', '_log_path');
$path->setAccessible(TRUE);
$threshold = new ReflectionProperty('CI_Log', '_threshold');
@@ -50,6 +54,11 @@ class Log_test extends CI_TestCase {
public function test_format_line()
{
+ if ( ! is_php('5.3'))
+ {
+ return $this->markTestSkipped("PHP 5.2 doesn't have ReflectionProperty::setAccessible() and can't run this test");
+ }
+
$this->ci_set_config('log_path', '');
$this->ci_set_config('log_threshold', 0);
$instance = new CI_Log();
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
index 2ef822863..8328c37cb 100644
--- a/tests/codeigniter/core/Security_test.php
+++ b/tests/codeigniter/core/Security_test.php
@@ -299,7 +299,8 @@ class Security_test extends CI_TestCase {
'<img src="mdn-logo-sm.png" alt="MD Logo" srcset="mdn-logo-HD.png 2x, mdn-logo-small.png 15w, mdn-banner-HD.png 100w 2x" />',
'<img sqrc="/img/sunset.gif" height="100%" width="100%">',
'<img srqc="/img/sunset.gif" height="100%" width="100%">',
- '<img srcq="/img/sunset.gif" height="100%" width="100%">'
+ '<img srcq="/img/sunset.gif" height="100%" width="100%">',
+ '<img src=non-quoted.attribute foo="bar">'
);
$urls = array(
@@ -310,7 +311,8 @@ class Security_test extends CI_TestCase {
'mdn-logo-sm.png',
'<img sqrc="/img/sunset.gif" height="100%" width="100%">',
'<img srqc="/img/sunset.gif" height="100%" width="100%">',
- '<img srcq="/img/sunset.gif" height="100%" width="100%">'
+ '<img srcq="/img/sunset.gif" height="100%" width="100%">',
+ 'non-quoted.attribute'
);
for ($i = 0; $i < count($imgtags); $i++)
diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php
index 58cb21492..54b2a4e18 100644
--- a/tests/codeigniter/database/query_builder/join_test.php
+++ b/tests/codeigniter/database/query_builder/join_test.php
@@ -37,6 +37,29 @@ class Join_test extends CI_TestCase {
// ------------------------------------------------------------------------
+ public function test_join_escape_is_null()
+ {
+ $expected = 'SELECT '.$this->db->escape_identifiers('field')
+ ."\nFROM ".$this->db->escape_identifiers('table1')
+ ."\nJOIN ".$this->db->escape_identifiers('table2').' ON '.$this->db->escape_identifiers('field').' IS NULL';
+
+ $this->assertEquals(
+ $expected,
+ $this->db->select('field')->from('table1')->join('table2', 'field IS NULL')->get_compiled_select()
+ );
+
+ $expected = 'SELECT '.$this->db->escape_identifiers('field')
+ ."\nFROM ".$this->db->escape_identifiers('table1')
+ ."\nJOIN ".$this->db->escape_identifiers('table2').' ON '.$this->db->escape_identifiers('field').' IS NOT NULL';
+
+ $this->assertEquals(
+ $expected,
+ $this->db->select('field')->from('table1')->join('table2', 'field IS NOT NULL')->get_compiled_select()
+ );
+ }
+
+ // ------------------------------------------------------------------------
+
public function test_join_escape_multiple_conditions()
{
// We just need a valid query produced, not one that makes sense
@@ -65,11 +88,11 @@ class Join_test extends CI_TestCase {
$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)';
+ .' AND ('.$fields[0]." = 'foo' OR ".$fields[1].' IS NULL)';
$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')
+ ->join('table2', "table1.field1 = table2.field2 AND (table1.field1 = 'foo' OR table2.field2 IS NULL)", 'RIGHT')
->get_compiled_select();
$this->assertEquals($expected, $result);