From b73eb19aed66190c10c9cad476da7c36c271d6dc Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 19 Sep 2019 15:08:45 +0300 Subject: [ci skip] 3.1.11 release --- tests/codeigniter/helpers/array_helper_test.php | 45 --- tests/codeigniter/helpers/captcha_helper_test.php | 10 - tests/codeigniter/helpers/cookie_helper_test.php | 59 ---- tests/codeigniter/helpers/date_helper_test.php | 325 --------------------- .../codeigniter/helpers/directory_helper_test.php | 59 ---- tests/codeigniter/helpers/download_helper_test.php | 10 - tests/codeigniter/helpers/email_helper_test.php | 24 -- tests/codeigniter/helpers/file_helper_test.php | 147 ---------- tests/codeigniter/helpers/form_helper_test.php | 290 ------------------ tests/codeigniter/helpers/html_helper_test.php | 106 ------- .../codeigniter/helpers/inflector_helper_test.php | 96 ------ tests/codeigniter/helpers/language_helper_test.php | 16 - tests/codeigniter/helpers/number_helper_test.php | 63 ---- tests/codeigniter/helpers/path_helper_test.php | 30 -- tests/codeigniter/helpers/security_helper_test.php | 64 ---- tests/codeigniter/helpers/string_helper_test.php | 148 ---------- tests/codeigniter/helpers/text_helper_test.php | 174 ----------- tests/codeigniter/helpers/url_helper_test.php | 89 ------ tests/codeigniter/helpers/xml_helper_test.php | 15 - 19 files changed, 1770 deletions(-) delete mode 100644 tests/codeigniter/helpers/array_helper_test.php delete mode 100644 tests/codeigniter/helpers/captcha_helper_test.php delete mode 100644 tests/codeigniter/helpers/cookie_helper_test.php delete mode 100644 tests/codeigniter/helpers/date_helper_test.php delete mode 100644 tests/codeigniter/helpers/directory_helper_test.php delete mode 100644 tests/codeigniter/helpers/download_helper_test.php delete mode 100644 tests/codeigniter/helpers/email_helper_test.php delete mode 100644 tests/codeigniter/helpers/file_helper_test.php delete mode 100644 tests/codeigniter/helpers/form_helper_test.php delete mode 100644 tests/codeigniter/helpers/html_helper_test.php delete mode 100644 tests/codeigniter/helpers/inflector_helper_test.php delete mode 100644 tests/codeigniter/helpers/language_helper_test.php delete mode 100644 tests/codeigniter/helpers/number_helper_test.php delete mode 100644 tests/codeigniter/helpers/path_helper_test.php delete mode 100644 tests/codeigniter/helpers/security_helper_test.php delete mode 100644 tests/codeigniter/helpers/string_helper_test.php delete mode 100644 tests/codeigniter/helpers/text_helper_test.php delete mode 100644 tests/codeigniter/helpers/url_helper_test.php delete mode 100644 tests/codeigniter/helpers/xml_helper_test.php (limited to 'tests/codeigniter/helpers') diff --git a/tests/codeigniter/helpers/array_helper_test.php b/tests/codeigniter/helpers/array_helper_test.php deleted file mode 100644 index b2409c330..000000000 --- a/tests/codeigniter/helpers/array_helper_test.php +++ /dev/null @@ -1,45 +0,0 @@ - 'bar', - 'sally' => 'jim', - 'maggie' => 'bessie', - 'herb' => 'cook' - ); - - public function set_up() - { - $this->helper('array'); - } - - // ------------------------------------------------------------------------ - - 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->assertContains(random_element($this->my_array), $this->my_array); - } - - // ------------------------------------------------------------------------ - - public function test_elements() - { - $this->assertInternalType('array', elements('test', $this->my_array)); - $this->assertInternalType('array', elements('foo', $this->my_array)); - } - -} diff --git a/tests/codeigniter/helpers/captcha_helper_test.php b/tests/codeigniter/helpers/captcha_helper_test.php deleted file mode 100644 index bb8760a15..000000000 --- a/tests/codeigniter/helpers/captcha_helper_test.php +++ /dev/null @@ -1,10 +0,0 @@ -markTestSkipped("Can't test"); - } - -} \ No newline at end of file diff --git a/tests/codeigniter/helpers/cookie_helper_test.php b/tests/codeigniter/helpers/cookie_helper_test.php deleted file mode 100644 index fba68f20f..000000000 --- a/tests/codeigniter/helpers/cookie_helper_test.php +++ /dev/null @@ -1,59 +0,0 @@ -helper('cookie'); - } - - // ------------------------------------------------------------------------ - - function test_set_cookie() - { - /*$input_cls = $this->ci_core_class('input'); - $this->ci_instance_var('input', new $input_cls); - - $this->assertTrue(set_cookie( - 'my_cookie', - 'foobar' - ));*/ - - $this->markTestSkipped('Need to find a way to overcome a headers already set exception'); - } - - // ------------------------------------------------------------------------ - - function test_get_cookie() - { - $_COOKIE['foo'] = 'bar'; - - $security = new Mock_Core_Security(); - $utf8 = new Mock_Core_Utf8(); - $input_cls = $this->ci_core_class('input'); - $this->ci_instance_var('input', new Mock_Core_Input($security, $utf8)); - - $this->assertEquals('bar', get_cookie('foo', FALSE)); - $this->assertEquals('bar', get_cookie('foo', TRUE)); - - $_COOKIE['bar'] = "Hello, i try to your site"; - - $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", get_cookie('bar', TRUE)); - $this->assertEquals("Hello, i try to your site", get_cookie('bar', FALSE)); - } - - // ------------------------------------------------------------------------ - - function test_delete_cookie() - { - /*$input_cls = $this->ci_core_class('input'); - $this->ci_instance_var('input', new $input_cls); - - $this->assertTrue(delete_cookie( - 'my_cookie' - ));*/ - - $this->markTestSkipped('Need to find a way to overcome a headers already set exception'); - } - -} \ No newline at end of file diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php deleted file mode 100644 index b419418bf..000000000 --- a/tests/codeigniter/helpers/date_helper_test.php +++ /dev/null @@ -1,325 +0,0 @@ -helper('date'); - $this->time = time(); - } - - // ------------------------------------------------------------------------ - - public function test_nice_date() - { - $this->assertEquals('2016-11-01', nice_date('201611', 'Y-m-d')); - $this->assertEquals('2016-11-23', nice_date('20161123', 'Y-m-d')); - } - - // ------------------------------------------------------------------------ - - public function test_now_local() - { - /* - - // This stub job, is simply to cater $config['time_reference'] - $config = $this->getMockBuilder('CI_Config')->getMock(); - $config->expects($this->any()) - ->method('item') - ->will($this->returnValue('local')); - - // Add the stub to our test instance - $this->ci_instance_var('config', $config); - - */ - - $this->ci_set_config('time_reference', 'local'); - - $this->assertEquals(time(), now()); - } - - // ------------------------------------------------------------------------ - - public function test_now_utc() - { - /* - - // This stub job, is simply to cater $config['time_reference'] - $config = $this->getMockBuilder('CI_Config')->getMock(); - $config->expects($this->any()) - ->method('item') - ->will($this->returnValue('UTC')); - - // Add the stub to our stdClass - $this->ci_instance_var('config', $config); - - */ - - $this->assertEquals( - mktime(gmdate('G'), gmdate('i'), gmdate('s'), gmdate('n'), gmdate('j'), gmdate('Y')), - now('UTC') - ); - } - - // ------------------------------------------------------------------------ - - public function test_mdate() - { - $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() - { - $this->assertEquals( - date(DATE_RFC822, $this->time), - standard_date('DATE_RFC822', $this->time) - ); - } - - // ------------------------------------------------------------------------ - - public function test_standard_date_atom() - { - $this->assertEquals( - date(DATE_ATOM, $this->time), - standard_date('DATE_ATOM', $this->time) - ); - } - - // ------------------------------------------------------------------------ - - public function test_standard_date_cookie() - { - $this->assertEquals( - date(DATE_COOKIE, $this->time), - standard_date('DATE_COOKIE', $this->time) - ); - } - - // ------------------------------------------------------------------------ - - public function test_standard_date_iso8601() - { - $this->assertEquals( - date(DATE_ISO8601, $this->time), - standard_date('DATE_ISO8601', $this->time) - ); - } - - // ------------------------------------------------------------------------ - - public function test_standard_date_rfc850() - { - $this->assertEquals( - date(DATE_RFC850, $this->time), - standard_date('DATE_RFC850', $this->time) - ); - } - - // ------------------------------------------------------------------------ - - public function test_standard_date_rfc1036() - { - $this->assertEquals( - date(DATE_RFC1036, $this->time), - standard_date('DATE_RFC1036', $this->time) - ); - } - - // ------------------------------------------------------------------------ - - public function test_standard_date_rfc1123() - { - $this->assertEquals( - date(DATE_RFC1123, $this->time), - standard_date('DATE_RFC1123', $this->time) - ); - } - - // ------------------------------------------------------------------------ - - public function test_standard_date_rfc2822() - { - $this->assertEquals( - date(DATE_RFC2822, $this->time), - standard_date('DATE_RFC2822', $this->time) - ); - } - - // ------------------------------------------------------------------------ - - public function test_standard_date_rss() - { - $this->assertEquals( - date(DATE_RSS, $this->time), - standard_date('DATE_RSS', $this->time) - ); - } - - // ------------------------------------------------------------------------ - - public function test_standard_date_w3c() - { - $this->assertEquals( - date(DATE_W3C, $this->time), - standard_date('DATE_W3C', $this->time) - ); - } - - // ------------------------------------------------------------------------ - - public function test_timespan() - { - $this->ci_vfs_clone('system/language/english/date_lang.php'); - - $loader_cls = $this->ci_core_class('load'); - $this->ci_instance_var('load', new $loader_cls); - - $lang_cls = $this->ci_core_class('lang'); - $this->ci_instance_var('lang', new $lang_cls); - - $this->assertEquals('1 Second', timespan(time(), time()+1)); - $this->assertEquals('1 Minute', timespan(time(), time()+60)); - $this->assertEquals('1 Hour', timespan(time(), time()+3600)); - $this->assertEquals('2 Hours', timespan(time(), time()+7200)); - } - - // ------------------------------------------------------------------------ - - public function test_days_in_month() - { - $this->assertEquals(30, days_in_month(06, 2005)); - $this->assertEquals(28, days_in_month(02, 2011)); - $this->assertEquals(29, days_in_month(02, 2012)); - } - - // ------------------------------------------------------------------------ - - public function test_local_to_gmt() - { - $this->assertEquals( - 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) - ); - } - - // ------------------------------------------------------------------------ - - public function test_gmt_to_local() - { - $this->assertEquals(1140128493, gmt_to_local('1140153693', 'UM8', TRUE)); - } - - // ------------------------------------------------------------------------ - - public function test_mysql_to_unix() - { - $this->assertEquals($this->time, mysql_to_unix(date('Y-m-d H:i:s', $this->time))); - } - - // ------------------------------------------------------------------------ - - public function test_unix_to_human() - { - $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')); - } - - // ------------------------------------------------------------------------ - - public function test_human_to_unix() - { - $date = '2000-12-31 10:00:00 PM'; - $this->assertEquals(strtotime($date), human_to_unix($date)); - $this->assertFalse(human_to_unix()); - } - - // ------------------------------------------------------------------------ - - public function test_timezones() - { - $zones = array( - 'UM12' => -12, - 'UM11' => -11, - 'UM10' => -10, - 'UM95' => -9.5, - 'UM9' => -9, - 'UM8' => -8, - 'UM7' => -7, - 'UM6' => -6, - 'UM5' => -5, - 'UM45' => -4.5, - 'UM4' => -4, - 'UM35' => -3.5, - 'UM3' => -3, - 'UM2' => -2, - 'UM1' => -1, - 'UTC' => 0, - 'UP1' => +1, - 'UP2' => +2, - 'UP3' => +3, - 'UP35' => +3.5, - 'UP4' => +4, - 'UP45' => +4.5, - 'UP5' => +5, - 'UP55' => +5.5, - 'UP575' => +5.75, - 'UP6' => +6, - 'UP65' => +6.5, - 'UP7' => +7, - 'UP8' => +8, - 'UP875' => +8.75, - 'UP9' => +9, - 'UP95' => +9.5, - 'UP10' => +10, - 'UP105' => +10.5, - 'UP11' => +11, - 'UP115' => +11.5, - 'UP12' => +12, - 'UP1275' => +12.75, - 'UP13' => +13, - 'UP14' => +14 - ); - - foreach ($zones AS $test => $expected) - { - $this->assertEquals($expected, timezones($test)); - } - - $this->assertArrayHasKey('UP3', timezones()); - $this->assertEquals(0, timezones('non_existent')); - } - - // ------------------------------------------------------------------------ - - public function test_date_range() - { - $dates = array( - '29-01-2012', '30-01-2012', '31-01-2012', - '01-02-2012', '02-02-2012', '03-02-2012', - '04-02-2012', '05-02-2012', '06-02-2012', - '07-02-2012', '08-02-2012', '09-02-2012', - '10-02-2012', '11-02-2012', '12-02-2012', - '13-02-2012', '14-02-2012', '15-02-2012', - '16-02-2012', '17-02-2012', '18-02-2012', - '19-02-2012', '20-02-2012', '21-02-2012', - '22-02-2012', '23-02-2012', '24-02-2012', - '25-02-2012', '26-02-2012', '27-02-2012', - '28-02-2012', '29-02-2012', '01-03-2012' - ); - - $this->assertEquals($dates, date_range(mktime(12, 0, 0, 1, 29, 2012), mktime(12, 0, 0, 3, 1, 2012), TRUE, 'd-m-Y')); - array_pop($dates); - $this->assertEquals($dates, date_range(mktime(12, 0, 0, 1, 29, 2012), 31, FALSE, 'd-m-Y')); - } - -} diff --git a/tests/codeigniter/helpers/directory_helper_test.php b/tests/codeigniter/helpers/directory_helper_test.php deleted file mode 100644 index 253c1e368..000000000 --- a/tests/codeigniter/helpers/directory_helper_test.php +++ /dev/null @@ -1,59 +0,0 @@ -helper('directory'); - - vfsStreamWrapper::register(); - vfsStreamWrapper::setRoot(new vfsStreamDirectory('testDir')); - - $this->_test_dir = vfsStreamWrapper::getRoot(); - } - - public function test_directory_map() - { - $ds = DIRECTORY_SEPARATOR; - - $structure = array( - 'libraries' => array( - 'benchmark.html' => '', - 'database' => array('active_record.html' => '', 'binds.html' => ''), - 'email.html' => '', - '0' => '', - '.hiddenfile.txt' => '' - ) - ); - - vfsStream::create($structure, $this->_test_dir); - - // is_dir(), opendir(), etc. seem to fail on Windows + vfsStream when there are trailing backslashes in directory names - if ( ! is_dir(vfsStream::url('testDir').DIRECTORY_SEPARATOR)) - { - $this->markTestSkipped("Can't test this under Windows"); - return; - } - - // test default recursive behavior - $expected = array( - 'libraries'.$ds => array( - 'benchmark.html', - 'database'.$ds => array('active_record.html', 'binds.html'), - 'email.html', - '0' - ) - ); - - $this->assertEquals($expected, directory_map(vfsStream::url('testDir'))); - - // test detection of hidden files - $expected['libraries'.$ds][] = '.hiddenfile.txt'; - - $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), 0, TRUE)); - - // test recursion depth behavior - $this->assertEquals(array('libraries'.$ds), directory_map(vfsStream::url('testDir'), 1)); - } - -} diff --git a/tests/codeigniter/helpers/download_helper_test.php b/tests/codeigniter/helpers/download_helper_test.php deleted file mode 100644 index d2b42e46b..000000000 --- a/tests/codeigniter/helpers/download_helper_test.php +++ /dev/null @@ -1,10 +0,0 @@ -markTestSkipped('Cant easily test'); - } - -} \ No newline at end of file diff --git a/tests/codeigniter/helpers/email_helper_test.php b/tests/codeigniter/helpers/email_helper_test.php deleted file mode 100644 index 529e96910..000000000 --- a/tests/codeigniter/helpers/email_helper_test.php +++ /dev/null @@ -1,24 +0,0 @@ -helper('email'); - } - - 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')); - $this->assertEquals(TRUE, valid_email('my.test@subdomain.test.com')); - } - - public function test_send_mail() - { - $this->markTestSkipped("Can't test"); - } - -} \ No newline at end of file diff --git a/tests/codeigniter/helpers/file_helper_test.php b/tests/codeigniter/helpers/file_helper_test.php deleted file mode 100644 index c31817595..000000000 --- a/tests/codeigniter/helpers/file_helper_test.php +++ /dev/null @@ -1,147 +0,0 @@ -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); - - $this->assertEquals($content, read_file(vfsStream::url('my_file.txt'))); - } - - // -------------------------------------------------------------------- - - 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())); - } - - // -------------------------------------------------------------------- - - /** - * 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())); - } - - // -------------------------------------------------------------------- - - 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 - $file = vfsStream::newFile('foo.png')->at($this->_test_dir); - - $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' - ); - - $this->_test_get_file_info($vals); - - // Test passing in vals as a string. - $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); - - $ret_values = array( - 'name' => 'my_file.txt', - 'server_path' => 'vfs://my_file.txt', - 'size' => 57, - 'date' => $last_modified, - 'readable' => 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); - } - } - - // -------------------------------------------------------------------- - - public function test_write_file() - { - $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 deleted file mode 100644 index b5fe99b96..000000000 --- a/tests/codeigniter/helpers/form_helper_test.php +++ /dev/null @@ -1,290 +0,0 @@ -helper('form'); - } - - // ------------------------------------------------------------------------ - - 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', - 'value' => 'johndoe', - 'maxlength' => '100', - 'size' => '50', - 'style' => 'width:50%', - ); - - $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', - ); - - $this->assertEquals($expected, form_dropdown('shirts', $options, 'large')); - - $expected = << - - - - - - -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' - ), - 'German Cars' => array( - 'mercedes' => 'Mercedes', - 'audi' => 'Audi' - ) - ); - - $expected = << - - - - - - - - - - -EOH; - - $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', - ); - - $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')); - } - - // ------------------------------------------------------------------------ - - public function test_form_fieldset_close() - { - $expected = << -EOH; - - $this->assertEquals($expected, form_fieldset_close('')); - } - - // ------------------------------------------------------------------------ - - public function test_form_checkbox() - { - $expected = << - -EOH; - - $this->assertEquals($expected, form_checkbox('newsletter', 'accept', TRUE)); - } - - // ------------------------------------------------------------------------ - - public function test_form_radio() - { - $expected = << - -EOH; - - $this->assertEquals($expected, form_radio('newsletter', 'accept', TRUE)); - } - - // ------------------------------------------------------------------------ - - public function test_form_submit() - { - $expected = << - -EOH; - - $this->assertEquals($expected, form_submit('mysubmit', 'Submit Post!')); - } - - // ------------------------------------------------------------------------ - - public function test_form_label() - { - $expected = <<What is your Name -EOH; - - $this->assertEquals($expected, form_label('What is your Name', 'username')); - } - - // ------------------------------------------------------------------------ - - public function test_form_reset() - { - $expected = << - -EOH; - - $this->assertEquals($expected, form_reset('myreset', 'Reset')); - } - - // ------------------------------------------------------------------------ - - public function test_form_button() - { - $expected = <<content - -EOH; - - $this->assertEquals($expected, form_button('name', 'content')); - } - - // ------------------------------------------------------------------------ - - public function test_form_close() - { - $expected = << -EOH; - - $this->assertEquals($expected, form_close('')); - } - - // ------------------------------------------------------------------------ - - public function test_form_prep() - { - $this->assertEquals( - 'Here is a string containing "quoted" text.', - form_prep('Here is a string containing "quoted" text.') - ); - - $this->assertEquals( - 'Here is a string containing a <tag>.', - form_prep('Here is a string containing a .', TRUE) - ); - } - -} diff --git a/tests/codeigniter/helpers/html_helper_test.php b/tests/codeigniter/helpers/html_helper_test.php deleted file mode 100644 index 3cf1016ec..000000000 --- a/tests/codeigniter/helpers/html_helper_test.php +++ /dev/null @@ -1,106 +0,0 @@ -helper('html'); - } - - // ------------------------------------------------------------------------ - - public function test_br() - { - $this->assertEquals('

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

