Modify RouterTest (unmocked simply methods).
This commit is contained in:
@ -84,20 +84,16 @@ class RouterTest extends PHPUnit_Framework_TestCase
|
|||||||
->method('getUri')
|
->method('getUri')
|
||||||
->with()
|
->with()
|
||||||
->will($this->returnValue($uri));
|
->will($this->returnValue($uri));
|
||||||
$router_mock = $this->getMockBuilder('Router')
|
$router = new Router();
|
||||||
->disableOriginalConstructor()
|
$reflection = new ReflectionProperty('Router', 'route');
|
||||||
->setMethods(array('getRoute'))
|
$reflection->setAccessible(true);
|
||||||
->getMock();
|
$reflection->setValue($router, $route_mock);
|
||||||
$router_mock->expects($this->once())
|
$this->assertEquals($uri, $router->getUri($name));
|
||||||
->method('getRoute')
|
|
||||||
->with()
|
|
||||||
->will($this->returnValue($route_mock));
|
|
||||||
$this->assertEquals($uri, $router_mock->getUri($name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetUriWithNamed()
|
public function testGetUriWithNamed()
|
||||||
{
|
{
|
||||||
$name = 'name of route';
|
$name = 'nameofroute';
|
||||||
$uri = 'uri from route.';
|
$uri = 'uri from route.';
|
||||||
$route_mock = $this->getMockBuilder('Route')
|
$route_mock = $this->getMockBuilder('Route')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
@ -107,21 +103,11 @@ class RouterTest extends PHPUnit_Framework_TestCase
|
|||||||
->method('getUri')
|
->method('getUri')
|
||||||
->with()
|
->with()
|
||||||
->will($this->returnValue($uri));
|
->will($this->returnValue($uri));
|
||||||
$router_mock = $this->getMockBuilder('Router')
|
$router = new Router();
|
||||||
->disableOriginalConstructor()
|
$reflection = new ReflectionProperty('Router', 'routes');
|
||||||
->setMethods(array('getRoute', 'routeIsExists', 'getRouteByName'))
|
$reflection->setAccessible(true);
|
||||||
->getMock();
|
$reflection->setValue($router, array($name => $route_mock));
|
||||||
$router_mock->expects($this->never())
|
$this->assertEquals($uri, $router->getUri($name));
|
||||||
->method('getRoute');
|
|
||||||
$router_mock->expects($this->at(0))
|
|
||||||
->method('routeIsExists')
|
|
||||||
->with($this->equalTo($name))
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
$router_mock->expects($this->at(1))
|
|
||||||
->method('getRouteByName')
|
|
||||||
->with($this->equalTo($name))
|
|
||||||
->will($this->returnValue($route_mock));
|
|
||||||
$this->assertEquals($uri, $router_mock->getUri($name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetUriWithNamedWithError()
|
public function testGetUriWithNamedWithError()
|
||||||
@ -129,14 +115,10 @@ class RouterTest extends PHPUnit_Framework_TestCase
|
|||||||
$name = 'name of route';
|
$name = 'name of route';
|
||||||
$router_mock = $this->getMockBuilder('Router')
|
$router_mock = $this->getMockBuilder('Router')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(array('getRoute', 'routeIsExists', 'getRouteByName'))
|
->setMethods(array('getRoute', 'getRouteByName'))
|
||||||
->getMock();
|
->getMock();
|
||||||
$router_mock->expects($this->never())
|
$router_mock->expects($this->never())
|
||||||
->method('getRoute');
|
->method('getRoute');
|
||||||
$router_mock->expects($this->once())
|
|
||||||
->method('routeIsExists')
|
|
||||||
->with($this->equalTo($name))
|
|
||||||
->will($this->returnValue(false));
|
|
||||||
$router_mock->expects($this->never())
|
$router_mock->expects($this->never())
|
||||||
->method('getRouteByName');
|
->method('getRouteByName');
|
||||||
$this->setExpectedException('ErrorException');
|
$this->setExpectedException('ErrorException');
|
||||||
|
Reference in New Issue
Block a user