summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2017-03-06 13:39:28 +0100
committerAndrey Andreev <narf@devilix.net>2017-03-06 13:39:28 +0100
commit356bc66ebcd6a4d48c28fd119233e9d0bb12375f (patch)
treec47cac8609dc7f5fc19b7d5f5dd783990c7db9c0 /tests
parent618870f9f70148944599c1db64babec09e7424bc (diff)
Fix #5044; add unit tests for img() HTML helper
Diffstat (limited to 'tests')
-rw-r--r--tests/codeigniter/helpers/html_helper_test.php16
-rw-r--r--tests/mocks/ci_testconfig.php8
2 files changed, 19 insertions, 5 deletions
diff --git a/tests/codeigniter/helpers/html_helper_test.php b/tests/codeigniter/helpers/html_helper_test.php
index d66ad895c..3cf1016ec 100644
--- a/tests/codeigniter/helpers/html_helper_test.php
+++ b/tests/codeigniter/helpers/html_helper_test.php
@@ -40,6 +40,20 @@ class Html_helper_test extends CI_TestCase {
// ------------------------------------------------------------------------
+ public function test_img()
+ {
+ $this->ci_set_config('base_url', 'http://localhost/');
+ $this->assertEquals('<img src="http://localhost/test" alt="" />', img("test"));
+ $this->assertEquals('<img src="data:foo/bar,baz" alt="" />', img("data:foo/bar,baz"));
+ $this->assertEquals('<img src="http://localhost/data://foo" alt="" />', img("data://foo"));
+ $this->assertEquals('<img src="//foo.bar/baz" alt="" />', img("//foo.bar/baz"));
+ $this->assertEquals('<img src="http://foo.bar/baz" alt="" />', img("http://foo.bar/baz"));
+ $this->assertEquals('<img src="https://foo.bar/baz" alt="" />', img("https://foo.bar/baz"));
+ $this->assertEquals('<img src="ftp://foo.bar/baz" alt="" />', img("ftp://foo.bar/baz"));
+ }
+
+ // ------------------------------------------------------------------------
+
public function test_Ul()
{
$expect = <<<EOH
@@ -89,4 +103,4 @@ EOH;
}
-} \ No newline at end of file
+}
diff --git a/tests/mocks/ci_testconfig.php b/tests/mocks/ci_testconfig.php
index f80adc5d4..afdb71001 100644
--- a/tests/mocks/ci_testconfig.php
+++ b/tests/mocks/ci_testconfig.php
@@ -1,20 +1,20 @@
<?php
-class CI_TestConfig {
+class CI_TestConfig extends CI_Config {
public $config = array();
public $_config_paths = array(APPPATH);
public $loaded = array();
- public function item($key)
+ public function item($key, $index = '')
{
return isset($this->config[$key]) ? $this->config[$key] : FALSE;
}
- public function load($file, $arg2 = FALSE, $arg3 = FALSE)
+ public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
$this->loaded[] = $file;
return TRUE;
}
-} \ No newline at end of file
+}