Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Use RequestMethodInterface constants
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Mar 7, 2018
1 parent 733306d commit 9c5dfc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions test/Middleware/PathBasedRoutingMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace ZendTest\Expressive\Router\Middleware;

use Fig\Http\Message\RequestMethodInterface as RequestMethod;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\Prophecy\ObjectProphecy;
Expand Down Expand Up @@ -72,11 +73,11 @@ public function process(
public function commonHttpMethods()
{
return [
'GET' => ['GET'],
'POST' => ['POST'],
'PUT' => ['PUT'],
'PATCH' => ['PATCH'],
'DELETE' => ['DELETE'],
RequestMethod::METHOD_GET => [RequestMethod::METHOD_GET],
RequestMethod::METHOD_POST => [RequestMethod::METHOD_POST],
RequestMethod::METHOD_PUT => [RequestMethod::METHOD_PUT],
RequestMethod::METHOD_PATCH => [RequestMethod::METHOD_PATCH],
RequestMethod::METHOD_DELETE => [RequestMethod::METHOD_DELETE],
];
}

Expand Down Expand Up @@ -178,7 +179,7 @@ public function testCommonHttpMethodsAreExposedAsClassMethodsAndReturnRoutes($me
public function testCreatingHttpRouteMethodWithExistingPathButDifferentMethodCreatesNewRouteInstance()
{
$this->router->addRoute(Argument::type(Route::class))->shouldBeCalledTimes(2);
$route = $this->middleware->route('/foo', $this->noopMiddleware, ['POST']);
$route = $this->middleware->route('/foo', $this->noopMiddleware, [RequestMethod::METHOD_POST]);

$middleware = $this->createNoopMiddleware();
$test = $this->middleware->get('/foo', $middleware);
Expand Down
8 changes: 4 additions & 4 deletions test/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ public function testRouteCanMatchMethod()

public function testRouteHeadMethodIsNotAllowedByDefault()
{
$route = new Route('/foo', $this->noopMiddleware, ['GET']);
$route = new Route('/foo', $this->noopMiddleware, [RequestMethod::METHOD_GET]);
$this->assertFalse($route->allowsMethod(RequestMethod::METHOD_HEAD));
}

public function testRouteOptionsMethodIsNotAllowedByDefault()
{
$route = new Route('/foo', $this->noopMiddleware, ['GET']);
$route = new Route('/foo', $this->noopMiddleware, [RequestMethod::METHOD_GET]);
$this->assertFalse($route->allowsMethod(RequestMethod::METHOD_OPTIONS));
}

Expand All @@ -103,7 +103,7 @@ public function testRouteNameForRouteAcceptingAnyMethodMatchesPathByDefault()

public function testRouteNameWithConstructor()
{
$route = new Route('/test', $this->noopMiddleware, ['GET'], 'test');
$route = new Route('/test', $this->noopMiddleware, [RequestMethod::METHOD_GET], 'test');
$this->assertSame('test', $route->getName());
}

Expand All @@ -116,7 +116,7 @@ public function testRouteNameWithGET()
public function testRouteNameWithGetAndPost()
{
$route = new Route('/test', $this->noopMiddleware, [RequestMethod::METHOD_GET, RequestMethod::METHOD_POST]);
$this->assertSame('/test^GET' . Route::HTTP_METHOD_SEPARATOR . 'POST', $route->getName());
$this->assertSame('/test^GET' . Route::HTTP_METHOD_SEPARATOR . RequestMethod::METHOD_POST, $route->getName());
}

public function testThrowsExceptionDuringConstructionIfPathIsNotString()
Expand Down

0 comments on commit 9c5dfc1

Please sign in to comment.