From 5ace440aa4dbd948191c37b67b01871b3a7593e9 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 14:52:15 +0200 Subject: change ellipsizing to ellipsize --- tests/codeigniter/helpers/text_helper_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index 584066b0c..a83c7e74d 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -122,7 +122,7 @@ class Text_helper_test extends CI_TestCase { // ------------------------------------------------------------------------ - public function test_ellipsizing() + public function test_ellipsize() { $strs = array( '0' => array( -- cgit v1.2.3-24-g4f1b From 0ef92f6fa4a40d4a689eee3ebd7eb7d632fe29c0 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 15:12:37 +0200 Subject: test for word_wrap() --- tests/codeigniter/helpers/text_helper_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index a83c7e74d..974247c4f 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -156,4 +156,12 @@ class Text_helper_test extends CI_TestCase { // ------------------------------------------------------------------------ + public function test_word_wrap() + { + $string = "Here is a simple string of text that will help us demonstrate this function."; + $word_wraped = word_wrap($string, 25); + preg_match_all("/\r\n|\n/", $word_wraped, $matches); + $this->assertEquals(count($matches[0]), 4); + } + } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 4221b980b66bbaebc23a0f9cc5dee7d649948e15 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 15:38:35 +0200 Subject: add test for word_wrap default charlim --- tests/codeigniter/helpers/text_helper_test.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index 974247c4f..d59b2743d 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -160,8 +160,17 @@ class Text_helper_test extends CI_TestCase { { $string = "Here is a simple string of text that will help us demonstrate this function."; $word_wraped = word_wrap($string, 25); - preg_match_all("/\r\n|\n/", $word_wraped, $matches); - $this->assertEquals(count($matches[0]), 4); + $this->assertEquals(substr_count($word_wraped, "\n"), 4); + } + + // ------------------------------------------------------------------------ + + public function test_default_word_wrap_charlim() + { + $string = "Here is a simple string of text that will help us demonstrate this function."; + $word_wraped = word_wrap($string); + $matches = preg_split("/\n/", $word_wraped, 1); + $this->assertEquals(strlen($matches[0]) - 1, 76); } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From bfaf50258b6f33961210ecc3df4ade2e0a4512b4 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 15:39:45 +0200 Subject: typo word_wraped -> word_wrapped --- tests/codeigniter/helpers/text_helper_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index d59b2743d..3bc83f050 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -159,8 +159,8 @@ class Text_helper_test extends CI_TestCase { public function test_word_wrap() { $string = "Here is a simple string of text that will help us demonstrate this function."; - $word_wraped = word_wrap($string, 25); - $this->assertEquals(substr_count($word_wraped, "\n"), 4); + $word_wrapped = word_wrap($string, 25); + $this->assertEquals(substr_count($word_wrapped, "\n"), 4); } // ------------------------------------------------------------------------ @@ -168,8 +168,8 @@ class Text_helper_test extends CI_TestCase { public function test_default_word_wrap_charlim() { $string = "Here is a simple string of text that will help us demonstrate this function."; - $word_wraped = word_wrap($string); - $matches = preg_split("/\n/", $word_wraped, 1); + $word_wrapped = word_wrap($string); + $matches = preg_split("/\n/", $word_wrapped, 1); $this->assertEquals(strlen($matches[0]) - 1, 76); } -- cgit v1.2.3-24-g4f1b From 385452c2ca1f9ce00668ca6d77c6fd0ad1ea4771 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 15:43:18 +0200 Subject: correction of the test and longer test string --- tests/codeigniter/helpers/text_helper_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index 3bc83f050..3c590538a 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -167,10 +167,10 @@ class Text_helper_test extends CI_TestCase { public function test_default_word_wrap_charlim() { - $string = "Here is a simple string of text that will help us demonstrate this function."; + $string = "Here is a longer string of text that will help us demonstrate the default charlim of this function."; $word_wrapped = word_wrap($string); - $matches = preg_split("/\n/", $word_wrapped, 1); - $this->assertEquals(strlen($matches[0]) - 1, 76); + $matches = preg_split("/\n/", $word_wrapped, 0); + $this->assertEquals(strlen($matches[0]), 73); } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 4215ddccd369ae8894c1031b97a344ae76eef5f6 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 15:58:28 +0200 Subject: remove regex in favor of strpos --- tests/codeigniter/helpers/text_helper_test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index 3c590538a..73e2b9429 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -169,8 +169,7 @@ class Text_helper_test extends CI_TestCase { { $string = "Here is a longer string of text that will help us demonstrate the default charlim of this function."; $word_wrapped = word_wrap($string); - $matches = preg_split("/\n/", $word_wrapped, 0); - $this->assertEquals(strlen($matches[0]), 73); + $this->assertEquals(strpos($word_wrapped, "\n"), 73); } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b