container);
$this->assertEquals(
'label',
$h->link('label', 'a', 'b', array('d' => 'e', 'plugin' => 'something'), false, 'f', 'g', true)
);
}
public function testPluginLinkWithRouteDefined()
{
$this->container['route']->enable();
$this->container['route']->addRoute('/myplugin/something/:d', 'a', 'b', 'something');
$h = new Url($this->container);
$this->assertEquals(
'label',
$h->link('label', 'a', 'b', array('d' => 'e', 'plugin' => 'something'), false, 'f', 'g', true)
);
}
public function testAppLink()
{
$h = new Url($this->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 testDir()
{
$this->container['request'] = new Request($this->container, array(
'PHP_SELF' => '/kanboard/index.php',
'REQUEST_METHOD' => 'GET'
)
);
$h = new Url($this->container);
$this->assertEquals('/kanboard/', $h->dir());
$this->container['request'] = new Request($this->container, array(
'PHP_SELF' => '/index.php',
'REQUEST_METHOD' => 'GET'
)
);
$h = new Url($this->container);
$this->assertEquals('/', $h->dir());
}
public function testServer()
{
$this->container['request'] = new Request($this->container, array(
'PHP_SELF' => '/index.php',
'REQUEST_METHOD' => 'GET',
'SERVER_NAME' => 'localhost',
'SERVER_PORT' => 80,
)
);
$h = new Url($this->container);
$this->assertEquals('http://localhost/', $h->server());
$this->container['request'] = new Request($this->container, array(
'PHP_SELF' => '/index.php',
'REQUEST_METHOD' => 'GET',
'SERVER_NAME' => 'kb',
'SERVER_PORT' => 1234,
)
);
$h = new Url($this->container);
$this->assertEquals('http://kb:1234/', $h->server());
}
public function testBase()
{
$this->container['request'] = new Request($this->container, array(
'PHP_SELF' => '/index.php',
'REQUEST_METHOD' => 'GET',
'SERVER_NAME' => 'kb',
'SERVER_PORT' => 1234,
)
);
$h = new Url($this->container);
$this->assertEquals('http://kb:1234/', $h->base());
$c = new Config($this->container);
$c->save(array('application_url' => 'https://mykanboard/'));
$this->container['memoryCache']->flush();
$h = new Url($this->container);
$this->assertEquals('https://mykanboard/', $c->get('application_url'));
$this->assertEquals('https://mykanboard/', $h->base());
}
}