blob: c81c5f1b8a994fc70fe33fc96561e8a0851ece06 [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>',
54 );
55
56 foreach ($strings as $in => $out)
57 {
58 $this->assertEquals($out, auto_link($in, 'url'));
59 }
60 }
61
62 // --------------------------------------------------------------------
63
64 public function test_pull_675()
65 {
66 $strings = array(
67 '<br />www.google.com' => '<br /><a href="http://www.google.com">http://www.google.com</a>',
Eric Barnes32b67802011-11-27 01:10:09 -050068 );
69
70 foreach ($strings as $in => $out)
71 {
72 $this->assertEquals($out, auto_link($in, 'url'));
73 }
74 }
Andrey Andreev99b782d2012-06-09 22:24:46 +030075
Greg Aker2c4b3662011-08-21 16:28:06 -050076}