| Server IP : 162.214.74.102 / Your IP : 216.73.216.59 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/www/lrsys_apps/rodeio/vendor/mikecao/flight/tests/ |
Upload File : |
<?php
/**
* Flight: An extensible micro-framework.
*
* @copyright Copyright (c) 2013, Mike Cao <mike@mikecao.com>
* @license MIT, http://flightphp.com/license
*/
require_once 'vendor/autoload.php';
require_once __DIR__.'/../flight/autoload.php';
class RedirectTest extends PHPUnit_Framework_TestCase
{
/**
* @var \flight\Engine
*/
private $app;
function getBaseUrl($base, $url){
if ($base != '/' && strpos($url, '://') === false) {
$url = preg_replace('#/+#', '/', $base.'/'.$url);
}
return $url;
}
function setUp() {
$_SERVER['SCRIPT_NAME'] = '/subdir/index.php';
$this->app = new \flight\Engine();
$this->app->set('flight.base_url', '/testdir');
}
// The base should be the subdirectory
function testBase(){
$base = $this->app->request()->base;
$this->assertEquals('/subdir', $base);
}
// Absolute URLs should include the base
function testAbsoluteUrl(){
$url = '/login';
$base = $this->app->request()->base;
$this->assertEquals('/subdir/login', $this->getBaseUrl($base, $url));
}
// Relative URLs should include the base
function testRelativeUrl(){
$url = 'login';
$base = $this->app->request()->base;
$this->assertEquals('/subdir/login', $this->getBaseUrl($base, $url));
}
// External URLs should ignore the base
function testHttpUrl(){
$url = 'http://www.yahoo.com';
$base = $this->app->request()->base;
$this->assertEquals('http://www.yahoo.com', $this->getBaseUrl($base, $url));
}
// Configuration should override derived value
function testBaseOverride(){
$url = 'login';
if ($this->app->get('flight.base_url') !== null) {
$base = $this->app->get('flight.base_url');
}
else {
$base = $this->app->request()->base;
}
$this->assertEquals('/testdir/login', $this->getBaseUrl($base, $url));
}
}