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

Commit

Permalink
Add Chain test (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhukovra authored and devanych committed Feb 1, 2021
1 parent ae47256 commit 709149e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/Middleware/ChainTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Yiisoft\Yii\Web\Tests\Middleware;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Yiisoft\Yii\Web\Middleware\Chain;
use PHPUnit\Framework\TestCase;

class ChainTest extends TestCase
{
public function testProcess()
{
$request = $this->createMock(ServerRequestInterface::class);
$handler = $this->createMock(RequestHandlerInterface::class);

$middleware1 = $this->createMock(MiddlewareInterface::class);
$middleware1->expects($this->once())->method('process')->willReturnCallback(
function (ServerRequestInterface $request, RequestHandlerInterface $handler) {
return $handler->handle($request);
}
);

$middleware2 = $this->createMock(MiddlewareInterface::class);
$middleware2->expects($this->once())->method('process');

$chain = new Chain($middleware1, $middleware2);
$chain->process($request, $handler);
}
}

0 comments on commit 709149e

Please sign in to comment.