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

Commit 73ed724

Browse files
committed
Update to the latest zend-expressive-router dependency rc4
Removed all irrelevant tests - it is no longer possible to add route without any HTTP method
1 parent 9c969c6 commit 73ed724

File tree

3 files changed

+29
-145
lines changed

3 files changed

+29
-145
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"psr/http-message": "^1.0.1",
2929
"psr/http-server-middleware": "^1.0",
3030
"zendframework/zend-diactoros": "^1.3.10",
31-
"zendframework/zend-expressive-router": "^3.0.0rc2",
31+
"zendframework/zend-expressive-router": "^3.0.0rc4",
3232
"zendframework/zend-expressive-template": "^2.0.0alpha1",
3333
"zendframework/zend-httphandlerrunner": "^1.0.1",
3434
"zendframework/zend-stratigility": "^3.0.0rc1"
@@ -41,9 +41,9 @@
4141
"phpstan/phpstan-strict-rules": "^0.9",
4242
"phpunit/phpunit": "^7.0.1",
4343
"zendframework/zend-coding-standard": "~1.0.0",
44-
"zendframework/zend-expressive-aurarouter": "^3.0.0rc2",
45-
"zendframework/zend-expressive-fastroute": "^3.0.0rc2",
46-
"zendframework/zend-expressive-zendrouter": "^3.0.0rc2",
44+
"zendframework/zend-expressive-aurarouter": "^3.0.0rc3",
45+
"zendframework/zend-expressive-fastroute": "^3.0.0rc4",
46+
"zendframework/zend-expressive-zendrouter": "^3.0.0rc3",
4747
"zendframework/zend-servicemanager": "^2.7.8 || ^3.3"
4848
},
4949
"conflict": {

composer.lock

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/Router/IntegrationTest.php

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,15 @@
1111

1212
use Fig\Http\Message\RequestMethodInterface as RequestMethod;
1313
use Fig\Http\Message\StatusCodeInterface as StatusCode;
14-
use PHPUnit\Framework\Assert;
1514
use PHPUnit\Framework\TestCase;
1615
use Prophecy\Argument;
1716
use Prophecy\Prophecy\ObjectProphecy;
1817
use Psr\Container\ContainerInterface;
19-
use Psr\Http\Message\ServerRequestInterface;
20-
use Psr\Http\Server\MiddlewareInterface;
2118
use Psr\Http\Server\RequestHandlerInterface;
2219
use Zend\Diactoros\Response;
2320
use Zend\Diactoros\ServerRequest;
2421
use Zend\Diactoros\Stream;
2522
use Zend\Expressive\Application;
26-
use Zend\Expressive\Middleware;
2723
use Zend\Expressive\MiddlewareContainer;
2824
use Zend\Expressive\MiddlewareFactory;
2925
use Zend\Expressive\Router\AuraRouter;
@@ -33,7 +29,6 @@
3329
use Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware;
3430
use Zend\Expressive\Router\Middleware\MethodNotAllowedMiddleware;
3531
use Zend\Expressive\Router\Middleware\PathBasedRoutingMiddleware as RouteMiddleware;
36-
use Zend\Expressive\Router\RouteResult;
3732
use Zend\Expressive\Router\RouterInterface;
3833
use Zend\Expressive\Router\ZendRouter;
3934
use Zend\HttpHandlerRunner\RequestHandlerRunner;
@@ -403,26 +398,6 @@ public function allowedMethod()
403398
];
404399
}
405400

