3 * Unitary tests for cleanup_url()
6 require_once 'application/Url.php';
8 class CleanupUrlTest
extends PHPUnit_Framework_TestCase
11 * Clean empty UrlThanks for building nothing
13 public function testCleanupUrlEmpty()
15 $this->assertEquals('', cleanup_url(''));
19 * Clean an already cleaned Url
21 public function testCleanupUrlAlreadyClean()
23 $ref = 'http://domain.tld:3000';
24 $this->assertEquals($ref, cleanup_url($ref));
25 $ref = $ref.'/path/to/dir/';
26 $this->assertEquals($ref, cleanup_url($ref));
30 * Clean Url needing cleaning
32 public function testCleanupUrlNeedClean()
34 $ref = 'http://domain.tld:3000';
35 $this->assertEquals($ref, cleanup_url($ref.'#tk.rss_all'));
36 $this->assertEquals($ref, cleanup_url($ref.'#xtor=RSS-'));
37 $this->assertEquals($ref, cleanup_url($ref.'#xtor=RSS-U3ht0tkc4b'));
38 $this->assertEquals($ref, cleanup_url($ref.'?action_object_map=junk'));
39 $this->assertEquals($ref, cleanup_url($ref.'?action_ref_map=Cr4p!'));
40 $this->assertEquals($ref, cleanup_url($ref.'?action_type_map=g4R84g3'));
42 $this->assertEquals($ref, cleanup_url($ref.'?fb_stuff=v41u3'));
43 $this->assertEquals($ref, cleanup_url($ref.'?fb=71m3w4573'));
45 $this->assertEquals($ref, cleanup_url($ref.'?utm_campaign=zomg'));
46 $this->assertEquals($ref, cleanup_url($ref.'?utm_medium=numnum'));
47 $this->assertEquals($ref, cleanup_url($ref.'?utm_source=c0d3'));
48 $this->assertEquals($ref, cleanup_url($ref.'?utm_term=1n4l'));
50 $this->assertEquals($ref, cleanup_url($ref.'?xtor=some-url'));
51 $this->assertEquals($ref, cleanup_url($ref.'?xtor=some-url&fb=som3th1ng'));
52 $this->assertEquals($ref, cleanup_url(
53 $ref.'?fb=stuff&utm_campaign=zomg&utm_medium=numnum&utm_source=c0d3'
55 $this->assertEquals($ref, cleanup_url(
56 $ref.'?xtor=some-url&fb=som3th1ng#tk.rss_all'
59 // ditch annoying query params and fragment, keep useful params
61 $ref.'?my=stuff&is=kept',
63 $ref.'?fb=zomg&my=stuff&utm_medium=numnum&is=kept#tk.rss_all'
67 // ditch annoying query params, keep useful params and fragment
69 $ref.'?my=stuff&is=kept#again',
71 $ref.'?fb=zomg&my=stuff&utm_medium=numnum&is=kept#again'