Skip to content

Commit

Permalink
Adapt to yiisoft/middleware-dispatcher changes (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
rustamwin committed Sep 7, 2022
1 parent 19146c8 commit 1b8c8af
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
@@ -1,8 +1,8 @@
# Yii Router Change Log

## 1.1.1 under development
## 1.2.0 under development

- no changes in this release.
- Chg #172: Upgrade the `yiisoft/middleware-dispatcher` dependency to version `3.0` (@rustamwin)

## 1.1.0 June 27, 2022

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -25,7 +25,7 @@
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0",
"yiisoft/http": "^1.2",
"yiisoft/middleware-dispatcher": "^2.0",
"yiisoft/middleware-dispatcher": "^3.0",
"yiisoft/router-implementation": "1.0.0"
},
"require-dev": {
Expand Down
4 changes: 2 additions & 2 deletions src/Middleware/Router.php
Expand Up @@ -13,7 +13,7 @@
use Yiisoft\Http\Method;
use Yiisoft\Http\Status;
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
use Yiisoft\Middleware\Dispatcher\MiddlewareFactoryInterface;
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Router\UrlMatcherInterface;

Expand All @@ -27,7 +27,7 @@ final class Router implements MiddlewareInterface
public function __construct(
UrlMatcherInterface $matcher,
ResponseFactoryInterface $responseFactory,
MiddlewareFactoryInterface $middlewareFactory,
MiddlewareFactory $middlewareFactory,
CurrentRoute $currentRoute,
?EventDispatcherInterface $eventDispatcher = null
) {
Expand Down
5 changes: 4 additions & 1 deletion tests/GroupTest.php
Expand Up @@ -16,6 +16,7 @@
use stdClass;
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
use Yiisoft\Middleware\Dispatcher\WrapperFactory;
use Yiisoft\Router\Group;
use Yiisoft\Router\Route;
use Yiisoft\Router\RouteCollection;
Expand Down Expand Up @@ -444,8 +445,10 @@ public function handle(ServerRequestInterface $request): ResponseInterface

private function getDispatcher(): MiddlewareDispatcher
{
$container = new Container([]);
$wrapperFactory = new WrapperFactory($container);
return new MiddlewareDispatcher(
new MiddlewareFactory(new Container([])),
new MiddlewareFactory($container, $wrapperFactory),
$this->createMock(EventDispatcherInterface::class)
);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/MatchingResultTest.php
Expand Up @@ -16,6 +16,7 @@
use Yiisoft\Http\Method;
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
use Yiisoft\Middleware\Dispatcher\WrapperFactory;
use Yiisoft\Router\MatchingResult;
use Yiisoft\Router\Route;

Expand Down Expand Up @@ -51,7 +52,7 @@ public function testProcessSuccess(): void
{
$container = $this->createMock(ContainerInterface::class);
$dispatcher = new MiddlewareDispatcher(
new MiddlewareFactory($container),
new MiddlewareFactory($container, new WrapperFactory($container)),
$this->createMock(EventDispatcherInterface::class)
);
$route = Route::post('/', $dispatcher)->middleware($this->getMiddleware());
Expand Down
3 changes: 2 additions & 1 deletion tests/Middleware/RouterTest.php
Expand Up @@ -14,6 +14,7 @@
use Psr\Http\Server\RequestHandlerInterface;
use Yiisoft\Http\Method;
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
use Yiisoft\Middleware\Dispatcher\WrapperFactory;
use Yiisoft\Router\CurrentRoute;
use Yiisoft\Router\Group;
use Yiisoft\Router\MatchingResult;
Expand Down Expand Up @@ -207,7 +208,7 @@ private function createRouterMiddleware(
return new Router(
$this->getMatcher($routeCollection),
new Psr17Factory(),
new MiddlewareFactory($container),
new MiddlewareFactory($container, new WrapperFactory($container)),
$currentRoute ?? new CurrentRoute()
);
}
Expand Down
4 changes: 3 additions & 1 deletion tests/RouteCollectionTest.php
Expand Up @@ -15,6 +15,7 @@
use RuntimeException;
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
use Yiisoft\Middleware\Dispatcher\WrapperFactory;
use Yiisoft\Router\Group;
use Yiisoft\Router\Route;
use Yiisoft\Router\RouteCollection;
Expand Down Expand Up @@ -382,8 +383,9 @@ public function handle(ServerRequestInterface $request): Response

private function getDispatcher(ContainerInterface $container = null): MiddlewareDispatcher
{
$container ??= $this->createMock(ContainerInterface::class);
return new MiddlewareDispatcher(
new MiddlewareFactory($container ?? $this->createMock(ContainerInterface::class)),
new MiddlewareFactory($container, new WrapperFactory($container)),
$this->createMock(EventDispatcherInterface::class)
);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/RouteTest.php
Expand Up @@ -16,6 +16,7 @@
use Yiisoft\Http\Method;
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
use Yiisoft\Middleware\Dispatcher\WrapperFactory;
use Yiisoft\Router\Route;
use Yiisoft\Router\Tests\Support\AssertTrait;
use Yiisoft\Router\Tests\Support\Container;
Expand Down Expand Up @@ -381,13 +382,13 @@ private function getDispatcher(ContainerInterface $container = null): Middleware
{
if ($container === null) {
return new MiddlewareDispatcher(
new MiddlewareFactory($this->getContainer()),
new MiddlewareFactory($this->getContainer(), new WrapperFactory($this->getContainer())),
$this->createMock(EventDispatcherInterface::class)
);
}

return new MiddlewareDispatcher(
new MiddlewareFactory($container),
new MiddlewareFactory($container, new WrapperFactory($container)),
$this->createMock(EventDispatcherInterface::class)
);
}
Expand Down

0 comments on commit 1b8c8af

Please sign in to comment.