parent
1ff3149636
commit
a84e0c4d84
|
@ -9,6 +9,68 @@ use Icinga\Test\BaseTestCase;
|
||||||
|
|
||||||
class UrlTest extends BaseTestCase
|
class UrlTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
public function testWhetherFromPathCutsOfTheFirstCharOfThePathIfUrlIsInternalAndHasAUsernameInIt()
|
||||||
|
{
|
||||||
|
$this->getRequestMock()->shouldReceive('getServer')->with("SERVER_NAME")->andReturn('localhost')
|
||||||
|
->shouldReceive('getServer')->with("SERVER_PORT")->andReturn('8080');
|
||||||
|
|
||||||
|
$url = Url::fromPath('http://testusername:testpassword@localhost:8080/path/to/my/url.html');
|
||||||
|
$this->assertEquals(
|
||||||
|
'path/to/my/url.html',
|
||||||
|
$url->getPath(),
|
||||||
|
'Url::fromPath does not cut of the first char of path if the url is internal and has a username in it'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWhetherGetAbsoluteUrlReturnsTheBasePathIfUrlIsInternalAndHasAUsernameInIt()
|
||||||
|
{
|
||||||
|
$this->getRequestMock()->shouldReceive('getServer')->with("SERVER_NAME")->andReturn('localhost')
|
||||||
|
->shouldReceive('getServer')->with("SERVER_PORT")->andReturn('8080');
|
||||||
|
|
||||||
|
$url = Url::fromPath('http://testusername:testpassword@localhost:8080/path/to/my/url.html');
|
||||||
|
$this->assertEquals(
|
||||||
|
'http://testusername:testpassword@localhost:8080/path/to/my/url.html',
|
||||||
|
$url->getAbsoluteUrl(),
|
||||||
|
'Url::getAbsoluteUrl does not reassemble the correct basePath'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWhetherGetAbsoluteUrlReturnsTheBasePathIfUrlIsInternalAndHasNoUsernameInIt()
|
||||||
|
{
|
||||||
|
$url = Url::fromPath('/path/to/my/url.html');
|
||||||
|
$this->assertEquals(
|
||||||
|
'/path/to/my/url.html',
|
||||||
|
$url->getAbsoluteUrl(),
|
||||||
|
'Url::getAbsoluteUrl does not reassemble the correct basePath'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWhetherGetAbsoluteUrlReturnsTheBasePathIfUrlIsExternalAndHasAUsernameInIt()
|
||||||
|
{
|
||||||
|
$this->getRequestMock()->shouldReceive('getServer')->with("SERVER_NAME")->andReturn('localhost')
|
||||||
|
->shouldReceive('getServer')->with("SERVER_PORT")->andReturn('8080');
|
||||||
|
|
||||||
|
$url = Url::fromPath('http://testusername:testpassword@testhost/path/to/my/url.html');
|
||||||
|
$this->assertEquals(
|
||||||
|
'http://testusername:testpassword@testhost/path/to/my/url.html',
|
||||||
|
$url->getAbsoluteUrl(),
|
||||||
|
'Url::getAbsoluteUrl does not reassemble the correct basePath'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWhetherGetAbsoluteUrlReturnsTheBasePathIfUrlIsExternalAndHasNoUsernameInIt()
|
||||||
|
{
|
||||||
|
$this->getRequestMock()->shouldReceive('getServer')->with("SERVER_NAME")->andReturn('localhost')
|
||||||
|
->shouldReceive('getServer')->with("SERVER_PORT")->andReturn('8080');
|
||||||
|
|
||||||
|
$url = Url::fromPath('http://testhost/path/to/my/url.html');
|
||||||
|
$this->assertEquals(
|
||||||
|
'http://testhost/path/to/my/url.html',
|
||||||
|
$url->getAbsoluteUrl(),
|
||||||
|
'Url::getAbsoluteUrl does not reassemble the correct basePath'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testWhetherGetAbsoluteUrlReturnsTheGivenUsernameAndPassword()
|
public function testWhetherGetAbsoluteUrlReturnsTheGivenUsernameAndPassword()
|
||||||
{
|
{
|
||||||
$url = Url::fromPath('http://testusername:testpassword@testsite.com/path/to/my/url.html');
|
$url = Url::fromPath('http://testusername:testpassword@testsite.com/path/to/my/url.html');
|
||||||
|
|
Loading…
Reference in New Issue