406-
public function notAllowedMethod()
407-
{
408-
return [
409-
'aura-get' => [AuraRouter::class, RequestMethod::METHOD_GET],
410-
'aura-post' => [AuraRouter::class, RequestMethod::METHOD_POST],
411-
'aura-put' => [AuraRouter::class, RequestMethod::METHOD_PUT],
412-
'aura-delete' => [AuraRouter::class, RequestMethod::METHOD_DELETE],
413-
'aura-patch' => [AuraRouter::class, RequestMethod::METHOD_PATCH],
414-
'fast-route-post' => [FastRouteRouter::class, RequestMethod::METHOD_POST],
415-
'fast-route-put' => [FastRouteRouter::class, RequestMethod::METHOD_PUT],
416-
'fast-route-delete' => [FastRouteRouter::class, RequestMethod::METHOD_DELETE],
417-
'fast-route-patch' => [FastRouteRouter::class, RequestMethod::METHOD_PATCH],
418-
'zf2-get' => [ZendRouter::class, RequestMethod::METHOD_GET],
419-
'zf2-post' => [ZendRouter::class, RequestMethod::METHOD_POST],
420-
'zf2-put' => [ZendRouter::class, RequestMethod::METHOD_PUT],
421-
'zf2-delete' => [ZendRouter::class, RequestMethod::METHOD_DELETE],
422-
'zf2-patch' => [ZendRouter::class, RequestMethod::METHOD_PATCH],
423-
];
424-
}
425-
426401
/**
427402
* @dataProvider allowedMethod
428403
*
@@ -462,97 +437,6 @@ public function testAllowedMethodsWhenOnlyPutMethodSet($adapter, $method)
462437
$this->assertSame('', (string) $result->getBody());
463438
}
464439

465-
/**
466-
* @dataProvider allowedMethod
467-
*
468-
* @param string $adapter
469-
* @param string $method
470-
*/
471-
public function testAllowedMethodsWhenNoHttpMethodsSet($adapter, $method)
472-
{
473-
$router = new $adapter();
474-
$app = $this->createApplicationFromRouter($router);
475-
$app->pipe(new RouteMiddleware($router));
476-
477-
// This middleware is used just to check that request has successful RouteResult
478-
$middleware = $this->prophesize(MiddlewareInterface::class);
479-
$middleware->process(Argument::that(function (ServerRequestInterface $req) {
480-
$routeResult = $req->getAttribute(RouteResult::class);
481-
482-
Assert::assertInstanceOf(RouteResult::class, $routeResult);
483-
Assert::assertFalse($routeResult->isSuccess());
484-
Assert::assertTrue($routeResult->isMethodFailure());
485-
486-
return true;
487-
}), Argument::any())->will(function (array $args) {
488-
return $args[1]->handle($args[0]);
489-
});
490-
491-
$app->pipe($middleware->reveal());
492-
493-
if ($method === RequestMethod::METHOD_HEAD) {
494-
$app->pipe(new ImplicitHeadMiddleware($router, function () {
495-
}));
496-
}
497-
if ($method === RequestMethod::METHOD_OPTIONS) {
498-
$app->pipe(new ImplicitOptionsMiddleware($this->responseFactory));
499-
}
500-
$app->pipe(new MethodNotAllowedMiddleware($this->responseFactory));
501-
$app->pipe(new DispatchMiddleware());
502-
503-
// Add a route with empty array - NO HTTP methods
504-
$app->route('/foo', function ($req, $res, $next) {
505-
$stream = new Stream('php://temp', 'w+');
506-
$stream->write('Middleware');
507-
return $res->withBody($stream);
508-
}, []);
509-
510-
$handler = $this->prophesize(RequestHandlerInterface::class);
511-
$handler->handle(Argument::type(ServerRequest::class))
512-
->willReturn($this->response);
513-
514-
$request = new ServerRequest(['REQUEST_METHOD' => $method], [], '/foo', $method);
515-
$result = $app->process($request, $handler->reveal());
516-
517-
if ($method === RequestMethod::METHOD_OPTIONS) {
518-
$this->assertSame(StatusCode::STATUS_OK, $result->getStatusCode());
519-
} else {
520-
$this->assertSame(StatusCode::STATUS_METHOD_NOT_ALLOWED, $result->getStatusCode());
521-
}
522-
$this->assertSame('', (string) $result->getBody());
523-
}
524-
525-
/**
526-
* @dataProvider notAllowedMethod
527-
*
528-
* @param string $adapter
529-
* @param string $method
530-
*/
531-
public function testNotAllowedMethodWhenNoHttpMethodsSet($adapter, $method)
532-
{
533-
$router = new $adapter();
534-
$app = $this->createApplicationFromRouter($router);
535-
$app->pipe(new RouteMiddleware($router));
536-
$app->pipe(new MethodNotAllowedMiddleware($this->responseFactory));
537-
$app->pipe(new DispatchMiddleware());
538-
539-
// Add a route with empty array - NO HTTP methods
540-
$app->route('/foo', function ($req, $res, $next) {
541-
$stream = new Stream('php://temp', 'w+');
542-
$stream->write('Middleware');
543-
return $res->withBody($stream);
544-
}, []);
545-
546-
$handler = $this->prophesize(RequestHandlerInterface::class);
547-
$handler->handle(Argument::type(ServerRequest::class))
548-
->shouldNotBeCalled();
549-
550-
$request = new ServerRequest(['REQUEST_METHOD' => $method], [], '/foo', $method);
551-
$result = $app->process($request, $handler->reveal());
552-
$this->assertEquals(StatusCode::STATUS_METHOD_NOT_ALLOWED, $result->getStatusCode());
553-
$this->assertNotContains('Middleware', (string) $result->getBody());
554-
}
555-
556440
/**
557441
* @group 74
558442
*

0 commit comments

Comments
 (0)