summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/codeigniter/core/Security_test.php31
-rw-r--r--tests/codeigniter/database/DB_driver_test.php2
-rw-r--r--tests/codeigniter/database/DB_test.php8
-rw-r--r--tests/mocks/core/input.php8
4 files changed, 48 insertions, 1 deletions
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
index d967613b5..c96eecf02 100644
--- a/tests/codeigniter/core/Security_test.php
+++ b/tests/codeigniter/core/Security_test.php
@@ -126,5 +126,36 @@ class Security_test extends CI_TestCase {
$this->assertEquals('foo', $safe_filename);
}
+
+ // --------------------------------------------------------------------
+ public function test_strip_image_tags()
+ {
+ $imgtags = Array(
+ '<img src="smiley.gif" alt="Smiley face" height="42" width="42">',
+ '<img alt="Smiley face" height="42" width="42" src="smiley.gif">',
+ '<img src="http://www.w3schools.com/images/w3schools_green.jpg">',
+ '<img src="/img/sunset.gif" height="100%" width="100%">',
+ '<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%">'
+ );
+
+ $urls = Array(
+ 'smiley.gif',
+ 'smiley.gif',
+ 'http://www.w3schools.com/images/w3schools_green.jpg',
+ '/img/sunset.gif',
+ '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%">'
+ );
+
+ for($i = 0; $i < count($imgtags); $i++)
+ {
+ $this->assertEquals($urls[$i], $this->security->strip_image_tags($imgtags[$i]));
+ }
+ }
} \ No newline at end of file
diff --git a/tests/codeigniter/database/DB_driver_test.php b/tests/codeigniter/database/DB_driver_test.php
index c04c42b09..26416d3fc 100644
--- a/tests/codeigniter/database/DB_driver_test.php
+++ b/tests/codeigniter/database/DB_driver_test.php
@@ -6,7 +6,7 @@ class DB_driver_test extends CI_TestCase {
{
$config = Mock_Database_DB::config(DB_DRIVER);
sscanf(DB_DRIVER, '%[^/]/', $driver_name);
- $driver = $this->$driver_name($config[DB_DRIVER]);
+ $driver = $this->{$driver_name}($config[DB_DRIVER]);
$this->assertTrue($driver->initialize());
}
diff --git a/tests/codeigniter/database/DB_test.php b/tests/codeigniter/database/DB_test.php
index d5a9369e6..dc4fae986 100644
--- a/tests/codeigniter/database/DB_test.php
+++ b/tests/codeigniter/database/DB_test.php
@@ -26,6 +26,14 @@ class DB_test extends CI_TestCase {
{
$config = Mock_Database_DB::config(DB_DRIVER);
$connection = new Mock_Database_DB($config);
+
+ // E_DEPRECATED notices thrown by mysql_connect(), mysql_pconnect()
+ // on PHP 5.5+ cause the tests to fail
+ if (DB_DRIVER === 'mysql' && version_compare(PHP_VERSION, '5.5', '>='))
+ {
+ error_reporting(E_ALL & ~E_DEPRECATED);
+ }
+
$db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER), TRUE);
$this->assertTrue($db instanceof CI_DB);
diff --git a/tests/mocks/core/input.php b/tests/mocks/core/input.php
index 0d1873849..40e27441f 100644
--- a/tests/mocks/core/input.php
+++ b/tests/mocks/core/input.php
@@ -38,4 +38,12 @@ class Mock_Core_Input extends CI_Input {
return FALSE;
}
+ public function __set($name, $value)
+ {
+ if ($name === 'ip_address')
+ {
+ $this->ip_address = $value;
+ }
+ }
+
} \ No newline at end of file