Update Handler tests

This commit is contained in:
PJ Dietz 2014-07-26 05:20:22 -04:00
parent 4ae6e5f2e4
commit 1222e61ebb
1 changed files with 6 additions and 10 deletions

View File

@ -2,23 +2,23 @@
namespace pjdietz\WellRESTed\Test;
use pjdietz\WellRESTed\Exceptions\HttpExceptions\HttpException;
use pjdietz\WellRESTed\Exceptions\HttpExceptions\NotFoundException;
use pjdietz\WellRESTed\Handler;
class HandlerTest extends \PHPUnit_Framework_TestCase
{
public function testResponse()
public function testGetResponse()
{
$mockRequest = $this->getMock('\pjdietz\WellRESTed\Interfaces\RequestInterface');
$mockHandler = $this->getMockForAbstractClass('\pjdietz\WellRESTed\Handler');
/** @var \pjdietz\WellRESTed\Handler $mockHandler */
$this->assertNotNull($mockHandler->getResponse($mockRequest));
}
/**
* @dataProvider verbProvider
*/
public function testVerb($verb)
public function testCallMethodForHttpVerb($verb)
{
$mockRequest = $this->getMock('\pjdietz\WellRESTed\Interfaces\RequestInterface');
$mockRequest->expects($this->any())
@ -26,6 +26,7 @@ class HandlerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($verb));
$mockHandler = $this->getMockForAbstractClass('\pjdietz\WellRESTed\Handler');
/** @var \pjdietz\WellRESTed\Handler $mockHandler */
$this->assertNotNull($mockHandler->getResponse($mockRequest));
}
@ -43,7 +44,7 @@ class HandlerTest extends \PHPUnit_Framework_TestCase
];
}
public function testHttException()
public function testTranslateHttpExceptionToResponse()
{
$mockRequest = $this->getMock('\pjdietz\WellRESTed\Interfaces\RequestInterface');
$mockRequest->expects($this->any())
@ -55,18 +56,13 @@ class HandlerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(404, $resp->getStatusCode());
}
public function testAllowedMethods()
public function testReadAllowedMethods()
{
$mockRequest = $this->getMock('\pjdietz\WellRESTed\Interfaces\RequestInterface');
$mockRequest->expects($this->any())
->method('getMethod')
->will($this->returnValue("OPTIONS"));
$mockHandler = $this->getMockForAbstractClass('\pjdietz\WellRESTed\Handler');
$mockHandler->expects($this->any())
->method('getAllowedMethods')
->will($this->returnValue(["GET","POST"]));
$handler = new OptionsHandler();
$resp = $handler->getResponse($mockRequest);