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/codeigniter/helpers') 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/codeigniter/helpers') 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/codeigniter/helpers') 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/codeigniter/helpers') 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/codeigniter/helpers') 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/codeigniter/helpers') 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 From 1b60fda70ff1e1801c133575c530ef0a5a450029 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 9 Jun 2012 21:07:40 +0300 Subject: Modified date helper tests for better accuracy --- tests/codeigniter/helpers/date_helper_test.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index 17d1ef21e..df03fe32c 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -16,13 +16,11 @@ class Date_helper_test extends CI_TestCase { $config->expects($this->any()) ->method('item') ->will($this->returnValue('local')); - + // Add the stub to our test instance $this->ci_instance_var('config', $config); - $expected = time(); - $test = now(); - $this->assertEquals($expected, $test); + $this->assertEquals(time(), now()); } // ------------------------------------------------------------------------ @@ -34,7 +32,7 @@ class Date_helper_test extends CI_TestCase { $config->expects($this->any()) ->method('item') ->will($this->returnValue('gmt')); - + // Add the stub to our stdClass $this->ci_instance_var('config', $config); @@ -204,8 +202,7 @@ class Date_helper_test extends CI_TestCase { public function test_mysql_to_unix() { $time = time(); - $this->assertEquals($time, - mysql_to_unix(date("Y-m-d H:i:s", $time))); + $this->assertEquals($time, mysql_to_unix(date("Y-m-d H:i:s", $time))); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From 99b782d8a3d92c4703a059cbd62e2f1e6fea689c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 9 Jun 2012 22:24:46 +0300 Subject: Cleanup and optimize helper tests for speed --- tests/codeigniter/helpers/array_helper_test.php | 22 ++-- tests/codeigniter/helpers/date_helper_test.php | 127 +++++++++--------- .../codeigniter/helpers/directory_helper_test.php | 47 ++++--- tests/codeigniter/helpers/email_helper_test.php | 2 +- tests/codeigniter/helpers/file_helper_test.php | 143 ++++++++++----------- tests/codeigniter/helpers/form_helper_test.php | 112 ++++++++-------- tests/codeigniter/helpers/html_helper_test.php | 28 ++-- .../codeigniter/helpers/inflector_helper_test.php | 31 ++--- tests/codeigniter/helpers/number_helper_test.php | 35 +++-- tests/codeigniter/helpers/path_helper_test.php | 5 +- tests/codeigniter/helpers/string_helper_test.php | 9 +- tests/codeigniter/helpers/text_helper_test.php | 70 +++++----- tests/codeigniter/helpers/url_helper_test.php | 1 + tests/codeigniter/helpers/xml_helper_test.php | 4 +- 14 files changed, 317 insertions(+), 319 deletions(-) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/array_helper_test.php b/tests/codeigniter/helpers/array_helper_test.php index 9cd15960f..ba46e86f9 100644 --- a/tests/codeigniter/helpers/array_helper_test.php +++ b/tests/codeigniter/helpers/array_helper_test.php @@ -1,7 +1,7 @@ helper('array'); @@ -13,31 +13,31 @@ class Array_helper_test extends CI_TestCase { 'herb' => 'cook' ); } - + // ------------------------------------------------------------------------ - + public function test_element_with_existing_item() - { + { $this->assertEquals(FALSE, element('testing', $this->my_array)); - + $this->assertEquals('not set', element('testing', $this->my_array, 'not set')); - + $this->assertEquals('bar', element('foo', $this->my_array)); } - - // ------------------------------------------------------------------------ + + // ------------------------------------------------------------------------ public function test_random_element() { // Send a string, not an array to random_element $this->assertEquals('my string', random_element('my string')); - + // Test sending an array $this->assertEquals(TRUE, in_array(random_element($this->my_array), $this->my_array)); } - // ------------------------------------------------------------------------ - + // ------------------------------------------------------------------------ + public function test_elements() { $this->assertEquals(TRUE, is_array(elements('test', $this->my_array))); diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index df03fe32c..4b747b864 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -5,6 +5,8 @@ class Date_helper_test extends CI_TestCase { public function set_up() { $this->helper('date'); + + $this->time = time(); } // ------------------------------------------------------------------------ @@ -37,119 +39,120 @@ class Date_helper_test extends CI_TestCase { $this->ci_instance_var('config', $config); $t = time(); - $expected = mktime(gmdate("H", $t), gmdate("i", $t), gmdate("s", $t), gmdate("m", $t), gmdate("d", $t), gmdate("Y", $t)); - $test = now(); - $this->assertEquals($expected, $test); + $this->assertEquals( + mktime(gmdate('H', $t), gmdate('i', $t), gmdate('s', $t), gmdate('m', $t), gmdate('d', $t), gmdate('Y', $t)), + now() + ); } // ------------------------------------------------------------------------ public function test_mdate() { - $time = time(); - $expected = date("Y-m-d - h:i a", $time); - $test = mdate("%Y-%m-%d - %h:%i %a", $time); - $this->assertEquals($expected, $test); + $this->assertEquals( + date('Y-m-d - h:i a', $this->time), + mdate('%Y-%m-%d - %h:%i %a', $this->time) + ); } // ------------------------------------------------------------------------ public function test_standard_date_rfc822() { - $time = time(); - $format = 'DATE_RFC822'; - $expected = date("D, d M y H:i:s O", $time); - $this->assertEquals($expected, standard_date($format, $time)); + $this->assertEquals( + date('D, d M y H:i:s O', $this->time), + standard_date('DATE_RFC822', $this->time) + ); } // ------------------------------------------------------------------------ public function test_standard_date_atom() { - $time = time(); - $format = 'DATE_ATOM'; - $expected = date("Y-m-d\TH:i:sO", $time); - $this->assertEquals($expected, standard_date($format, $time)); + $this->assertEquals( + date("Y-m-d\TH:i:sO", $this->time), + standard_date('DATE_ATOM', $this->time) + ); } // ------------------------------------------------------------------------ public function test_standard_date_cookie() { - $time = time(); - $format = 'DATE_COOKIE'; - $expected = date("l, d-M-y H:i:s \U\T\C", $time); - $this->assertEquals($expected, standard_date($format, $time)); + $this->assertEquals( + date("l, d-M-y H:i:s \U\T\C", $this->time), + standard_date('DATE_COOKIE', $this->time) + ); } // ------------------------------------------------------------------------ public function test_standard_date_iso8601() { - $time = time(); - $format = 'DATE_ISO8601'; - $expected = date("Y-m-d\TH:i:sO", $time); - $this->assertEquals($expected, standard_date($format, $time)); + $this->assertEquals( + date("Y-m-d\TH:i:sO", $this->time), + standard_date('DATE_ISO8601', $this->time) + ); } // ------------------------------------------------------------------------ public function test_standard_date_rfc850() { - $time = time(); - $format = 'DATE_RFC850'; - $expected = date("l, d-M-y H:i:s \U\T\C", $time); - $this->assertEquals($expected, standard_date($format, $time)); + $this->assertEquals( + date("l, d-M-y H:i:s \U\T\C", $this->time), + standard_date('DATE_RFC850', $this->time) + ); } // ------------------------------------------------------------------------ public function test_standard_date_rfc1036() { - $time = time(); - $format = 'DATE_RFC1036'; - $expected = date("D, d M y H:i:s O", $time); - $this->assertEquals($expected, standard_date($format, $time)); + $this->assertEquals( + date('D, d M y H:i:s O', $this->time), + standard_date('DATE_RFC1036', $this->time) + ); } // ------------------------------------------------------------------------ public function test_standard_date_rfc1123() { - $time = time(); - $format = 'DATE_RFC1123'; - $expected = date("D, d M Y H:i:s O", $time); - $this->assertEquals($expected, standard_date($format, $time)); + $this->assertEquals( + date('D, d M Y H:i:s O', $this->time), + standard_date('DATE_RFC1123', $this->time) + ); } // ------------------------------------------------------------------------ public function test_standard_date_rfc2822() { - $time = time(); - $format = 'DATE_RFC2822'; - $expected = date("D, d M Y H:i:s O", $time); - $this->assertEquals($expected, standard_date($format, $time)); + $this->assertEquals( + date('D, d M Y H:i:s O', $this->time), + standard_date('DATE_RFC2822', $this->time) + ); } // ------------------------------------------------------------------------ public function test_standard_date_rss() { - $time = time(); - $format = 'DATE_RSS'; - $expected = date("D, d M Y H:i:s O", $time); - $this->assertEquals($expected, standard_date($format, $time)); + $this->assertEquals( + date('D, d M Y H:i:s O', $this->time), + standard_date('DATE_RSS', $this->time) + ); } // ------------------------------------------------------------------------ public function test_standard_date_w3c() { - $time = time(); - $format = 'DATE_W3C'; - $expected = date("Y-m-d\TH:i:sO", $time); - $this->assertEquals($expected, standard_date($format, $time)); + $this->assertEquals( + date("Y-m-d\TH:i:sO", $this->time), + standard_date('DATE_W3C', $this->time) + ); } // ------------------------------------------------------------------------ @@ -181,38 +184,36 @@ class Date_helper_test extends CI_TestCase { public function test_local_to_gmt() { - $t = time(); - $expected = mktime(gmdate("H", $t), gmdate("i", $t), gmdate("s", $t), gmdate("m", $t), gmdate("d", $t), gmdate("Y", $t)); - $this->assertEquals($expected, local_to_gmt($t)); + $this->assertEquals( + mktime( + gmdate('H', $this->time), gmdate('i', $this->time), gmdate('s', $this->time), + gmdate('m', $this->time), gmdate('d', $this->time), gmdate('Y', $this->time) + ), + local_to_gmt($this->time) + ); } // ------------------------------------------------------------------------ public function test_gmt_to_local() { - $timestamp = '1140153693'; - $timezone = 'UM8'; - $daylight_saving = TRUE; - - $this->assertEquals(1140128493, gmt_to_local($timestamp, $timezone, $daylight_saving)); + $this->assertEquals(1140128493, gmt_to_local('1140153693', 'UM8', TRUE)); } // ------------------------------------------------------------------------ public function test_mysql_to_unix() { - $time = time(); - $this->assertEquals($time, mysql_to_unix(date("Y-m-d H:i:s", $time))); + $this->assertEquals($this->time, mysql_to_unix(date('Y-m-d H:i:s', $this->time))); } // ------------------------------------------------------------------------ public function test_unix_to_human() { - $time = time(); - $this->assertEquals(date("Y-m-d h:i A", $time), unix_to_human($time)); - $this->assertEquals(date("Y-m-d h:i:s A", $time), unix_to_human($time, TRUE, 'us')); - $this->assertEquals(date("Y-m-d H:i:s", $time), unix_to_human($time, TRUE, 'eu')); + $this->assertEquals(date('Y-m-d h:i A', $this->time), unix_to_human($this->time)); + $this->assertEquals(date('Y-m-d h:i:s A', $this->time), unix_to_human($this->time, TRUE, 'us')); + $this->assertEquals(date('Y-m-d H:i:s', $this->time), unix_to_human($this->time, TRUE, 'eu')); } // ------------------------------------------------------------------------ @@ -220,8 +221,7 @@ class Date_helper_test extends CI_TestCase { public function test_human_to_unix() { $date = '2000-12-31 10:00:00 PM'; - $expected = strtotime($date); - $this->assertEquals($expected, human_to_unix($date)); + $this->assertEquals(strtotime($date), human_to_unix($date)); $this->assertFalse(human_to_unix()); } @@ -280,6 +280,7 @@ class Date_helper_test extends CI_TestCase { $this->assertArrayHasKey('UP3', timezones()); $this->assertEquals(0, timezones('non_existant')); } + } /* End of file date_helper_test.php */ \ No newline at end of file diff --git a/tests/codeigniter/helpers/directory_helper_test.php b/tests/codeigniter/helpers/directory_helper_test.php index 3937d2913..176ff1d78 100644 --- a/tests/codeigniter/helpers/directory_helper_test.php +++ b/tests/codeigniter/helpers/directory_helper_test.php @@ -1,41 +1,50 @@ helper('directory'); vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('testDir')); - + $this->_test_dir = vfsStreamWrapper::getRoot(); - } - + } + public function test_directory_map() { - $structure = array('libraries' => array('benchmark.html' => '', 'database' => - array('active_record.html' => '', 'binds.html' => ''), 'email.html' => '', '.hiddenfile.txt' => '')); - + $structure = array( + 'libraries' => array( + 'benchmark.html' => '', + 'database' => array('active_record.html' => '', 'binds.html' => ''), + 'email.html' => '', + '.hiddenfile.txt' => '' + ) + ); + vfsStream::create($structure, $this->_test_dir); // test default recursive behavior - $expected = array('libraries' => array('benchmark.html', 'database' => - array('active_record.html', 'binds.html'), 'email.html')); - - $this->assertEquals($expected, directory_map(vfsStream::url('testDir'))); + $expected = array( + 'libraries' => array( + 'benchmark.html', + 'database' => array('active_record.html', 'binds.html'), + 'email.html' + ) + ); - // test recursion depth behavior - $expected = array('libraries'); - - $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), 1)); + $this->assertEquals($expected, directory_map(vfsStream::url('testDir'))); // test detection of hidden files - $expected = array('libraries' => array('benchmark.html', 'database' => - array('active_record.html', 'binds.html'), 'email.html', '.hiddenfile.txt')); - + $expected['libraries'][] = '.hiddenfile.txt'; + $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), FALSE, TRUE)); - } + + // test recursion depth behavior + $this->assertEquals(array('libraries'), directory_map(vfsStream::url('testDir'), 1)); + } + } /* End of file directory_helper_test.php */ \ No newline at end of file diff --git a/tests/codeigniter/helpers/email_helper_test.php b/tests/codeigniter/helpers/email_helper_test.php index a01f3d5af..fea452f5f 100644 --- a/tests/codeigniter/helpers/email_helper_test.php +++ b/tests/codeigniter/helpers/email_helper_test.php @@ -14,5 +14,5 @@ class Email_helper_test extends CI_TestCase { $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/file_helper_test.php b/tests/codeigniter/helpers/file_helper_test.php index 4b9c29485..9b03da9d7 100644 --- a/tests/codeigniter/helpers/file_helper_test.php +++ b/tests/codeigniter/helpers/file_helper_test.php @@ -5,24 +5,23 @@ class File_helper_Test extends CI_TestCase { public function set_up() { $this->helper('file'); - + vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('testDir')); - + $this->_test_dir = vfsStreamWrapper::getRoot(); } - + // -------------------------------------------------------------------- - + public function test_read_file() { $this->assertFalse(read_file('does_not_exist')); - + $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - - $file = vfsStream::newFile('my_file.txt')->withContent($content) - ->at($this->_test_dir); - + + $file = vfsStream::newFile('my_file.txt')->withContent($content)->at($this->_test_dir); + $this->assertEquals($content, read_file(vfsStream::url('my_file.txt'))); } @@ -31,126 +30,124 @@ class File_helper_Test extends CI_TestCase { public function test_octal_permissions() { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - + $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content) - ->lastModified(time() - 86400) - ->at($this->_test_dir); - - $this->assertEquals('777', octal_permissions($file->getPermissions())); + ->lastModified(time() - 86400) + ->at($this->_test_dir); + + $this->assertEquals('777', octal_permissions($file->getPermissions())); } - // -------------------------------------------------------------------- - + // -------------------------------------------------------------------- + /** * More tests should happen here, since I'm not hitting the whole function. */ public function test_symbolic_permissions() { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - + $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content) - ->lastModified(time() - 86400) - ->at($this->_test_dir); - - $this->assertEquals('urwxrwxrwx', symbolic_permissions($file->getPermissions())); + ->lastModified(time() - 86400) + ->at($this->_test_dir); + + $this->assertEquals('urwxrwxrwx', symbolic_permissions($file->getPermissions())); } - // -------------------------------------------------------------------- - + // -------------------------------------------------------------------- + public function test_get_mime_by_extension() { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - + $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content) - ->lastModified(time() - 86400) - ->at($this->_test_dir); - - $this->assertEquals('text/plain', - get_mime_by_extension(vfsStream::url('my_file.txt'))); - - // Test a mime with an array, such as png + ->lastModified(time() - 86400) + ->at($this->_test_dir); + + $this->assertEquals('text/plain', get_mime_by_extension(vfsStream::url('my_file.txt'))); + + // Test a mime with an array, such as png $file = vfsStream::newFile('foo.png')->at($this->_test_dir); - - $this->assertEquals('image/png', get_mime_by_extension(vfsStream::url('foo.png'))); - + + $this->assertEquals('image/png', get_mime_by_extension(vfsStream::url('foo.png'))); + // Test a file not in the mimes array $file = vfsStream::newFile('foo.blarfengar')->at($this->_test_dir); - + $this->assertFalse(get_mime_by_extension(vfsStream::url('foo.blarfengar'))); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- public function test_get_file_info() { // Test Bad File $this->assertFalse(get_file_info('i_am_bad_boo')); - + // Test the rest - + // First pass in an array $vals = array( 'name', 'server_path', 'size', 'date', - 'readable', 'writable', 'executable', 'fileperms' + 'readable', 'writable', 'executable', 'fileperms' ); - + $this->_test_get_file_info($vals); // Test passing in vals as a string. - $vals = 'name, server_path, size, date, readable, writable, executable, fileperms'; - $this->_test_get_file_info($vals); + $this->_test_get_file_info(implode(', ', $vals)); } - + private function _test_get_file_info($vals) { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; $last_modified = time() - 86400; - + $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content) - ->lastModified($last_modified) - ->at($this->_test_dir); - + ->lastModified($last_modified) + ->at($this->_test_dir); + $ret_values = array( - 'name' => 'my_file.txt', - 'server_path' => 'vfs://my_file.txt', - 'size' => 57, - 'date' => $last_modified, + 'name' => 'my_file.txt', + 'server_path' => 'vfs://my_file.txt', + 'size' => 57, + 'date' => $last_modified, 'readable' => TRUE, - 'writable' => TRUE, - 'executable' => TRUE, + 'writable' => TRUE, + 'executable' => TRUE, 'fileperms' => 33279 ); - + $info = get_file_info(vfsStream::url('my_file.txt'), $vals); - + foreach ($info as $k => $v) { $this->assertEquals($ret_values[$k], $v); } } - - // -------------------------------------------------------------------- + + // -------------------------------------------------------------------- // Skipping for now, as it's not implemented in vfsStreamWrapper // flock(): vfsStreamWrapper::stream_lock is not implemented! - + // public function test_write_file() // { - // if ( ! defined('FOPEN_WRITE_CREATE_DESTRUCTIVE')) - // { - // define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); - // } - // - // $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - // - // $file = vfsStream::newFile('write.txt', 0777)->withContent('') - // ->lastModified(time() - 86400) - // ->at($this->_test_dir); - // - // $this->assertTrue(write_file(vfsStream::url('write.txt'), $content)); - // + // if ( ! defined('FOPEN_WRITE_CREATE_DESTRUCTIVE')) + // { + // define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); + // } + // + // $content = 'Jack and Jill went up the mountain to fight a billy goat.'; + // + // $file = vfsStream::newFile('write.txt', 0777)->withContent('') + // ->lastModified(time() - 86400) + // ->at($this->_test_dir); + // + // $this->assertTrue(write_file(vfsStream::url('write.txt'), $content)); + // // } - // -------------------------------------------------------------------- - + // -------------------------------------------------------------------- + } \ No newline at end of file diff --git a/tests/codeigniter/helpers/form_helper_test.php b/tests/codeigniter/helpers/form_helper_test.php index 80bace9d1..1a30ed993 100644 --- a/tests/codeigniter/helpers/form_helper_test.php +++ b/tests/codeigniter/helpers/form_helper_test.php @@ -3,26 +3,26 @@ require BASEPATH . 'core/Common.php'; require BASEPATH . 'helpers/form_helper.php'; -class Form_helper_test extends CI_TestCase +class Form_helper_test extends CI_TestCase { public function test_form_hidden() - { + { $expected = << EOH; - + $this->assertEquals($expected, form_hidden('username', 'johndoe')); } - + public function test_form_input() { $expected = << EOH; - + $data = array( 'name' => 'username', 'id' => 'username', @@ -34,37 +34,37 @@ EOH; $this->assertEquals($expected, form_input($data)); } - + public function test_form_password() - { + { $expected = << EOH; - + $this->assertEquals($expected, form_password('password')); } - + public function test_form_upload() - { + { $expected = << EOH; - + $this->assertEquals($expected, form_upload('attachment')); } - + public function test_form_textarea() - { + { $expected = <<Notes EOH; - + $this->assertEquals($expected, form_textarea('notes', 'Notes')); } - + public function test_form_dropdown() { $expected = << EOH; - + $options = array( - 'small' => 'Small Shirt', - 'med' => 'Medium Shirt', - 'large' => 'Large Shirt', - 'xlarge' => 'Extra Large Shirt', + 'small' => 'Small Shirt', + 'med' => 'Medium Shirt', + 'large' => 'Large Shirt', + 'xlarge' => 'Extra Large Shirt', ); - + $this->assertEquals($expected, form_dropdown('shirts', $options, 'large')); - + $expected = << @@ -95,22 +95,22 @@ EOH; EOH; - + $shirts_on_sale = array('small', 'large'); - + $this->assertEquals($expected, form_dropdown('shirts', $options, $shirts_on_sale)); - + $options = array( 'Swedish Cars' => array( - 'volvo' => 'Volvo', - 'saab' => 'Saab' + 'volvo' => 'Volvo', + 'saab' => 'Saab' ), 'German Cars' => array( - 'mercedes' => 'Mercedes', - 'audi' => 'Audi' + 'mercedes' => 'Mercedes', + 'audi' => 'Audi' ) ); - + $expected = << @@ -124,13 +124,10 @@ EOH; EOH; - - $cars_on_sale = array('volvo', 'audi'); - - $this->assertEquals($expected, form_dropdown('cars', $options, $cars_on_sale)); - + + $this->assertEquals($expected, form_dropdown('cars', $options, array('volvo', 'audi'))); } - + public function test_form_multiselect() { $expected = << EOH; - + $options = array( - 'small' => 'Small Shirt', - 'med' => 'Medium Shirt', - 'large' => 'Large Shirt', - 'xlarge' => 'Extra Large Shirt', - ); - + 'small' => 'Small Shirt', + 'med' => 'Medium Shirt', + 'large' => 'Large Shirt', + 'xlarge' => 'Extra Large Shirt', + ); + $this->assertEquals($expected, form_multiselect('shirts[]', $options, array('med', 'large'))); } - + public function test_form_fieldset() { $expected = <<Address Information EOH; - + $this->assertEquals($expected, form_fieldset('Address Information')); } @@ -169,10 +166,10 @@ EOH; $expected = << EOH; - + $this->assertEquals($expected, form_fieldset_close('')); } - + public function test_form_checkbox() { $expected = <<assertEquals($expected, form_checkbox('newsletter', 'accept', TRUE)); } - + public function test_form_radio() { $expected = <<assertEquals($expected, form_radio('newsletter', 'accept', TRUE)); } - + public function test_form_submit() { $expected = <<assertEquals($expected, form_submit('mysubmit', 'Submit Post!')); } - + public function test_form_label() { $expected = <<assertEquals($expected, form_label('What is your Name', 'username')); } - + public function test_form_reset() { $expected = <<assertEquals($expected, form_reset('myreset', 'Reset')); } - + public function test_form_button() { $expected = <<assertEquals($expected, form_button('name','content')); + $this->assertEquals($expected, form_button('name', 'content')); } - + public function test_form_close() { $expected = <<assertEquals($expected, form_close('')); } - + public function test_form_prep() { - $expected = "Here is a string containing "quoted" text."; - + $expected = 'Here is a string containing "quoted" text.'; + $this->assertEquals($expected, form_prep('Here is a string containing "quoted" text.')); } + } /* End of file form_helper_test.php */ \ 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 28974b0f8..9a7bb48bf 100644 --- a/tests/codeigniter/helpers/html_helper_test.php +++ b/tests/codeigniter/helpers/html_helper_test.php @@ -6,16 +6,16 @@ class Html_helper_test extends CI_TestCase { { $this->helper('html'); } - + // ------------------------------------------------------------------------ - + public function test_br() { $this->assertEquals('

', br(2)); } - + // ------------------------------------------------------------------------ - + public function test_heading() { $this->assertEquals('

foobar

', heading('foobar')); @@ -23,7 +23,7 @@ class Html_helper_test extends CI_TestCase { } // ------------------------------------------------------------------------ - + public function test_Ul() { $expect = <<assertEquals($expect, ul($list)); + $this->assertEquals(ltrim($expect), ul($list)); $expect = << @@ -51,13 +49,11 @@ EOH; $expect = ltrim($expect); - $list = array('foo', 'bar'); - $this->assertEquals($expect, ul($list, 'class="test"')); $this->assertEquals($expect, ul($list, array('class' => 'test'))); } - + // ------------------------------------------------------------------------ public function test_NBS() @@ -66,15 +62,15 @@ EOH; } // ------------------------------------------------------------------------ - + public function test_meta() { $this->assertEquals("\n", meta('test', 'foo')); - + $expect = "\n"; - + $this->assertEquals($expect, meta(array('name' => 'foo'))); - + } - + } \ No newline at end of file diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php index 9e9478711..f3b0ebbe8 100644 --- a/tests/codeigniter/helpers/inflector_helper_test.php +++ b/tests/codeigniter/helpers/inflector_helper_test.php @@ -1,12 +1,12 @@ helper('inflector'); } - + public function test_singular() { $strs = array( @@ -16,15 +16,15 @@ class Inflector_helper_test extends CI_TestCase { 'smells' => 'smell', 'equipment' => 'equipment' ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, singular($str)); } } - + // -------------------------------------------------------------------- - + public function test_plural() { $strs = array( @@ -35,15 +35,15 @@ class Inflector_helper_test extends CI_TestCase { 'witch' => 'witches', 'equipment' => 'equipment' ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, plural($str)); - } - } + } + } // -------------------------------------------------------------------- - + public function test_camelize() { $strs = array( @@ -52,15 +52,15 @@ class Inflector_helper_test extends CI_TestCase { 'i-am-playing-a-trick' => 'i-am-playing-a-trick', 'what_do_you_think-yo?' => 'whatDoYouThink-yo?', ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, camelize($str)); } - } + } // -------------------------------------------------------------------- - + public function test_underscore() { $strs = array( @@ -69,7 +69,7 @@ class Inflector_helper_test extends CI_TestCase { 'i-am-playing-a-trick' => 'i-am-playing-a-trick', 'what_do_you_think-yo?' => 'what_do_you_think-yo?', ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, underscore($str)); @@ -77,7 +77,7 @@ class Inflector_helper_test extends CI_TestCase { } // -------------------------------------------------------------------- - + public function test_humanize() { $strs = array( @@ -86,10 +86,11 @@ class Inflector_helper_test extends CI_TestCase { 'i-am-playing-a-trick' => 'I-am-playing-a-trick', 'what_do_you_think-yo?' => 'What Do You Think-yo?', ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, humanize($str)); } } + } \ No newline at end of file diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php index 4bb9a918a..23d5c5c1a 100644 --- a/tests/codeigniter/helpers/number_helper_test.php +++ b/tests/codeigniter/helpers/number_helper_test.php @@ -1,35 +1,35 @@ helper('number'); - + // Grab the core lang class $lang_cls = $this->ci_core_class('lang'); - + // Mock away load, too much going on in there, // we'll just check for the expected parameter - + $lang = $this->getMock($lang_cls, array('load')); $lang->expects($this->once()) ->method('load') ->with($this->equalTo('number')); - + // Assign the proper language array - + $lang->language = $this->_get_lang('number'); - + // We don't have a controller, so just create // a cheap class to act as our super object. // Make sure it has a lang attribute. - + $obj = new StdClass; $obj->lang = $lang; $this->ci_instance($obj); } - + // Quick helper to actually grab the language // file. Consider moving this to ci_testcase? public function _get_lang($name) @@ -37,41 +37,40 @@ class Number_helper_test extends CI_TestCase { require BASEPATH.'language/english/'.$name.'_lang.php'; return $lang; } - + public function test_byte_format() { $this->assertEquals('456 Bytes', byte_format(456)); } - + public function test_kb_format() { $this->assertEquals('4.5 KB', byte_format(4567)); } - + public function test_kb_format_medium() { $this->assertEquals('44.6 KB', byte_format(45678)); } - + public function test_kb_format_large() { $this->assertEquals('446.1 KB', byte_format(456789)); } - + public function test_mb_format() { $this->assertEquals('3.3 MB', byte_format(3456789)); } - + public function test_gb_format() { $this->assertEquals('1.8 GB', byte_format(1932735283.2)); } - + public function test_tb_format() { $this->assertEquals('112,283.3 TB', byte_format(123456789123456789)); } -} -// EOF \ No newline at end of file +} \ No newline at end of file diff --git a/tests/codeigniter/helpers/path_helper_test.php b/tests/codeigniter/helpers/path_helper_test.php index 632f57501..0faf6f383 100644 --- a/tests/codeigniter/helpers/path_helper_test.php +++ b/tests/codeigniter/helpers/path_helper_test.php @@ -8,9 +8,8 @@ class Path_helper_test extends CI_TestCase { } public function test_set_realpath() - { - $expected = getcwd() . DIRECTORY_SEPARATOR; - $this->assertEquals($expected, set_realpath(getcwd())); + { + $this->assertEquals(getcwd().DIRECTORY_SEPARATOR, set_realpath(getcwd())); } public function test_set_realpath_nonexistent_directory() diff --git a/tests/codeigniter/helpers/string_helper_test.php b/tests/codeigniter/helpers/string_helper_test.php index 29c3d6594..75701ec13 100644 --- a/tests/codeigniter/helpers/string_helper_test.php +++ b/tests/codeigniter/helpers/string_helper_test.php @@ -10,18 +10,18 @@ class String_helper_test extends CI_TestCase { public function test_strip_slashes() { $expected = array( - "Is your name O'reilly?", + "Is your name O'reilly?", "No, my name is O'connor." ); - + $str = array( "Is your name O\'reilly?", "No, my name is O\'connor." ); - + $this->assertEquals($expected, strip_slashes($str)); } - + public function test_trim_slashes() { $strs = array( @@ -144,4 +144,5 @@ class String_helper_test extends CI_TestCase { $this->assertEquals('file-1', increment_string('file', '-', '1')); $this->assertEquals(124, increment_string('123', '')); } + } \ 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 73e2b9429..f131469cb 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -3,16 +3,16 @@ 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)); @@ -20,8 +20,8 @@ class Text_helper_test extends CI_TestCase { $this->assertEquals('', word_limiter('', 4)); } - // ------------------------------------------------------------------------ - + // ------------------------------------------------------------------------ + public function test_character_limiter() { $this->assertEquals('Once upon a time, a…', character_limiter($this->_long_string, 20)); @@ -30,22 +30,22 @@ class Text_helper_test extends CI_TestCase { $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() { @@ -53,27 +53,27 @@ class Text_helper_test extends CI_TestCase { '“‘ “test”' => '“‘ “test”', '†¥¨ˆøåß∂ƒ©˙∆˚¬' => '†¥¨ˆøåß∂ƒ©˙∆˚¬' ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, entities_to_ascii($str)); - } + } } - - // ------------------------------------------------------------------------ - - function test_convert_accented_characters() + + // ------------------------------------------------------------------------ + + public 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 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', @@ -81,28 +81,26 @@ class Text_helper_test extends CI_TestCase { '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() { - $code = ''; $expect = "\n<?php var_dump(\$this); ?> \n\n"; - $this->assertEquals($expect, highlight_code($code)); + $this->assertEquals($expect, highlight_code('')); } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ public function test_highlight_phrase() { @@ -113,14 +111,14 @@ class Text_helper_test extends CI_TestCase { 'Or tell me what this is' => 'Or tell me what this is', '' => '' ); - + foreach ($strs as $str => $expect) { $this->assertEquals($expect, highlight_phrase($str, 'this is')); } } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ public function test_ellipsize() { @@ -144,32 +142,30 @@ class Text_helper_test extends CI_TestCase { 'short' => 'short' ), ); - + foreach ($strs as $pos => $s) { foreach ($s as $str => $expect) { - $this->assertEquals($expect, ellipsize($str, 10, $pos)); + $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."; - $word_wrapped = word_wrap($string, 25); - $this->assertEquals(substr_count($word_wrapped, "\n"), 4); + $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."; - $word_wrapped = word_wrap($string); - $this->assertEquals(strpos($word_wrapped, "\n"), 73); + $this->assertEquals(strpos(word_wrap($string), "\n"), 73); } } \ No newline at end of file diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php index c561809ce..c81c5f1b8 100644 --- a/tests/codeigniter/helpers/url_helper_test.php +++ b/tests/codeigniter/helpers/url_helper_test.php @@ -72,4 +72,5 @@ class Url_helper_test extends CI_TestCase { $this->assertEquals($out, auto_link($in, 'url')); } } + } \ No newline at end of file diff --git a/tests/codeigniter/helpers/xml_helper_test.php b/tests/codeigniter/helpers/xml_helper_test.php index a83fef91e..e8cf411da 100644 --- a/tests/codeigniter/helpers/xml_helper_test.php +++ b/tests/codeigniter/helpers/xml_helper_test.php @@ -6,10 +6,10 @@ class Xml_helper_test extends CI_TestCase { { $this->helper('xml'); } - + public function test_xml_convert() { $this->assertEquals('<tag>my & test - </tag>', xml_convert('my & test - ')); } - + } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From c186288755aba46a2b6f0c3f104d9a6ce6b11a7f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 9 Jun 2012 23:16:58 +0300 Subject: Cleanup/optimize tests/codeigniter/ --- tests/codeigniter/helpers/number_helper_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php index 23d5c5c1a..ef6aae138 100644 --- a/tests/codeigniter/helpers/number_helper_test.php +++ b/tests/codeigniter/helpers/number_helper_test.php @@ -25,7 +25,7 @@ class Number_helper_test extends CI_TestCase { // a cheap class to act as our super object. // Make sure it has a lang attribute. - $obj = new StdClass; + $obj = new stdClass; $obj->lang = $lang; $this->ci_instance($obj); } -- cgit v1.2.3-24-g4f1b From e1c8ee76f4756442094106320d9577c2c7595959 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 11:35:11 +0300 Subject: Alter now() tests --- tests/codeigniter/helpers/date_helper_test.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index 4b747b864..bcb1477bc 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -13,6 +13,8 @@ class Date_helper_test extends CI_TestCase { public function test_now_local() { + /* + // This stub job, is simply to cater $config['time_reference'] $config = $this->getMock('CI_Config'); $config->expects($this->any()) @@ -22,6 +24,10 @@ class Date_helper_test extends CI_TestCase { // Add the stub to our test instance $this->ci_instance_var('config', $config); + */ + + $this->ci_set_config('time_reference', 'local'); + $this->assertEquals(time(), now()); } @@ -29,6 +35,8 @@ class Date_helper_test extends CI_TestCase { public function test_now_gmt() { + /* + // This stub job, is simply to cater $config['time_reference'] $config = $this->getMock('CI_Config'); $config->expects($this->any()) @@ -38,6 +46,10 @@ class Date_helper_test extends CI_TestCase { // Add the stub to our stdClass $this->ci_instance_var('config', $config); + */ + + $this->ci_set_config('time_reference', 'gmt'); + $t = time(); $this->assertEquals( mktime(gmdate('H', $t), gmdate('i', $t), gmdate('s', $t), gmdate('m', $t), gmdate('d', $t), gmdate('Y', $t)), -- cgit v1.2.3-24-g4f1b From 0ddff314d619e5d24bdf07f3da33c779f5b6e2c0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 13:18:07 +0300 Subject: test_now_gmt() -> test_now_utc() --- tests/codeigniter/helpers/date_helper_test.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index bcb1477bc..242935116 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -33,7 +33,7 @@ class Date_helper_test extends CI_TestCase { // ------------------------------------------------------------------------ - public function test_now_gmt() + public function test_now_utc() { /* @@ -41,18 +41,17 @@ class Date_helper_test extends CI_TestCase { $config = $this->getMock('CI_Config'); $config->expects($this->any()) ->method('item') - ->will($this->returnValue('gmt')); + ->will($this->returnValue('UTC')); // Add the stub to our stdClass $this->ci_instance_var('config', $config); */ - $this->ci_set_config('time_reference', 'gmt'); + $this->ci_set_config('time_reference', 'UTC'); - $t = time(); $this->assertEquals( - mktime(gmdate('H', $t), gmdate('i', $t), gmdate('s', $t), gmdate('m', $t), gmdate('d', $t), gmdate('Y', $t)), + gmmktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('Y')), now() ); } -- cgit v1.2.3-24-g4f1b From 3ed533109309326a858c778dfea5cb9186f965b4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 13:21:07 +0300 Subject: Some optimizations to the date helper tests --- tests/codeigniter/helpers/date_helper_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index 242935116..1d397ac81 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -51,7 +51,7 @@ class Date_helper_test extends CI_TestCase { $this->ci_set_config('time_reference', 'UTC'); $this->assertEquals( - gmmktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('Y')), + gmmktime(date('G'), date('i'), date('s'), date('n'), date('j'), date('Y')), now() ); } @@ -196,9 +196,9 @@ class Date_helper_test extends CI_TestCase { public function test_local_to_gmt() { $this->assertEquals( - mktime( - gmdate('H', $this->time), gmdate('i', $this->time), gmdate('s', $this->time), - gmdate('m', $this->time), gmdate('d', $this->time), gmdate('Y', $this->time) + gmmktime( + date('G', $this->time), date('i', $this->time), date('s', $this->time), + date('n', $this->time), date('j', $this->time), date('Y', $this->time) ), local_to_gmt($this->time) ); -- cgit v1.2.3-24-g4f1b From b089e15b1510de6b6a034631c80d3d5e830ff9f3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 19:11:40 +0300 Subject: Fix local_to_gmt() --- tests/codeigniter/helpers/date_helper_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index 1d397ac81..8258c9248 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -196,9 +196,9 @@ class Date_helper_test extends CI_TestCase { public function test_local_to_gmt() { $this->assertEquals( - gmmktime( - date('G', $this->time), date('i', $this->time), date('s', $this->time), - date('n', $this->time), date('j', $this->time), date('Y', $this->time) + mktime( + gmdate('G', $this->time), gmdate('i', $this->time), gmdate('s', $this->time), + gmdate('n', $this->time), gmdate('j', $this->time), gmdate('Y', $this->time) ), local_to_gmt($this->time) ); -- cgit v1.2.3-24-g4f1b From a84055b49539da1faa2893618b2475d1888a9fea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 20 Jun 2012 14:37:59 +0300 Subject: Fix issue #1510 --- tests/codeigniter/helpers/date_helper_test.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index 8258c9248..4e01b1aa3 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -48,11 +48,9 @@ class Date_helper_test extends CI_TestCase { */ - $this->ci_set_config('time_reference', 'UTC'); - $this->assertEquals( - gmmktime(date('G'), date('i'), date('s'), date('n'), date('j'), date('Y')), - now() + mktime(gmdate('G'), gmdate('i'), gmdate('s'), gmdate('n'), gmdate('j'), gmdate('Y')), + now('UTC') ); } -- cgit v1.2.3-24-g4f1b From 5211c094c930d69d52539591b306c293c99689ad Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 2 Jul 2012 16:47:12 +0300 Subject: Fix standard_date() tests --- tests/codeigniter/helpers/date_helper_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index 4e01b1aa3..eaf4cf8a5 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -79,7 +79,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_atom() { $this->assertEquals( - date("Y-m-d\TH:i:sO", $this->time), + date('Y-m-d\TH:i:sP', $this->time), standard_date('DATE_ATOM', $this->time) ); } @@ -99,7 +99,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_iso8601() { $this->assertEquals( - date("Y-m-d\TH:i:sO", $this->time), + date('Y-m-d\TH:i:sP', $this->time), standard_date('DATE_ISO8601', $this->time) ); } @@ -139,7 +139,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_rfc2822() { $this->assertEquals( - date('D, d M Y H:i:s O', $this->time), + date('r', $this->time), standard_date('DATE_RFC2822', $this->time) ); } @@ -159,7 +159,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_w3c() { $this->assertEquals( - date("Y-m-d\TH:i:sO", $this->time), + date('Y-m-d\TH:i:sP', $this->time), standard_date('DATE_W3C', $this->time) ); } -- cgit v1.2.3-24-g4f1b From dd6f32b3b506d29da38f41d307e5ea217c21cb51 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 4 Jul 2012 10:08:54 +0300 Subject: Optimize standard_date() --- tests/codeigniter/helpers/date_helper_test.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php index eaf4cf8a5..1b79b9480 100644 --- a/tests/codeigniter/helpers/date_helper_test.php +++ b/tests/codeigniter/helpers/date_helper_test.php @@ -69,7 +69,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_rfc822() { $this->assertEquals( - date('D, d M y H:i:s O', $this->time), + date(DATE_RFC822, $this->time), standard_date('DATE_RFC822', $this->time) ); } @@ -79,7 +79,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_atom() { $this->assertEquals( - date('Y-m-d\TH:i:sP', $this->time), + date(DATE_ATOM, $this->time), standard_date('DATE_ATOM', $this->time) ); } @@ -89,7 +89,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_cookie() { $this->assertEquals( - date("l, d-M-y H:i:s \U\T\C", $this->time), + date(DATE_COOKIE, $this->time), standard_date('DATE_COOKIE', $this->time) ); } @@ -99,7 +99,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_iso8601() { $this->assertEquals( - date('Y-m-d\TH:i:sP', $this->time), + date(DATE_ISO8601, $this->time), standard_date('DATE_ISO8601', $this->time) ); } @@ -109,7 +109,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_rfc850() { $this->assertEquals( - date("l, d-M-y H:i:s \U\T\C", $this->time), + date(DATE_RFC850, $this->time), standard_date('DATE_RFC850', $this->time) ); } @@ -119,7 +119,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_rfc1036() { $this->assertEquals( - date('D, d M y H:i:s O', $this->time), + date(DATE_RFC1036, $this->time), standard_date('DATE_RFC1036', $this->time) ); } @@ -129,7 +129,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_rfc1123() { $this->assertEquals( - date('D, d M Y H:i:s O', $this->time), + date(DATE_RFC1123, $this->time), standard_date('DATE_RFC1123', $this->time) ); } @@ -139,7 +139,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_rfc2822() { $this->assertEquals( - date('r', $this->time), + date(DATE_RFC2822, $this->time), standard_date('DATE_RFC2822', $this->time) ); } @@ -149,7 +149,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_rss() { $this->assertEquals( - date('D, d M Y H:i:s O', $this->time), + date(DATE_RSS, $this->time), standard_date('DATE_RSS', $this->time) ); } @@ -159,7 +159,7 @@ class Date_helper_test extends CI_TestCase { public function test_standard_date_w3c() { $this->assertEquals( - date('Y-m-d\TH:i:sP', $this->time), + date(DATE_W3C, $this->time), standard_date('DATE_W3C', $this->time) ); } -- cgit v1.2.3-24-g4f1b From 62ab8b24fc37a25eab9205c46321fa41729e5faf Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Sat, 28 Jul 2012 14:57:04 -0400 Subject: Adding optional attributes as array or object for html helper --- tests/codeigniter/helpers/html_helper_test.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/html_helper_test.php b/tests/codeigniter/helpers/html_helper_test.php index 9a7bb48bf..4dd717ff7 100644 --- a/tests/codeigniter/helpers/html_helper_test.php +++ b/tests/codeigniter/helpers/html_helper_test.php @@ -22,6 +22,22 @@ class Html_helper_test extends CI_TestCase { $this->assertEquals('

foobar

', heading('foobar', 2, 'class="bar"')); } + public function test_heading_array_attributes() + { + // Test array of attributes + $this->assertEquals('

foobar

', heading('foobar', 2, array('class' => 'bar', 'id' => 'foo'))); + } + + public function test_heading_object_attributes() + { + // Test array of attributes + $this->assertEquals('

foobar

', heading('foobar', 2, array('class' => 'bar', 'id' => 'foo'))); + $test = new stdClass; + $test->class = "bar"; + $test->id = "foo"; + $this->assertEquals('

foobar

', heading('foobar', 2, $test)); + } + // ------------------------------------------------------------------------ public function test_Ul() @@ -72,5 +88,4 @@ EOH; $this->assertEquals($expect, meta(array('name' => 'foo'))); } - } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 8280885499ca4b1cffacc9ad78a9eff07a84de25 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Thu, 13 Sep 2012 05:19:59 +0200 Subject: directory_map() was skipping files and directories named "0" Close #1757. Thanks @BennyC! --- tests/codeigniter/helpers/directory_helper_test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/directory_helper_test.php b/tests/codeigniter/helpers/directory_helper_test.php index 176ff1d78..c39ccd8d0 100644 --- a/tests/codeigniter/helpers/directory_helper_test.php +++ b/tests/codeigniter/helpers/directory_helper_test.php @@ -19,6 +19,7 @@ class Directory_helper_test extends CI_TestCase { 'benchmark.html' => '', 'database' => array('active_record.html' => '', 'binds.html' => ''), 'email.html' => '', + '0' => '', '.hiddenfile.txt' => '' ) ); @@ -30,7 +31,8 @@ class Directory_helper_test extends CI_TestCase { 'libraries' => array( 'benchmark.html', 'database' => array('active_record.html', 'binds.html'), - 'email.html' + 'email.html', + '0' ) ); -- cgit v1.2.3-24-g4f1b