Add an uglyUrls option that disables URL rewriting (fixes #88)
This commit is contained in:
parent
4562c88859
commit
9f112c15b9
8 changed files with 162 additions and 0 deletions
82
tests/UglyRouterTest.php
Normal file
82
tests/UglyRouterTest.php
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/**
|
||||
* UglyRouterTest class.
|
||||
*/
|
||||
|
||||
namespace Alltube\Test;
|
||||
|
||||
use Alltube\UglyRouter;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Uri;
|
||||
use Slim\Http\Headers;
|
||||
use Slim\Http\Environment;
|
||||
use Slim\Http\Stream;
|
||||
|
||||
/**
|
||||
* Unit tests for the UglyRouter class.
|
||||
*/
|
||||
class UglyRouterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* UglyRouter instance.
|
||||
*
|
||||
* @var UglyRouter
|
||||
*/
|
||||
private $router;
|
||||
|
||||
/**
|
||||
* Prepare tests.
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->router = new UglyRouter();
|
||||
$this->router->map(['GET'], '/foo', 'print')->setName('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the dispatch() function.
|
||||
* @return void
|
||||
*/
|
||||
public function testDispatch()
|
||||
{
|
||||
$this->assertEquals(
|
||||
[1, 'route0', []],
|
||||
$this->router->dispatch(
|
||||
new Request(
|
||||
'GET',
|
||||
Uri::createFromString('http://example.com/?page=foo'),
|
||||
Headers::createFromEnvironment(new Environment()),
|
||||
[],
|
||||
[],
|
||||
new Stream(fopen('php://temp', 'r'))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the pathFor() function.
|
||||
* @return void
|
||||
*/
|
||||
public function testPathFor()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'/?page=foo',
|
||||
$this->router->pathFor('foo', [], [])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the pathFor() function with a base path.
|
||||
* @return void
|
||||
*/
|
||||
public function testPathForWithBasePath()
|
||||
{
|
||||
|
||||
$this->router->setBasePath('/bar');
|
||||
$this->assertEquals(
|
||||
'/bar/?page=foo',
|
||||
$this->router->pathFor('foo', [], [])
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue