summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codeigniter/helpers')
-rw-r--r--tests/codeigniter/helpers/array_helper_test.php8
-rw-r--r--tests/codeigniter/helpers/email_helper_test.php16
-rw-r--r--tests/codeigniter/helpers/html_helper_test.php19
-rw-r--r--tests/codeigniter/helpers/inflector_helper_test.php10
-rw-r--r--tests/codeigniter/helpers/number_helper_test.php13
-rw-r--r--tests/codeigniter/helpers/string_helper_test.php27
-rw-r--r--tests/codeigniter/helpers/text_helper_test.php26
-rw-r--r--tests/codeigniter/helpers/xml_helper_test.php13
8 files changed, 97 insertions, 35 deletions
diff --git a/tests/codeigniter/helpers/array_helper_test.php b/tests/codeigniter/helpers/array_helper_test.php
index fd306cee8..62559de83 100644
--- a/tests/codeigniter/helpers/array_helper_test.php
+++ b/tests/codeigniter/helpers/array_helper_test.php
@@ -6,7 +6,7 @@ require_once(BASEPATH.'helpers/array_helper.php');
class Array_helper_test extends CI_TestCase
{
- public function setUp()
+ public function set_up()
{
$this->my_array = array(
'foo' => 'bar',
@@ -18,7 +18,7 @@ class Array_helper_test extends CI_TestCase
// ------------------------------------------------------------------------
- public function testElementWithExistingItem()
+ public function test_element_with_existing_item()
{
$this->assertEquals(FALSE, element('testing', $this->my_array));
@@ -29,7 +29,7 @@ class Array_helper_test extends CI_TestCase
// ------------------------------------------------------------------------
- public function testRandomElement()
+ public function test_random_element()
{
// Send a string, not an array to random_element
$this->assertEquals('my string', random_element('my string'));
@@ -40,7 +40,7 @@ class Array_helper_test extends CI_TestCase
// ------------------------------------------------------------------------
- public function testElements()
+ public function test_elements()
{
$this->assertEquals(TRUE, is_array(elements('test', $this->my_array)));
$this->assertEquals(TRUE, is_array(elements('foo', $this->my_array)));
diff --git a/tests/codeigniter/helpers/email_helper_test.php b/tests/codeigniter/helpers/email_helper_test.php
new file mode 100644
index 000000000..7324e8109
--- /dev/null
+++ b/tests/codeigniter/helpers/email_helper_test.php
@@ -0,0 +1,16 @@
+<?php
+
+require_once(BASEPATH.'helpers/email_helper.php');
+
+class Email_helper_test extends CI_TestCase
+{
+
+ public function test_valid_email()
+ {
+ $this->assertEquals(FALSE, valid_email('test'));
+ $this->assertEquals(FALSE, valid_email('test@test@test.com'));
+ $this->assertEquals(TRUE, valid_email('test@test.com'));
+ $this->assertEquals(TRUE, valid_email('my.test@test.com'));
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/html_helper_test.php b/tests/codeigniter/helpers/html_helper_test.php
index 8c0e53301..706874f9e 100644
--- a/tests/codeigniter/helpers/html_helper_test.php
+++ b/tests/codeigniter/helpers/html_helper_test.php
@@ -4,14 +4,25 @@ require_once(BASEPATH.'helpers/html_helper.php');
class Html_helper_test extends CI_TestCase
{
- public function testHeading()
+
+ // ------------------------------------------------------------------------
+
+ public function test_br()
+ {
+ $this->assertEquals('<br /><br />', br(2));
+ }
+
+ // ------------------------------------------------------------------------
+
+ public function test_heading()
{
$this->assertEquals('<h1>foobar</h1>', heading('foobar'));
+ $this->assertEquals('<h2 class="bar">foobar</h2>', heading('foobar', 2, 'class="bar"'));
}
// ------------------------------------------------------------------------
- public function testUl()
+ public function test_Ul()
{
$expect = <<<EOH
<ul>
@@ -47,14 +58,14 @@ EOH;
// ------------------------------------------------------------------------
- public function testNBS()
+ public function test_NBS()
{
$this->assertEquals('&nbsp;&nbsp;&nbsp;', nbs(3));
}
// ------------------------------------------------------------------------
- public function testMeta()
+ public function test_meta()
{
$this->assertEquals("<meta name=\"test\" content=\"foo\" />\n", meta('test', 'foo'));
diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php
index e59875e4a..34bc34ebb 100644
--- a/tests/codeigniter/helpers/inflector_helper_test.php
+++ b/tests/codeigniter/helpers/inflector_helper_test.php
@@ -5,7 +5,7 @@ require_once(BASEPATH.'helpers/inflector_helper.php');
class Inflector_helper_test extends CI_TestCase {
- public function testSingular()
+ public function test_singular()
{
$strs = array(
'tellies' => 'telly',
@@ -22,7 +22,7 @@ class Inflector_helper_test extends CI_TestCase {
// --------------------------------------------------------------------
- public function testPlural()
+ public function test_plural()
{
$strs = array(
'telly' => 'tellies',
@@ -40,7 +40,7 @@ class Inflector_helper_test extends CI_TestCase {
// --------------------------------------------------------------------
- public function testCamelize()
+ public function test_camelize()
{
$strs = array(
'this is the string' => 'thisIsTheString',
@@ -57,7 +57,7 @@ class Inflector_helper_test extends CI_TestCase {
// --------------------------------------------------------------------
- public function testUnderscore()
+ public function test_underscore()
{
$strs = array(
'this is the string' => 'this_is_the_string',
@@ -74,7 +74,7 @@ class Inflector_helper_test extends CI_TestCase {
// --------------------------------------------------------------------
- public function testHumanize()
+ public function test_humanize()
{
$strs = array(
'this_is_the_string' => 'This Is The String',
diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php
new file mode 100644
index 000000000..02fc49c3d
--- /dev/null
+++ b/tests/codeigniter/helpers/number_helper_test.php
@@ -0,0 +1,13 @@
+<?php
+
+require_once(BASEPATH.'helpers/number_helper.php');
+
+class Number_helper_test extends CI_TestCase
+{
+
+ public function test_byte_format()
+ {
+ // $this->assertEquals('456 Bytes', byte_format(456));
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/string_helper_test.php b/tests/codeigniter/helpers/string_helper_test.php
index 00ba5dec7..5e0ee45de 100644
--- a/tests/codeigniter/helpers/string_helper_test.php
+++ b/tests/codeigniter/helpers/string_helper_test.php
@@ -4,7 +4,7 @@ require_once(BASEPATH.'helpers/string_helper.php');
class String_helper_test extends CI_TestCase
{
- public function testTrimSlashes()
+ public function test_trim_slashes()
{
$strs = array(
'//Slashes//\/' => 'Slashes//\\',
@@ -18,15 +18,8 @@ class String_helper_test extends CI_TestCase
}
// --------------------------------------------------------------------
-
- public function testStripSlashes()
- {
- $this->assertEquals("This is totally foo bar'd", trim_slashes("This is totally foo bar'd"));
- }
-
- // --------------------------------------------------------------------
- public function testStripQuotes()
+ public function test_strip_quotes()
{
$strs = array(
'"me oh my!"' => 'me oh my!',
@@ -41,7 +34,7 @@ class String_helper_test extends CI_TestCase
// --------------------------------------------------------------------
- public function testQuotesToEntities()
+ public function test_quotes_to_entities()
{
$strs = array(
'"me oh my!"' => '&quot;me oh my!&quot;',
@@ -56,7 +49,7 @@ class String_helper_test extends CI_TestCase
// --------------------------------------------------------------------
- public function testReduceDoubleSlashes()
+ public function test_reduce_double_slashes()
{
$strs = array(
'http://codeigniter.com' => 'http://codeigniter.com',
@@ -72,7 +65,7 @@ class String_helper_test extends CI_TestCase
// --------------------------------------------------------------------
- public function testReduceMultiples()
+ public function test_reduce_multiples()
{
$strs = array(
'Fred, Bill,, Joe, Jimmy' => 'Fred, Bill, Joe, Jimmy',
@@ -97,7 +90,7 @@ class String_helper_test extends CI_TestCase
// --------------------------------------------------------------------
- public function testRepeater()
+ public function test_repeater()
{
$strs = array(
'a' => 'aaaaaaaaaa',
@@ -114,4 +107,12 @@ class String_helper_test extends CI_TestCase
// --------------------------------------------------------------------
+
+ public function test_random_string()
+ {
+ $this->assertEquals(16, strlen(random_string('alnum', 16)));
+ $this->assertEquals(32, strlen(random_string('unique', 16)));
+ $this->assertInternalType('string', random_string('numeric', 16));
+ }
+
} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php
index 22c834bcf..a0866e638 100644
--- a/tests/codeigniter/helpers/text_helper_test.php
+++ b/tests/codeigniter/helpers/text_helper_test.php
@@ -6,14 +6,14 @@ class Text_helper_test extends CI_TestCase
{
private $_long_string;
- public function setUp()
+ public function set_up()
{
$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 testWordLimiter()
+ public function test_word_limiter()
{
$this->assertEquals('Once upon a time,&#8230;', word_limiter($this->_long_string, 4));
$this->assertEquals('Once upon a time,&hellip;', word_limiter($this->_long_string, 4, '&hellip;'));
@@ -22,7 +22,7 @@ class Text_helper_test extends CI_TestCase
// ------------------------------------------------------------------------
- public function testCharacterLimiter()
+ public function test_character_limiter()
{
$this->assertEquals('Once upon a time, a&#8230;', character_limiter($this->_long_string, 20));
$this->assertEquals('Once upon a time, a&hellip;', character_limiter($this->_long_string, 20, '&hellip;'));
@@ -32,7 +32,7 @@ class Text_helper_test extends CI_TestCase
// ------------------------------------------------------------------------
- public function testAsciiToEntities()
+ public function test_ascii_to_entities()
{
$strs = array(
'“‘ “test”' => '&#8220;&#8216; &#8220;test&#8221;',
@@ -47,7 +47,7 @@ class Text_helper_test extends CI_TestCase
// ------------------------------------------------------------------------
- public function testEntitiesToAscii()
+ public function test_entities_to_ascii()
{
$strs = array(
'&#8220;&#8216; &#8220;test&#8221;' => '“‘ “test”',
@@ -59,10 +59,18 @@ class Text_helper_test extends CI_TestCase
$this->assertEquals($expect, entities_to_ascii($str));
}
}
+
+ // ------------------------------------------------------------------------
+
+ function test_convert_accented_characters()
+ {
+ $this->assertEquals('AAAeEEEIIOOEUUUeY', convert_accented_characters('ÀÂÄÈÊËÎÏÔŒÙÛÜŸ'));
+ $this->assertEquals('a e i o u n ue', convert_accented_characters('á é í ó ú ñ ü'));
+ }
// ------------------------------------------------------------------------
- public function testCensoredWords()
+ public function test_censored_words()
{
$censored = array('boob', 'nerd', 'ass', 'fart');
@@ -86,7 +94,7 @@ class Text_helper_test extends CI_TestCase
// ------------------------------------------------------------------------
- public function testHighlightCode()
+ public function test_highlight_code()
{
$code = '<?php var_dump($this); ?>';
$expect = "<code><span style=\"color: #000000\">\n<span style=\"color: #0000BB\">&lt;?php&nbsp;var_dump</span><span style=\"color: #007700\">(</span><span style=\"color: #0000BB\">\$this</span><span style=\"color: #007700\">);&nbsp;</span><span style=\"color: #0000BB\">?&gt;&nbsp;</span>\n</span>\n</code>";
@@ -96,7 +104,7 @@ class Text_helper_test extends CI_TestCase
// ------------------------------------------------------------------------
- public function testHighlightPhrase()
+ public function test_highlight_phrase()
{
$strs = array(
'this is a phrase' => '<strong>this is</strong> a phrase',
@@ -114,7 +122,7 @@ class Text_helper_test extends CI_TestCase
// ------------------------------------------------------------------------
- public function testEllipsizing()
+ public function test_ellipsizing()
{
$strs = array(
'0' => array(
diff --git a/tests/codeigniter/helpers/xml_helper_test.php b/tests/codeigniter/helpers/xml_helper_test.php
new file mode 100644
index 000000000..49f49e166
--- /dev/null
+++ b/tests/codeigniter/helpers/xml_helper_test.php
@@ -0,0 +1,13 @@
+<?php
+
+require_once(BASEPATH.'helpers/xml_helper.php');
+
+class Xml_helper_test extends CI_TestCase
+{
+
+ public function test_xml_convert()
+ {
+ $this->assertEquals('&lt;tag&gt;my &amp; test &#45; &lt;/tag&gt;', xml_convert('<tag>my & test - </tag>'));
+ }
+
+} \ No newline at end of file