blob: 51a8cc7c08facf39fe351aae56e2e30556c716c1 [file] [log] [blame]
Greg Aker2c4b3662011-08-21 16:28:06 -05001<?php
2
3require_once(BASEPATH.'helpers/url_helper.php');
4
5class 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 Barnes94076142011-11-27 00:59:07 -050013
Greg Aker2c4b3662011-08-21 16:28:06 -050014 foreach ($words as $in => $out)
15 {
16 $this->assertEquals($out, url_title($in, 'dash', TRUE));
Eric Barnes94076142011-11-27 00:59:07 -050017 }
Greg Aker2c4b3662011-08-21 16:28:06 -050018 }
19
20 // --------------------------------------------------------------------
21
Eric Barnes94076142011-11-27 00:59:07 -050022 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 Barnes32b67802011-11-27 01:10:09 -050034
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 Barnesd90e1a02011-11-27 14:12:46 -050050 '<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 Barnes32b67802011-11-27 01:10:09 -050065 );
66
67 foreach ($strings as $in => $out)
68 {
69 $this->assertEquals($out, auto_link($in, 'url'));
70 }
71 }
Greg Aker2c4b3662011-08-21 16:28:06 -050072}