more tests
This commit is contained in:
parent
e0d9a20f4c
commit
1edb7b6126
2 changed files with 12 additions and 8 deletions
|
@ -165,20 +165,24 @@ class UtilTest extends TestCase
|
||||||
|
|
||||||
public function test_get_query(): void
|
public function test_get_query(): void
|
||||||
{
|
{
|
||||||
// no query string
|
// niceurls
|
||||||
$_SERVER["REQUEST_URI"] = "/tasty/cake";
|
$_SERVER["REQUEST_URI"] = "/test/tasty/cake";
|
||||||
$this->assertEquals("/tasty/cake", _get_query());
|
$this->assertEquals("/tasty/cake", _get_query());
|
||||||
|
|
||||||
// query string
|
// no niceurls
|
||||||
$_SERVER["REQUEST_URI"] = "index.php?q=/tasty/cake";
|
$_SERVER["REQUEST_URI"] = "/test/index.php?q=/tasty/cake";
|
||||||
$this->assertEquals("/tasty/cake", _get_query());
|
$this->assertEquals("/tasty/cake", _get_query());
|
||||||
|
|
||||||
// leave url encoding alone
|
// leave url encoding alone
|
||||||
$_SERVER["REQUEST_URI"] = "index.php?q=/tasty/cake%20pie";
|
$_SERVER["REQUEST_URI"] = "/test/index.php?q=/tasty/cake%20pie";
|
||||||
$this->assertEquals("/tasty/cake%20pie", _get_query());
|
$this->assertEquals("/tasty/cake%20pie", _get_query());
|
||||||
|
|
||||||
// if just viewing index.php
|
// if just viewing index.php
|
||||||
$_SERVER["REQUEST_URI"] = "index.php";
|
$_SERVER["REQUEST_URI"] = "/test/index.php";
|
||||||
|
$this->assertEquals("/", _get_query());
|
||||||
|
|
||||||
|
// niceurl root
|
||||||
|
$_SERVER["REQUEST_URI"] = "/test/";
|
||||||
$this->assertEquals("/", _get_query());
|
$this->assertEquals("/", _get_query());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -740,8 +740,8 @@ function _get_query(): string
|
||||||
return "/";
|
return "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise, use the request URI
|
// otherwise, use the request URI minus the base path
|
||||||
return $parts["path"];
|
return substr($parts["path"], strlen(get_base_href()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue