Greg Aker | 2c4b366 | 2011-08-21 16:28:06 -0500 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | require_once(BASEPATH.'helpers/url_helper.php'); |
| 4 | |
| 5 | class Url_helper_test extends CI_TestCase |
| 6 | { |
| 7 | public function test_url_title() |
| 8 | { |
| 9 | $words = array( |
| 10 | 'foo bar /' => 'foo-bar', |
| 11 | '\ testing 12' => 'testing-12' |
| 12 | ); |
Eric Barnes | 9407614 | 2011-11-27 00:59:07 -0500 | [diff] [blame] | 13 | |
Greg Aker | 2c4b366 | 2011-08-21 16:28:06 -0500 | [diff] [blame] | 14 | foreach ($words as $in => $out) |
| 15 | { |
| 16 | $this->assertEquals($out, url_title($in, 'dash', TRUE)); |
Eric Barnes | 9407614 | 2011-11-27 00:59:07 -0500 | [diff] [blame] | 17 | } |
Greg Aker | 2c4b366 | 2011-08-21 16:28:06 -0500 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | // -------------------------------------------------------------------- |
| 21 | |
Eric Barnes | 9407614 | 2011-11-27 00:59:07 -0500 | [diff] [blame] | 22 | public function test_url_title_extra_dashes() |
| 23 | { |
| 24 | $words = array( |
| 25 | '_foo bar_' => 'foo_bar', |
| 26 | '_What\'s wrong with CSS?_' => 'Whats_wrong_with_CSS' |
| 27 | ); |
| 28 | |
| 29 | foreach ($words as $in => $out) |
| 30 | { |
| 31 | $this->assertEquals($out, url_title($in, 'underscore')); |
| 32 | } |
| 33 | } |
Eric Barnes | 32b6780 | 2011-11-27 01:10:09 -0500 | [diff] [blame] | 34 | |
| 35 | // -------------------------------------------------------------------- |
| 36 | |
| 37 | public function test_prep_url() |
| 38 | { |
| 39 | $this->assertEquals('http://codeigniter.com', prep_url('codeigniter.com')); |
| 40 | $this->assertEquals('http://www.codeigniter.com', prep_url('www.codeigniter.com')); |
| 41 | } |
| 42 | |
| 43 | // -------------------------------------------------------------------- |
| 44 | |
| 45 | public function test_auto_link_url() |
| 46 | { |
| 47 | $strings = array( |
| 48 | 'www.codeigniter.com test' => '<a href="http://www.codeigniter.com">http://www.codeigniter.com</a> test', |
| 49 | 'This is my noreply@codeigniter.com test' => 'This is my noreply@codeigniter.com test', |
Eric Barnes | d90e1a0 | 2011-11-27 14:12:46 -0500 | [diff] [blame] | 50 | '<br />www.google.com' => '<br /><a href="http://www.google.com">http://www.google.com</a>', |
| 51 | ); |
| 52 | |
| 53 | foreach ($strings as $in => $out) |
| 54 | { |
| 55 | $this->assertEquals($out, auto_link($in, 'url')); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | // -------------------------------------------------------------------- |
| 60 | |
| 61 | public function test_pull_675() |
| 62 | { |
| 63 | $strings = array( |
| 64 | '<br />www.google.com' => '<br /><a href="http://www.google.com">http://www.google.com</a>', |
Eric Barnes | 32b6780 | 2011-11-27 01:10:09 -0500 | [diff] [blame] | 65 | ); |
| 66 | |
| 67 | foreach ($strings as $in => $out) |
| 68 | { |
| 69 | $this->assertEquals($out, auto_link($in, 'url')); |
| 70 | } |
| 71 | } |
Greg Aker | 2c4b366 | 2011-08-21 16:28:06 -0500 | [diff] [blame] | 72 | } |