2015-09-06 21:31:37 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* HttpUtils' tests
|
|
|
|
*/
|
|
|
|
|
2018-12-03 00:34:53 +01:00
|
|
|
namespace Shaarli\Http;
|
|
|
|
|
|
|
|
require_once 'application/http/HttpUtils.php';
|
2015-09-06 21:31:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unitary tests for index_url()
|
|
|
|
*/
|
2018-12-03 00:34:53 +01:00
|
|
|
class IndexUrlTest extends \PHPUnit\Framework\TestCase
|
2015-09-06 21:31:37 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* If on the main page, remove "index.php" from the URL resource
|
|
|
|
*/
|
|
|
|
public function testRemoveIndex()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
|
|
|
'http://host.tld/',
|
|
|
|
index_url(
|
|
|
|
array(
|
|
|
|
'HTTPS' => 'Off',
|
|
|
|
'SERVER_NAME' => 'host.tld',
|
|
|
|
'SERVER_PORT' => '80',
|
|
|
|
'SCRIPT_NAME' => '/index.php'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
'http://host.tld/admin/',
|
|
|
|
index_url(
|
|
|
|
array(
|
|
|
|
'HTTPS' => 'Off',
|
|
|
|
'SERVER_NAME' => 'host.tld',
|
|
|
|
'SERVER_PORT' => '80',
|
|
|
|
'SCRIPT_NAME' => '/admin/index.php'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The resource is != "index.php"
|
|
|
|
*/
|
|
|
|
public function testOtherResource()
|
|
|
|
{
|
|
|
|
$this->assertEquals(
|
|
|
|
'http://host.tld/page.php',
|
|
|
|
page_url(
|
|
|
|
array(
|
|
|
|
'HTTPS' => 'Off',
|
|
|
|
'SERVER_NAME' => 'host.tld',
|
|
|
|
'SERVER_PORT' => '80',
|
|
|
|
'SCRIPT_NAME' => '/page.php'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
'http://host.tld/admin/page.php',
|
|
|
|
page_url(
|
|
|
|
array(
|
|
|
|
'HTTPS' => 'Off',
|
|
|
|
'SERVER_NAME' => 'host.tld',
|
|
|
|
'SERVER_PORT' => '80',
|
|
|
|
'SCRIPT_NAME' => '/admin/page.php'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|