]> git.wh0rd.org - tt-rss.git/blame - tests/FunctionsTest.php
add unit tests for fix_url() and fix a bug I discovered because of them - protocols...
[tt-rss.git] / tests / FunctionsTest.php
CommitLineData
44453773
CW
1<?php
2require_once dirname(__FILE__) . '/../functions.php';
3/**
4 * Unit tests for functions.php
5 *
6 * @author Christian Weiske <cweiske@php.net>
7 */
8class FunctionsTest extends PHPUnit_Framework_TestCase
9{
10 /**
11 * Test fix_url with feed:// urls
12 */
13 public function testFixUrlFeed()
14 {
15 $this->assertEquals('http://tt-rss.org/', fix_url('feed://tt-rss.org'));
16 $this->assertEquals('http://tt-rss.org/', fix_url('feed://tt-rss.org/'));
17 }
18
19 /**
20 * Test fix_url with non-http protocols
21 */
22 public function testFixUrlProtocols()
23 {
24 $this->assertEquals('https://tt-rss.org/', fix_url('https://tt-rss.org'));
25 $this->assertEquals('ftp://tt-rss.org/', fix_url('ftp://tt-rss.org/'));
26 $this->assertEquals(
27 'reallylongprotocolisthat://tt-rss.org/',
28 fix_url('reallylongprotocolisthat://tt-rss.org')
29 );
30 }
31
32 /**
33 * Test fix_url with domain names only
34 */
35 public function testFixUrlDomainOnly()
36 {
37 $this->assertEquals('http://tt-rss.org/', fix_url('tt-rss.org'));
38 $this->assertEquals('http://tt-rss.org/', fix_url('tt-rss.org/'));
39 $this->assertEquals('http://tt-rss.org/', fix_url('http://tt-rss.org'));
40 $this->assertEquals('http://tt-rss.org/', fix_url('http://tt-rss.org/'));
41 }
42
43 /**
44 * Test fix_url with domain + paths
45 */
46 public function testFixUrlWithPaths()
47 {
48 $this->assertEquals('http://tt-rss.org/foo', fix_url('tt-rss.org/foo'));
49
50 $this->assertEquals(
51 'http://tt-rss.org/foo/bar/baz',
52 fix_url('tt-rss.org/foo/bar/baz')
53 );
54 $this->assertEquals(
55 'http://tt-rss.org/foo/bar/baz/',
56 fix_url('tt-rss.org/foo/bar/baz/')
57 );
58 }
59}
60
61?>