summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codeigniter')
-rw-r--r--tests/codeigniter/core/Loader_test.php8
-rw-r--r--tests/codeigniter/database/query_builder/count_test.php10
-rw-r--r--tests/codeigniter/helpers/date_helper_test.php2
-rw-r--r--tests/codeigniter/helpers/html_helper_test.php16
-rw-r--r--tests/codeigniter/libraries/Encryption_test.php16
-rw-r--r--tests/codeigniter/libraries/Form_validation_test.php2
6 files changed, 46 insertions, 8 deletions
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index c1c4997c4..8c5bb3021 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -99,7 +99,7 @@ class Loader_test extends CI_TestCase {
// Test reloading
unset($this->ci_obj->$name);
$this->assertInstanceOf('CI_Loader', $this->load->library($lib));
- $this->assertObjectNotHasAttribute($name, $this->ci_obj);
+ $this->assertObjectHasAttribute($name, $this->ci_obj);
// Create baseless library
$name = 'ext_baseless_lib';
@@ -295,8 +295,10 @@ class Loader_test extends CI_TestCase {
$output->expects($this->once())->method('append_output')->with($content.$value);
$this->ci_instance_var('output', $output);
- // Test view output
- $this->assertInstanceOf('CI_Loader', $this->load->view($view, array($var => $value)));
+ // Test view output and $vars as an object
+ $vars = new stdClass();
+ $vars->$var = $value;
+ $this->assertInstanceOf('CI_Loader', $this->load->view($view, $vars));
}
// --------------------------------------------------------------------
diff --git a/tests/codeigniter/database/query_builder/count_test.php b/tests/codeigniter/database/query_builder/count_test.php
index 90ac5283e..da312d866 100644
--- a/tests/codeigniter/database/query_builder/count_test.php
+++ b/tests/codeigniter/database/query_builder/count_test.php
@@ -35,4 +35,14 @@ class Count_test extends CI_TestCase {
$this->assertEquals(2, $this->db->like('name', 'ian')->count_all_results('job'));
}
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_count_all_results_limit()
+ {
+ $this->assertEquals(1, $this->db->like('name', 'ian')->limit(1)->count_all_results('job'));
+ }
+
} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php
index 8a3502280..b419418bf 100644
--- a/tests/codeigniter/helpers/date_helper_test.php
+++ b/tests/codeigniter/helpers/date_helper_test.php
@@ -296,7 +296,7 @@ class Date_helper_test extends CI_TestCase {
}
$this->assertArrayHasKey('UP3', timezones());
- $this->assertEquals(0, timezones('non_existant'));
+ $this->assertEquals(0, timezones('non_existent'));
}
// ------------------------------------------------------------------------
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/codeigniter/libraries/Encryption_test.php b/tests/codeigniter/libraries/Encryption_test.php
index 96e52ada8..99c5d4b9d 100644
--- a/tests/codeigniter/libraries/Encryption_test.php
+++ b/tests/codeigniter/libraries/Encryption_test.php
@@ -94,10 +94,22 @@ class Encryption_test extends CI_TestCase {
}
// Test default length, it must match the digest size
- $this->assertEquals(64, strlen($this->encryption->hkdf('foobar', 'sha512')));
+ $hkdf_result = $this->encryption->hkdf('foobar', 'sha512');
+ $this->assertEquals(
+ 64,
+ defined('MB_OVERLOAD_STRING')
+ ? mb_strlen($hkdf_result, '8bit')
+ : strlen($hkdf_result)
+ );
// Test maximum length (RFC5869 says that it must be up to 255 times the digest size)
- $this->assertEquals(12240, strlen($this->encryption->hkdf('foobar', 'sha384', NULL, 48 * 255)));
+ $hkdf_result = $this->encryption->hkdf('foobar', 'sha384', NULL, 48 * 255);
+ $this->assertEquals(
+ 12240,
+ defined('MB_OVERLOAD_STRING')
+ ? mb_strlen($hkdf_result, '8bit')
+ : strlen($hkdf_result)
+ );
$this->assertFalse($this->encryption->hkdf('foobar', 'sha224', NULL, 28 * 255 + 1));
// CI-specific test for an invalid digest
diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php
index 0815300e6..c9c404b43 100644
--- a/tests/codeigniter/libraries/Form_validation_test.php
+++ b/tests/codeigniter/libraries/Form_validation_test.php
@@ -270,7 +270,7 @@ class Form_validation_test extends CI_TestCase {
public function test_rule_valid_email()
{
$this->assertTrue($this->form_validation->valid_email('email@sample.com'));
-
+ $this->assertFalse($this->form_validation->valid_email('email@sample.com foo bar'));
$this->assertFalse($this->form_validation->valid_email('valid_email', '@sample.com'));
}