blob: 30ba4a417c505982ac81bb37f0f9f50af608940a [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',
50 );
51
52 foreach ($strings as $in => $out)
53 {
54 $this->assertEquals($out, auto_link($in, 'url'));
55 }
56 }
Greg Aker2c4b3662011-08-21 16:28:06 -050057}