57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
// Simple test for simple routing
|
|
|
|
include('libraries/Routes.php');
|
|
include('libraries/Utils.php');
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
\PhangoApp\PhaRouter\Config::$home_module='welcome';
|
|
|
|
class RouterTest extends TestCase {
|
|
|
|
//Test routes
|
|
|
|
public function testGetHome() {
|
|
|
|
$path_info='';
|
|
|
|
$this->assertEquals('Welcome to the real world!', \PhangoApp\PhaRouter\get_route($path_info));
|
|
|
|
}
|
|
|
|
public function testGetGoodController() {
|
|
|
|
$path_info='/welcome/index/good';
|
|
|
|
$this->assertEquals('All things are good!', \PhangoApp\PhaRouter\get_route($path_info));
|
|
|
|
}
|
|
|
|
|
|
//Test paths format for not poison
|
|
|
|
public function testSimplePath() {
|
|
|
|
$this->assertEquals([], \PhangoApp\PhaRouter\filter_path(''));
|
|
|
|
$this->assertEquals([], \PhangoApp\PhaRouter\filter_path('/'));
|
|
|
|
$this->assertEquals([1 => 'nono'], \PhangoApp\PhaRouter\filter_path('/ñoño'));
|
|
|
|
$this->assertEquals([1 => 'nono', 2 => 'sucks'], \PhangoApp\PhaRouter\filter_path('/ñoño/sucks'));
|
|
|
|
$this->assertEquals([], \PhangoApp\PhaRouter\filter_path('/[]'));
|
|
|
|
$this->assertEquals([1 => 'asshole'], \PhangoApp\PhaRouter\filter_path('/[asshole]'));
|
|
|
|
$this->assertEquals([1 => 'asshole'], \PhangoApp\PhaRouter\filter_path('/"asshole'));
|
|
|
|
$this->assertEquals([1 => 'getcool'], \PhangoApp\PhaRouter\filter_path('/""""/getcool'));
|
|
|
|
$this->assertEquals([1 => 'etc', 2 => 'passwd'], \PhangoApp\PhaRouter\filter_path('/...../etc/passwd'));
|
|
|
|
}
|
|
|
|
}
|