foobar

', heading('foobar')); - $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_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 = << -
  • foo
  • -
  • bar
  • - - -EOH; - - $expect = ltrim($expect); - $list = array('foo', 'bar'); - - $this->assertEquals(ltrim($expect), ul($list)); - - $expect = << -
  • foo
  • -
  • bar
  • - - -EOH; - - $expect = ltrim($expect); - - $this->assertEquals($expect, ul($list, 'class="test"')); - - $this->assertEquals($expect, ul($list, array('class' => 'test'))); - } - - // ------------------------------------------------------------------------ - - public function test_NBS() - { - $this->assertEquals('   ', nbs(3)); - } - - // ------------------------------------------------------------------------ - - public function test_meta() - { - $this->assertEquals("\n", meta('test', 'foo')); - - $expect = "\n"; - - $this->assertEquals($expect, meta(array('name' => 'foo'))); - - } - -} diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php deleted file mode 100644 index 3ec681bcd..000000000 --- a/tests/codeigniter/helpers/inflector_helper_test.php +++ /dev/null @@ -1,96 +0,0 @@ -helper('inflector'); - } - - public function test_singular() - { - $strs = array( - 'tellies' => 'telly', - 'smellies' => 'smelly', - 'abjectnesses' => 'abjectness', - 'smells' => 'smell', - 'equipment' => 'equipment' - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, singular($str)); - } - } - - // -------------------------------------------------------------------- - - public function test_plural() - { - $strs = array( - 'telly' => 'tellies', - 'smelly' => 'smellies', - 'abjectness' => 'abjectnesses', // ref : http://en.wiktionary.org/wiki/abjectnesses - 'smell' => 'smells', - 'witch' => 'witches', - 'equipment' => 'equipment' - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, plural($str)); - } - } - - // -------------------------------------------------------------------- - - public function test_camelize() - { - $strs = array( - 'this is the string' => 'thisIsTheString', - 'this is another one' => 'thisIsAnotherOne', - '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( - 'this is the string' => 'this_is_the_string', - 'this is another one' => 'this_is_another_one', - '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)); - } - } - - // -------------------------------------------------------------------- - - public function test_humanize() - { - $strs = array( - 'this_is_the_string' => 'This Is The String', - 'this_is_another_one' => 'This Is Another One', - '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)); - } - } - -} diff --git a/tests/codeigniter/helpers/language_helper_test.php b/tests/codeigniter/helpers/language_helper_test.php deleted file mode 100644 index 1ddabea3d..000000000 --- a/tests/codeigniter/helpers/language_helper_test.php +++ /dev/null @@ -1,16 +0,0 @@ -helper('language'); - $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('line'))->getMock(); - $lang->expects($this->any())->method('line')->will($this->returnValue(FALSE)); - $this->ci_instance_var('lang', $lang); - - $this->assertFalse(lang(1)); - $this->assertEquals('', lang(1, 'foo', array('class' => 'bar'))); - } - -} diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php deleted file mode 100644 index 663e354fe..000000000 --- a/tests/codeigniter/helpers/number_helper_test.php +++ /dev/null @@ -1,63 +0,0 @@ -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->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock(); - $lang->expects($this->once()) - ->method('load') - ->with($this->equalTo('number')); - - // Assign the proper language array - $lang->language = $this->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. - $this->ci_instance_var('lang', $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)); - } - -} diff --git a/tests/codeigniter/helpers/path_helper_test.php b/tests/codeigniter/helpers/path_helper_test.php deleted file mode 100644 index 9d325e70d..000000000 --- a/tests/codeigniter/helpers/path_helper_test.php +++ /dev/null @@ -1,30 +0,0 @@ -helper('path'); - } - - public function test_set_realpath() - { - $this->assertEquals(getcwd().DIRECTORY_SEPARATOR, set_realpath(getcwd())); - } - - public function test_set_realpath_nonexistent_directory() - { - $expected = '/path/to/nowhere'; - $this->assertEquals($expected, set_realpath('/path/to/nowhere', FALSE)); - } - - public function test_set_realpath_error_trigger() - { - $this->setExpectedException( - 'RuntimeException', 'CI Error: Not a valid path: /path/to/nowhere' - ); - - set_realpath('/path/to/nowhere', TRUE); - } - -} diff --git a/tests/codeigniter/helpers/security_helper_test.php b/tests/codeigniter/helpers/security_helper_test.php deleted file mode 100644 index effd3ec02..000000000 --- a/tests/codeigniter/helpers/security_helper_test.php +++ /dev/null @@ -1,64 +0,0 @@ -helper('security'); - $obj = new stdClass; - $obj->security = new Mock_Core_Security(); - $this->ci_instance($obj); - } - - function test_xss_clean() - { - $this->assertEquals('foo', xss_clean('foo')); - - $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", xss_clean("Hello, i try to your site")); - } - - function test_sanitize_filename() - { - $this->assertEquals('hello.doc', sanitize_filename('hello.doc')); - - $filename = './'; - $this->assertEquals('foo', sanitize_filename($filename)); - } - - function test_do_hash() - { - $md5 = md5('foo'); - $sha1 = sha1('foo'); - - $algos = hash_algos(); - $algo_results = array(); - foreach ($algos as $k => $v) - { - $algo_results[$v] = hash($v, 'foo'); - } - - $this->assertEquals($sha1, do_hash('foo')); - $this->assertEquals($sha1, do_hash('foo', 'sha1')); - $this->assertEquals($md5, do_hash('foo', 'md5')); - $this->assertEquals($md5, do_hash('foo', 'foobar')); - - // Test each algorithm available to PHP - foreach ($algo_results as $algo => $result) - { - $this->assertEquals($result, do_hash('foo', $algo)); - } - } - - function test_strip_image_tags() - { - $this->assertEquals('http://example.com/spacer.gif', strip_image_tags('http://example.com/spacer.gif')); - - $this->assertEquals('http://example.com/spacer.gif', strip_image_tags('Who needs CSS when you have a spacer.gif?')); - } - - function test_encode_php_tags() - { - $this->assertEquals('<? echo $foo; ?>', encode_php_tags('')); - } - -} \ No newline at end of file diff --git a/tests/codeigniter/helpers/string_helper_test.php b/tests/codeigniter/helpers/string_helper_test.php deleted file mode 100644 index 75701ec13..000000000 --- a/tests/codeigniter/helpers/string_helper_test.php +++ /dev/null @@ -1,148 +0,0 @@ -helper('string'); - } - - public function test_strip_slashes() - { - $expected = array( - "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( - '//Slashes//\/' => 'Slashes//\\', - '/var/www/html/' => 'var/www/html' - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, trim_slashes($str)); - } - } - - // -------------------------------------------------------------------- - - public function test_strip_quotes() - { - $strs = array( - '"me oh my!"' => 'me oh my!', - "it's a winner!" => 'its a winner!', - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, strip_quotes($str)); - } - } - - // -------------------------------------------------------------------- - - public function test_quotes_to_entities() - { - $strs = array( - '"me oh my!"' => '"me oh my!"', - "it's a winner!" => 'it's a winner!', - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, quotes_to_entities($str)); - } - } - - // -------------------------------------------------------------------- - - public function test_reduce_double_slashes() - { - $strs = array( - 'http://codeigniter.com' => 'http://codeigniter.com', - '//var/www/html/example.com/' => '/var/www/html/example.com/', - '/var/www/html//index.php' => '/var/www/html/index.php' - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, reduce_double_slashes($str)); - } - } - - // -------------------------------------------------------------------- - - public function test_reduce_multiples() - { - $strs = array( - 'Fred, Bill,, Joe, Jimmy' => 'Fred, Bill, Joe, Jimmy', - 'Ringo, John, Paul,,' => 'Ringo, John, Paul,' - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, reduce_multiples($str)); - } - - $strs = array( - 'Fred, Bill,, Joe, Jimmy' => 'Fred, Bill, Joe, Jimmy', - 'Ringo, John, Paul,,' => 'Ringo, John, Paul' - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, reduce_multiples($str, ',', TRUE)); - } - } - - // -------------------------------------------------------------------- - - public function test_repeater() - { - $strs = array( - 'a' => 'aaaaaaaaaa', - ' ' => '          ', - '
    ' => '









    ' - - ); - - foreach ($strs as $str => $expect) - { - $this->assertEquals($expect, repeater($str, 10)); - } - } - - // -------------------------------------------------------------------- - - 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)); - } - - // -------------------------------------------------------------------- - - public function test_increment_string() - { - $this->assertEquals('my-test_1', increment_string('my-test')); - $this->assertEquals('my-test-1', increment_string('my-test', '-')); - $this->assertEquals('file_5', increment_string('file_4')); - $this->assertEquals('file-5', increment_string('file-4', '-')); - $this->assertEquals('file-5', increment_string('file-4', '-')); - $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 deleted file mode 100644 index 7a7dc0a12..000000000 --- a/tests/codeigniter/helpers/text_helper_test.php +++ /dev/null @@ -1,174 +0,0 @@ -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 = "\n<?php var_dump(\$this); ?> \n\n"; - - $this->assertEquals($expect, highlight_code('')); - } - - // ------------------------------------------------------------------------ - - public function test_highlight_phrase() - { - $strs = array( - 'this is a phrase' => 'this is a phrase', - 'this is another' => 'this is another', - 'Gimme a test, Sally' => 'Gimme a test, Sally', - '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')); - } - - $this->assertEquals('this is a strong test', highlight_phrase('this is a strong test', 'this is', '', '')); - } - - // ------------------------------------------------------------------------ - - 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 diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php deleted file mode 100644 index 83a8c0ec2..000000000 --- a/tests/codeigniter/helpers/url_helper_test.php +++ /dev/null @@ -1,89 +0,0 @@ -helper('url'); - } - - public function test_url_title() - { - $words = array( - 'foo bar /' => 'foo-bar', - '\ testing 12' => 'testing-12' - ); - - foreach ($words as $in => $out) - { - $this->assertEquals($out, url_title($in, 'dash', TRUE)); - } - } - - // -------------------------------------------------------------------- - - public function test_url_title_extra_dashes() - { - $words = array( - '_foo bar_' => 'foo_bar', - '_What\'s wrong with CSS?_' => 'Whats_wrong_with_CSS' - ); - - foreach ($words as $in => $out) - { - $this->assertEquals($out, url_title($in, 'underscore')); - } - } - - // -------------------------------------------------------------------- - - public function test_prep_url() - { - $this->assertEquals('http://codeigniter.com', prep_url('codeigniter.com')); - $this->assertEquals('http://www.codeigniter.com', prep_url('www.codeigniter.com')); - } - - // -------------------------------------------------------------------- - - public function test_auto_link_url() - { - $strings = array( - 'www.codeigniter.com test' => 'www.codeigniter.com test', - 'This is my noreply@codeigniter.com test' => 'This is my noreply@codeigniter.com test', - '
    www.google.com' => '
    www.google.com', - 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at www.codeigniter.com. Period test.', - 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at www.codeigniter.com, comma test', - 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' => 'This one: ://codeigniter.com must not break this one: http://codeigniter.com', - 'Trailing slash: https://codeigniter.com/ fubar' => 'Trailing slash: https://codeigniter.com/ fubar' - ); - - foreach ($strings as $in => $out) - { - $this->assertEquals($out, auto_link($in, 'url')); - } - } - - // -------------------------------------------------------------------- - - public function test_pull_675() - { - $strings = array( - '
    www.google.com' => '
    www.google.com', - ); - - foreach ($strings as $in => $out) - { - $this->assertEquals($out, auto_link($in, 'url')); - } - } - - // -------------------------------------------------------------------- - - public function test_issue_5331() - { - $this->assertEquals( - 'this is some text that includes '.safe_mailto('www.email@domain.com').' which is causing an issue', - auto_link('this is some text that includes www.email@domain.com which is causing an issue') - ); - } -} diff --git a/tests/codeigniter/helpers/xml_helper_test.php b/tests/codeigniter/helpers/xml_helper_test.php deleted file mode 100644 index e8cf411da..000000000 --- a/tests/codeigniter/helpers/xml_helper_test.php +++ /dev/null @@ -1,15 +0,0 @@ -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