From eeac2329baab1fdae7cbf6c707ed2ffd8beb4c1b Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 24 May 2015 16:02:25 -0400 Subject: Helpers refactoring --- tests/units/UrlHelperTest.php | 64 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/units/UrlHelperTest.php (limited to 'tests/units/UrlHelperTest.php') diff --git a/tests/units/UrlHelperTest.php b/tests/units/UrlHelperTest.php new file mode 100644 index 00000000..d70842aa --- /dev/null +++ b/tests/units/UrlHelperTest.php @@ -0,0 +1,64 @@ +container); + $this->assertEquals( + 'label', + $h->link('label', 'a', 'b', array('d' => 'e'), false, 'f', 'g', true) + ); + } + + public function testHref() + { + $h = new Url($this->container); + $this->assertEquals( + '?controller=a&action=b&d=e', + $h->href('a', 'b', array('d' => 'e')) + ); + } + + public function testTo() + { + $h = new Url($this->container); + $this->assertEquals( + '?controller=a&action=b&d=e', + $h->to('a', 'b', array('d' => 'e')) + ); + } + + public function testServer() + { + $h = new Url($this->container); + + $_SERVER['PHP_SELF'] = '/'; + $_SERVER['SERVER_NAME'] = 'localhost'; + $_SERVER['SERVER_PORT'] = 1234; + + $this->assertEquals('http://localhost:1234/', $h->server()); + } + + public function testBase() + { + $h = new Url($this->container); + + $_SERVER['PHP_SELF'] = '/'; + $_SERVER['SERVER_NAME'] = 'localhost'; + $_SERVER['SERVER_PORT'] = 1234; + + $this->assertEquals('http://localhost:1234/', $h->base()); + + $c = new Config($this->container); + $c->save(array('application_url' => 'https://mykanboard/')); + + $this->assertEquals('https://mykanboard/', $c->get('application_url')); + $this->assertEquals('https://mykanboard/', $h->base()); + } +} -- cgit v1.2.3