blob: 5fc3642383e5fb160f884e539a4ba95708b6fdea [file] [log] [blame]
Greg Aker2c4b3662011-08-21 16:28:06 -05001<?php
2
Taufan Adityae1dc9ea2012-03-28 16:49:49 +07003class Url_helper_test extends CI_TestCase {
Greg Aker2c4b3662011-08-21 16:28:06 -05004
Taufan Adityae1dc9ea2012-03-28 16:49:49 +07005 public function set_up()
6 {
7 $this->helper('url');
8 }
9
Greg Aker2c4b3662011-08-21 16:28:06 -050010 public function test_url_title()
11 {
12 $words = array(
13 'foo bar /' => 'foo-bar',
14 '\ testing 12' => 'testing-12'
15 );
Eric Barnes94076142011-11-27 00:59:07 -050016
Greg Aker2c4b3662011-08-21 16:28:06 -050017 foreach ($words as $in => $out)
18 {
19 $this->assertEquals($out, url_title($in, 'dash', TRUE));
Eric Barnes94076142011-11-27 00:59:07 -050020 }
Greg Aker2c4b3662011-08-21 16:28:06 -050021 }
22
23 // --------------------------------------------------------------------
24
Eric Barnes94076142011-11-27 00:59:07 -050025 public function test_url_title_extra_dashes()
26 {
27 $words = array(
28 '_foo bar_' => 'foo_bar',
29 '_What\'s wrong with CSS?_' => 'Whats_wrong_with_CSS'
30 );
31
32 foreach ($words as $in => $out)
33 {
34 $this->assertEquals($out, url_title($in, 'underscore'));
35 }
36 }
Eric Barnes32b67802011-11-27 01:10:09 -050037
38 // --------------------------------------------------------------------
39
40 public function test_prep_url()
41 {
42 $this->assertEquals('http://codeigniter.com', prep_url('codeigniter.com'));
43 $this->assertEquals('http://www.codeigniter.com', prep_url('www.codeigniter.com'));
44 }
45
46 // --------------------------------------------------------------------
47
48 public function test_auto_link_url()
49 {
50 $strings = array(
51 'www.codeigniter.com test' => '<a href="http://www.codeigniter.com">http://www.codeigniter.com</a> test',
52 'This is my noreply@codeigniter.com test' => 'This is my noreply@codeigniter.com test',
Eric Barnesd90e1a02011-11-27 14:12:46 -050053 '<br />www.google.com' => '<br /><a href="http://www.google.com">http://www.google.com</a>',
Andrey Andreev929e1242012-10-19 10:09:28 +030054 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">http://www.codeigniter.com</a>. Period test.',
55 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">http://www.codeigniter.com</a>, comma test'
Eric Barnesd90e1a02011-11-27 14:12:46 -050056 );
57
58 foreach ($strings as $in => $out)
59 {
60 $this->assertEquals($out, auto_link($in, 'url'));
61 }
62 }
63
64 // --------------------------------------------------------------------
65
66 public function test_pull_675()
67 {
68 $strings = array(
69 '<br />www.google.com' => '<br /><a href="http://www.google.com">http://www.google.com</a>',
Eric Barnes32b67802011-11-27 01:10:09 -050070 );
71
72 foreach ($strings as $in => $out)
73 {
74 $this->assertEquals($out, auto_link($in, 'url'));
75 }
76 }
Andrey Andreev99b782d2012-06-09 22:24:46 +030077
Greg Aker2c4b3662011-08-21 16:28:06 -050078}