diff options
author | Andrey Andreev <narf@devilix.net> | 2018-01-13 12:57:11 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2018-01-13 12:57:11 +0100 |
commit | 02a0518e1c56ba3506f370362ac5ebdb8a138312 (patch) | |
tree | 8b4684192b403dcae17d298eb4fc9e7ab001acad /tests/codeigniter/helpers/text_helper_test.php | |
parent | f0b9735d5857e6c07c8f5824b13cff4828db3cfe (diff) |
[ci skip] 3.1.7 release
Diffstat (limited to 'tests/codeigniter/helpers/text_helper_test.php')
-rw-r--r-- | tests/codeigniter/helpers/text_helper_test.php | 174 |
1 files changed, 0 insertions, 174 deletions
diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php deleted file mode 100644 index 7a7dc0a12..000000000 --- a/tests/codeigniter/helpers/text_helper_test.php +++ /dev/null @@ -1,174 +0,0 @@ -<?php - -class Text_helper_test extends CI_TestCase { - - private $_long_string; - - public function set_up() - { - $this->helper('text'); - - $this->_long_string = 'Once upon a time, a framework had no tests. It sad. So some nice people began to write tests. The more time that went on, the happier it became. Everyone was happy.'; - } - - // ------------------------------------------------------------------------ - - public function test_word_limiter() - { - $this->assertEquals('Once upon a time,…', word_limiter($this->_long_string, 4)); - $this->assertEquals('Once upon a time,…', word_limiter($this->_long_string, 4, '…')); - $this->assertEquals('', word_limiter('', 4)); - } - - // ------------------------------------------------------------------------ - - public function test_character_limiter() - { - $this->assertEquals('Once upon a time, a…', character_limiter($this->_long_string, 20)); - $this->assertEquals('Once upon a time, a…', character_limiter($this->_long_string, 20, '…')); - $this->assertEquals('Short', character_limiter('Short', 20)); - $this->assertEquals('Short', character_limiter('Short', 5)); - } - - // ------------------------------------------------------------------------ - - public function test_ascii_to_entities() - { - $strs = array( - '“‘ “test”' => '“‘ “test”', - '†¥¨ˆøåß∂ƒ©˙∆˚¬' => '†¥¨ˆøåß∂ƒ©˙∆˚¬' - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, ascii_to_entities($str)); - } - } - - // ------------------------------------------------------------------------ - - public function test_entities_to_ascii() - { - $strs = array( - '“‘ “test”' => '“‘ “test”', - '†¥¨ˆøåß∂ƒ©˙∆˚¬' => '†¥¨ˆøåß∂ƒ©˙∆˚¬' - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, entities_to_ascii($str)); - } - } - - // ------------------------------------------------------------------------ - - public function test_convert_accented_characters() - { - $this->ci_vfs_clone('application/config/foreign_chars.php'); - $this->assertEquals('AAAeEEEIIOOEUUUeY', convert_accented_characters('ÀÂÄÈÊËÎÏÔŒÙÛÜŸ')); - $this->assertEquals('a e i o u n ue', convert_accented_characters('á é í ó ú ñ ü')); - } - - // ------------------------------------------------------------------------ - - public function test_censored_words() - { - $censored = array('boob', 'nerd', 'ass', 'fart'); - - $strs = array( - 'Ted bobbled the ball' => 'Ted bobbled the ball', - 'Jake is a nerdo' => 'Jake is a nerdo', - 'The borg will assimilate you' => 'The borg will assimilate you', - 'Did Mary Fart?' => 'Did Mary $*#?', - 'Jake is really a boob' => 'Jake is really a $*#' - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, word_censor($str, $censored, '$*#')); - } - - // test censored words being sent as a string - $this->assertEquals('test', word_censor('test', 'test')); - } - - // ------------------------------------------------------------------------ - - public function test_highlight_code() - { - $expect = "<code><span style=\"color: #000000\">\n<span style=\"color: #0000BB\"><?php var_dump</span><span style=\"color: #007700\">(</span><span style=\"color: #0000BB\">\$this</span><span style=\"color: #007700\">); </span><span style=\"color: #0000BB\">?> </span>\n</span>\n</code>"; - - $this->assertEquals($expect, highlight_code('<?php var_dump($this); ?>')); - } - - // ------------------------------------------------------------------------ - - public function test_highlight_phrase() - { - $strs = array( - 'this is a phrase' => '<mark>this is</mark> a phrase', - 'this is another' => '<mark>this is</mark> another', - 'Gimme a test, Sally' => 'Gimme a test, Sally', - 'Or tell me what this is' => 'Or tell me what <mark>this is</mark>', - '' => '' - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, highlight_phrase($str, 'this is')); - } - - $this->assertEquals('<strong>this is</strong> a strong test', highlight_phrase('this is a strong test', 'this is', '<strong>', '</strong>')); - } - - // ------------------------------------------------------------------------ - - public function test_ellipsize() - { - $strs = array( - '0' => array( - 'this is my string' => '… my string', - "here's another one" => '…nother one', - 'this one is just a bit longer' => '…bit longer', - 'short' => 'short' - ), - '.5' => array( - 'this is my string' => 'this …tring', - "here's another one" => "here'…r one", - 'this one is just a bit longer' => 'this …onger', - 'short' => 'short' - ), - '1' => array( - 'this is my string' => 'this is my…', - "here's another one" => "here's ano…", - 'this one is just a bit longer' => 'this one i…', - 'short' => 'short' - ), - ); - - foreach ($strs as $pos => $s) - { - foreach ($s as $str => $expect) - { - $this->assertEquals($expect, ellipsize($str, 10, $pos)); - } - } - } - - // ------------------------------------------------------------------------ - - public function test_word_wrap() - { - $string = 'Here is a simple string of text that will help us demonstrate this function.'; - $this->assertEquals(substr_count(word_wrap($string, 25), "\n"), 4); - } - - // ------------------------------------------------------------------------ - - public function test_default_word_wrap_charlim() - { - $string = "Here is a longer string of text that will help us demonstrate the default charlim of this function."; - $this->assertEquals(strpos(word_wrap($string), "\n"), 73); - } - -}
\ No newline at end of file |