From fa986fe738363069d8ae331f0ae331521cd895d3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 10 Jan 2017 12:22:05 +0200 Subject: Add a testcase and changelog entry for #4975 --- tests/codeigniter/core/Loader_test.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index c1c4997c4..241c415b3 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -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)); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 71d8f72ffc48a7f46747b3b6b1a554533cc1cbc5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 17 Jan 2017 12:01:00 +0200 Subject: [ci skip] Merge pull request #4986 from ka7/feature/spelling Spelling fixes in comment blocks and docs --- tests/codeigniter/helpers/date_helper_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') 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')); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From f565212c5aa07a8016394a3bc66874be83c73d4d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 19 Jan 2017 15:17:00 +0200 Subject: Fix byte-safety issues & actually test for them --- tests/codeigniter/libraries/Encryption_test.php | 16 ++++++++++++++-- tests/phpunit.xml | 10 ++++------ 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'tests') 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/phpunit.xml b/tests/phpunit.xml index 96c3af9bb..875198c4e 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -17,10 +17,8 @@ - - PEAR_INSTALL_DIR - PHP_LIBDIR - ../vendor - + + ../system/ + - \ No newline at end of file + -- cgit v1.2.3-24-g4f1b From 356bc66ebcd6a4d48c28fd119233e9d0bb12375f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 6 Mar 2017 14:39:28 +0200 Subject: Fix #5044; add unit tests for img() HTML helper --- tests/codeigniter/helpers/html_helper_test.php | 16 +++++++++++++++- tests/mocks/ci_testconfig.php | 8 ++++---- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'tests') 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("test")); + $this->assertEquals('', img("data:foo/bar,baz")); + $this->assertEquals('', img("data://foo")); + $this->assertEquals('', img("//foo.bar/baz")); + $this->assertEquals('', img("http://foo.bar/baz")); + $this->assertEquals('', img("https://foo.bar/baz")); + $this->assertEquals('', img("ftp://foo.bar/baz")); + } + + // ------------------------------------------------------------------------ + public function test_Ul() { $expect = <<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 +} -- cgit v1.2.3-24-g4f1b From 2c1b3d9694e570c45ac82fcefbb51c965c6ea8a8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 15 Jun 2017 14:22:49 +0300 Subject: Merge pull request #5155 from tianhe1986/develop_count_ignore_limit Fix CI_DB_query_builder::count_all_results() returning wrong count with LIMIT/OFFSET --- tests/codeigniter/database/query_builder/count_test.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') 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 -- cgit v1.2.3-24-g4f1b From ed1a0453a9372e88058169f2028c9a2140318961 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 19 Jun 2017 08:25:23 +0300 Subject: [ci skip] Fix a bug in FV valid_email() --- tests/codeigniter/libraries/Form_validation_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') 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')); } -- cgit v1.2.3-24-g4f1b From be0280d02a408a8b4aeb6aee10d9dd936f978ce2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 28 Jun 2017 11:49:01 +0300 Subject: #5164 fix for stock libraries --- tests/codeigniter/core/Loader_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 241c415b3..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'; -- cgit v1.2.3-24-g4f1b