diff --git a/config/autoload/dependencies.global.php b/config/autoload/dependencies.global.php index 5d64b8c0..aa105e6d 100644 --- a/config/autoload/dependencies.global.php +++ b/config/autoload/dependencies.global.php @@ -5,13 +5,8 @@ use Shlinkio\Shlink\Common\Factory\EmptyResponseImplicitOptionsMiddlewareFactory use Zend\Expressive; use Zend\Expressive\Container; use Zend\Expressive\Helper; -use Zend\Expressive\Middleware; -use Zend\Expressive\Plates; -use Zend\Expressive\Router; use Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware; -use Zend\Expressive\Template; use Zend\ServiceManager\Factory\InvokableFactory; -use Zend\Stratigility\Middleware\ErrorHandler; return [ diff --git a/module/Common/test/Factory/EmptyResponseImplicitOptionsMiddlewareFactoryTest.php b/module/Common/test/Factory/EmptyResponseImplicitOptionsMiddlewareFactoryTest.php index 11b76440..8e6b17b7 100644 --- a/module/Common/test/Factory/EmptyResponseImplicitOptionsMiddlewareFactoryTest.php +++ b/module/Common/test/Factory/EmptyResponseImplicitOptionsMiddlewareFactoryTest.php @@ -38,8 +38,8 @@ class EmptyResponseImplicitOptionsMiddlewareFactoryTest extends TestCase $instance = $this->factory->__invoke(new ServiceManager(), ''); $ref = new \ReflectionObject($instance); - $prop = $ref->getProperty('response'); + $prop = $ref->getProperty('responseFactory'); $prop->setAccessible(true); - $this->assertInstanceOf(EmptyResponse::class, $prop->getValue($instance)); + $this->assertInstanceOf(EmptyResponse::class, $prop->getValue($instance)()); } } diff --git a/module/Common/test/Middleware/LocaleMiddlewareTest.php b/module/Common/test/Middleware/LocaleMiddlewareTest.php index 703ef700..35b6aa3a 100644 --- a/module/Common/test/Middleware/LocaleMiddlewareTest.php +++ b/module/Common/test/Middleware/LocaleMiddlewareTest.php @@ -32,7 +32,7 @@ class LocaleMiddlewareTest extends TestCase public function whenNoHeaderIsPresentLocaleIsNotChanged() { $this->assertEquals('ru', $this->translator->getLocale()); - $this->middleware->process(ServerRequestFactory::fromGlobals(), TestUtils::createDelegateMock()->reveal()); + $this->middleware->process(ServerRequestFactory::fromGlobals(), TestUtils::createReqHandlerMock()->reveal()); $this->assertEquals('ru', $this->translator->getLocale()); } @@ -43,7 +43,7 @@ class LocaleMiddlewareTest extends TestCase { $this->assertEquals('ru', $this->translator->getLocale()); $request = ServerRequestFactory::fromGlobals()->withHeader('Accept-Language', 'es'); - $this->middleware->process($request, TestUtils::createDelegateMock()->reveal()); + $this->middleware->process($request, TestUtils::createReqHandlerMock()->reveal()); $this->assertEquals('es', $this->translator->getLocale()); } @@ -52,7 +52,7 @@ class LocaleMiddlewareTest extends TestCase */ public function localeGetsNormalized() { - $delegate = TestUtils::createDelegateMock(); + $delegate = TestUtils::createReqHandlerMock(); $this->assertEquals('ru', $this->translator->getLocale()); diff --git a/module/Common/test/Util/TestUtils.php b/module/Common/test/Util/TestUtils.php index 218298a4..64ed655a 100644 --- a/module/Common/test/Util/TestUtils.php +++ b/module/Common/test/Util/TestUtils.php @@ -7,18 +7,18 @@ use Prophecy\Argument; use Prophecy\Prophet; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; +use Psr\Http\Server\RequestHandlerInterface; use Zend\Diactoros\Response; class TestUtils { private static $prophet; - public static function createDelegateMock(ResponseInterface $response = null, RequestInterface $request = null) + public static function createReqHandlerMock(ResponseInterface $response = null, RequestInterface $request = null) { $argument = $request ?: Argument::any(); - $delegate = static::getProphet()->prophesize(DelegateInterface::class); - $delegate->process($argument)->willReturn($response ?: new Response()); + $delegate = static::getProphet()->prophesize(RequestHandlerInterface::class); + $delegate->handle($argument)->willReturn($response ?: new Response()); return $delegate; } diff --git a/module/Core/test/Action/PreviewActionTest.php b/module/Core/test/Action/PreviewActionTest.php index 46d03a83..abd4dc35 100644 --- a/module/Core/test/Action/PreviewActionTest.php +++ b/module/Core/test/Action/PreviewActionTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\Prophecy\MethodProphecy; use Prophecy\Prophecy\ObjectProphecy; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; +use Psr\Http\Server\RequestHandlerInterface; use Shlinkio\Shlink\Common\Service\PreviewGenerator; use Shlinkio\Shlink\Core\Action\PreviewAction; use Shlinkio\Shlink\Core\Exception\EntityDoesNotExistException; @@ -47,8 +47,8 @@ class PreviewActionTest extends TestCase $shortCode = 'abc123'; $this->urlShortener->shortCodeToUrl($shortCode)->willThrow(EntityDoesNotExistException::class) ->shouldBeCalledTimes(1); - $delegate = $this->prophesize(DelegateInterface::class); - $delegate->process(Argument::cetera())->shouldBeCalledTimes(1) + $delegate = $this->prophesize(RequestHandlerInterface::class); + $delegate->handle(Argument::cetera())->shouldBeCalledTimes(1) ->willReturn(new Response()); $this->action->process( @@ -70,7 +70,7 @@ class PreviewActionTest extends TestCase $resp = $this->action->process( ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode), - TestUtils::createDelegateMock()->reveal() + TestUtils::createReqHandlerMock()->reveal() ); $this->assertEquals(filesize($path), $resp->getHeaderLine('Content-length')); @@ -85,9 +85,9 @@ class PreviewActionTest extends TestCase $shortCode = 'abc123'; $this->urlShortener->shortCodeToUrl($shortCode)->willThrow(InvalidShortCodeException::class) ->shouldBeCalledTimes(1); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); /** @var MethodProphecy $process */ - $process = $delegate->process(Argument::any())->willReturn(new Response()); + $process = $delegate->handle(Argument::any())->willReturn(new Response()); $this->action->process( ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode), diff --git a/module/Core/test/Action/QrCodeActionTest.php b/module/Core/test/Action/QrCodeActionTest.php index b8a4658c..2d58c8c9 100644 --- a/module/Core/test/Action/QrCodeActionTest.php +++ b/module/Core/test/Action/QrCodeActionTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\Prophecy\MethodProphecy; use Prophecy\Prophecy\ObjectProphecy; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; +use Psr\Http\Server\RequestHandlerInterface; use Shlinkio\Shlink\Common\Response\QrCodeResponse; use Shlinkio\Shlink\Core\Action\QrCodeAction; use Shlinkio\Shlink\Core\Exception\EntityDoesNotExistException; @@ -46,8 +46,8 @@ class QrCodeActionTest extends TestCase $shortCode = 'abc123'; $this->urlShortener->shortCodeToUrl($shortCode)->willThrow(EntityDoesNotExistException::class) ->shouldBeCalledTimes(1); - $delegate = $this->prophesize(DelegateInterface::class); - $process = $delegate->process(Argument::any())->willReturn(new Response()); + $delegate = $this->prophesize(RequestHandlerInterface::class); + $process = $delegate->handle(Argument::any())->willReturn(new Response()); $this->action->process( ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode), @@ -65,9 +65,9 @@ class QrCodeActionTest extends TestCase $shortCode = 'abc123'; $this->urlShortener->shortCodeToUrl($shortCode)->willThrow(InvalidShortCodeException::class) ->shouldBeCalledTimes(1); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); /** @var MethodProphecy $process */ - $process = $delegate->process(Argument::any())->willReturn(new Response()); + $process = $delegate->handle(Argument::any())->willReturn(new Response()); $this->action->process( ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode), @@ -84,7 +84,7 @@ class QrCodeActionTest extends TestCase { $shortCode = 'abc123'; $this->urlShortener->shortCodeToUrl($shortCode)->willReturn('')->shouldBeCalledTimes(1); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); $resp = $this->action->process( ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode), @@ -93,6 +93,6 @@ class QrCodeActionTest extends TestCase $this->assertInstanceOf(QrCodeResponse::class, $resp); $this->assertEquals(200, $resp->getStatusCode()); - $delegate->process(Argument::any())->shouldHaveBeenCalledTimes(0); + $delegate->handle(Argument::any())->shouldHaveBeenCalledTimes(0); } } diff --git a/module/Core/test/Action/RedirectActionTest.php b/module/Core/test/Action/RedirectActionTest.php index 014b7a92..88b44d07 100644 --- a/module/Core/test/Action/RedirectActionTest.php +++ b/module/Core/test/Action/RedirectActionTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\Prophecy\MethodProphecy; use Prophecy\Prophecy\ObjectProphecy; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; +use Psr\Http\Server\RequestHandlerInterface; use Shlinkio\Shlink\Core\Action\RedirectAction; use Shlinkio\Shlink\Core\Exception\EntityDoesNotExistException; use Shlinkio\Shlink\Core\Options\AppOptions; @@ -57,7 +57,7 @@ class RedirectActionTest extends TestCase ->shouldBeCalledTimes(1); $request = ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode); - $response = $this->action->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->action->process($request, TestUtils::createReqHandlerMock()->reveal()); $this->assertInstanceOf(Response\RedirectResponse::class, $response); $this->assertEquals(302, $response->getStatusCode()); @@ -76,9 +76,9 @@ class RedirectActionTest extends TestCase $this->visitTracker->track(Argument::cetera())->willReturn(null) ->shouldNotBeCalled(); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); /** @var MethodProphecy $process */ - $process = $delegate->process(Argument::any())->willReturn(new Response()); + $process = $delegate->handle(Argument::any())->willReturn(new Response()); $request = ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode); $this->action->process($request, $delegate->reveal()); @@ -100,7 +100,7 @@ class RedirectActionTest extends TestCase $request = ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode) ->withQueryParams(['foobar' => true]); - $response = $this->action->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->action->process($request, TestUtils::createReqHandlerMock()->reveal()); $this->assertInstanceOf(Response\RedirectResponse::class, $response); $this->assertEquals(302, $response->getStatusCode()); diff --git a/module/Core/test/Middleware/QrCodeCacheMiddlewareTest.php b/module/Core/test/Middleware/QrCodeCacheMiddlewareTest.php index 1fe7f4ab..f566a6bf 100644 --- a/module/Core/test/Middleware/QrCodeCacheMiddlewareTest.php +++ b/module/Core/test/Middleware/QrCodeCacheMiddlewareTest.php @@ -7,7 +7,7 @@ use Doctrine\Common\Cache\ArrayCache; use Doctrine\Common\Cache\Cache; use PHPUnit\Framework\TestCase; use Prophecy\Argument; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; +use Psr\Http\Server\RequestHandlerInterface; use Shlinkio\Shlink\Core\Middleware\QrCodeCacheMiddleware; use Zend\Diactoros\Response; use Zend\Diactoros\ServerRequestFactory; @@ -35,8 +35,8 @@ class QrCodeCacheMiddlewareTest extends TestCase */ public function noCachedPathFallsBackToNextMiddleware() { - $delegate = $this->prophesize(DelegateInterface::class); - $delegate->process(Argument::any())->willReturn(new Response())->shouldBeCalledTimes(1); + $delegate = $this->prophesize(RequestHandlerInterface::class); + $delegate->handle(Argument::any())->willReturn(new Response())->shouldBeCalledTimes(1); $this->middleware->process(ServerRequestFactory::fromGlobals()->withUri( new Uri('/foo/bar') @@ -53,7 +53,7 @@ class QrCodeCacheMiddlewareTest extends TestCase $isCalled = false; $uri = (new Uri())->withPath('/foo'); $this->cache->save('/foo', ['body' => 'the body', 'content-type' => 'image/png']); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); $resp = $this->middleware->process( ServerRequestFactory::fromGlobals()->withUri($uri), @@ -64,6 +64,6 @@ class QrCodeCacheMiddlewareTest extends TestCase $resp->getBody()->rewind(); $this->assertEquals('the body', $resp->getBody()->getContents()); $this->assertEquals('image/png', $resp->getHeaderLine('Content-Type')); - $delegate->process(Argument::any())->shouldHaveBeenCalledTimes(0); + $delegate->handle(Argument::any())->shouldHaveBeenCalledTimes(0); } } diff --git a/module/Core/test/Response/NotFoundDelegateTest.php b/module/Core/test/Response/NotFoundDelegateTest.php index 4f80bf56..b3ce2e66 100644 --- a/module/Core/test/Response/NotFoundDelegateTest.php +++ b/module/Core/test/Response/NotFoundDelegateTest.php @@ -43,7 +43,7 @@ class NotFoundDelegateTest extends TestCase /** @var MethodProphecy $render */ $render = $this->renderer->render(Argument::cetera())->willReturn(''); - $resp = $this->delegate->process($request); + $resp = $this->delegate->handle($request); $this->assertInstanceOf($expectedResponse, $resp); $render->shouldHaveBeenCalledTimes($renderCalls); diff --git a/module/Rest/src/Action/Tag/CreateTagsAction.php b/module/Rest/src/Action/Tag/CreateTagsAction.php index f0ce1547..6f93b46f 100644 --- a/module/Rest/src/Action/Tag/CreateTagsAction.php +++ b/module/Rest/src/Action/Tag/CreateTagsAction.php @@ -5,7 +5,6 @@ namespace Shlinkio\Shlink\Rest\Action\Tag; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Server\RequestHandlerInterface; use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface; use Shlinkio\Shlink\Rest\Action\AbstractRestAction; diff --git a/module/Rest/test/Action/AuthenticateActionTest.php b/module/Rest/test/Action/AuthenticateActionTest.php index 4fb2518f..4825a100 100644 --- a/module/Rest/test/Action/AuthenticateActionTest.php +++ b/module/Rest/test/Action/AuthenticateActionTest.php @@ -10,7 +10,6 @@ use Shlinkio\Shlink\Rest\Action\AuthenticateAction; use Shlinkio\Shlink\Rest\Authentication\JWTService; use Shlinkio\Shlink\Rest\Entity\ApiKey; use Shlinkio\Shlink\Rest\Service\ApiKeyService; -use ShlinkioTest\Shlink\Common\Util\TestUtils; use Zend\Diactoros\ServerRequestFactory; use Zend\I18n\Translator\Translator; @@ -47,7 +46,7 @@ class AuthenticateActionTest extends TestCase */ public function notProvidingAuthDataReturnsError() { - $resp = $this->action->process(ServerRequestFactory::fromGlobals(), TestUtils::createDelegateMock()->reveal()); + $resp = $this->action->handle(ServerRequestFactory::fromGlobals()); $this->assertEquals(400, $resp->getStatusCode()); } @@ -62,7 +61,7 @@ class AuthenticateActionTest extends TestCase $request = ServerRequestFactory::fromGlobals()->withParsedBody([ 'apiKey' => 'foo', ]); - $response = $this->action->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->action->handle($request); $this->assertEquals(200, $response->getStatusCode()); $response->getBody()->rewind(); @@ -80,7 +79,7 @@ class AuthenticateActionTest extends TestCase $request = ServerRequestFactory::fromGlobals()->withParsedBody([ 'apiKey' => 'foo', ]); - $response = $this->action->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->action->handle($request); $this->assertEquals(401, $response->getStatusCode()); } } diff --git a/module/Rest/test/Action/CreateShortcodeActionTest.php b/module/Rest/test/Action/CreateShortcodeActionTest.php index 2c92f030..c9d8ff19 100644 --- a/module/Rest/test/Action/CreateShortcodeActionTest.php +++ b/module/Rest/test/Action/CreateShortcodeActionTest.php @@ -11,7 +11,6 @@ use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException; use Shlinkio\Shlink\Core\Service\UrlShortener; use Shlinkio\Shlink\Rest\Action\CreateShortcodeAction; use Shlinkio\Shlink\Rest\Util\RestUtils; -use ShlinkioTest\Shlink\Common\Util\TestUtils; use Zend\Diactoros\ServerRequestFactory; use Zend\Diactoros\Uri; use Zend\I18n\Translator\Translator; @@ -41,10 +40,7 @@ class CreateShortcodeActionTest extends TestCase */ public function missingLongUrlParamReturnsError() { - $response = $this->action->process( - ServerRequestFactory::fromGlobals(), - TestUtils::createDelegateMock()->reveal() - ); + $response = $this->action->handle(ServerRequestFactory::fromGlobals()); $this->assertEquals(400, $response->getStatusCode()); } @@ -60,7 +56,7 @@ class CreateShortcodeActionTest extends TestCase $request = ServerRequestFactory::fromGlobals()->withParsedBody([ 'longUrl' => 'http://www.domain.com/foo/bar', ]); - $response = $this->action->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->action->handle($request); $this->assertEquals(200, $response->getStatusCode()); $this->assertTrue(strpos($response->getBody()->getContents(), 'http://foo.com/abc123') > 0); } @@ -77,7 +73,7 @@ class CreateShortcodeActionTest extends TestCase $request = ServerRequestFactory::fromGlobals()->withParsedBody([ 'longUrl' => 'http://www.domain.com/foo/bar', ]); - $response = $this->action->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->action->handle($request); $this->assertEquals(400, $response->getStatusCode()); $this->assertTrue(strpos($response->getBody()->getContents(), RestUtils::INVALID_URL_ERROR) > 0); } @@ -100,7 +96,7 @@ class CreateShortcodeActionTest extends TestCase 'longUrl' => 'http://www.domain.com/foo/bar', 'customSlug' => 'foo', ]); - $response = $this->action->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->action->handle($request); $this->assertEquals(400, $response->getStatusCode()); $this->assertContains(RestUtils::INVALID_SLUG_ERROR, (string) $response->getBody()); } @@ -117,7 +113,7 @@ class CreateShortcodeActionTest extends TestCase $request = ServerRequestFactory::fromGlobals()->withParsedBody([ 'longUrl' => 'http://www.domain.com/foo/bar', ]); - $response = $this->action->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->action->handle($request); $this->assertEquals(500, $response->getStatusCode()); $this->assertTrue(strpos($response->getBody()->getContents(), RestUtils::UNKNOWN_ERROR) > 0); } diff --git a/module/Rest/test/Action/EditShortCodeActionTest.php b/module/Rest/test/Action/EditShortCodeActionTest.php index 30392840..5a4e6b2f 100644 --- a/module/Rest/test/Action/EditShortCodeActionTest.php +++ b/module/Rest/test/Action/EditShortCodeActionTest.php @@ -6,7 +6,6 @@ namespace ShlinkioTest\Shlink\Rest\Action; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException; use Shlinkio\Shlink\Core\Service\ShortUrlServiceInterface; @@ -43,7 +42,7 @@ class EditShortCodeActionTest extends TestCase ]); /** @var JsonResponse $resp */ - $resp = $this->action->process($request, $this->prophesize(DelegateInterface::class)->reveal()); + $resp = $this->action->handle($request); $payload = $resp->getPayload(); $this->assertEquals(400, $resp->getStatusCode()); @@ -65,7 +64,7 @@ class EditShortCodeActionTest extends TestCase ); /** @var JsonResponse $resp */ - $resp = $this->action->process($request, $this->prophesize(DelegateInterface::class)->reveal()); + $resp = $this->action->handle($request); $payload = $resp->getPayload(); $this->assertEquals(404, $resp->getStatusCode()); @@ -85,7 +84,7 @@ class EditShortCodeActionTest extends TestCase ]); $updateMeta = $this->shortUrlService->updateMetadataByShortCode(Argument::cetera())->willReturn(new ShortUrl()); - $resp = $this->action->process($request, $this->prophesize(DelegateInterface::class)->reveal()); + $resp = $this->action->handle($request); $this->assertEquals(204, $resp->getStatusCode()); $updateMeta->shouldHaveBeenCalled(); diff --git a/module/Rest/test/Action/EditShortcodeTagsActionTest.php b/module/Rest/test/Action/EditShortcodeTagsActionTest.php index f90c73f0..a2bcfb38 100644 --- a/module/Rest/test/Action/EditShortcodeTagsActionTest.php +++ b/module/Rest/test/Action/EditShortcodeTagsActionTest.php @@ -9,7 +9,6 @@ use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException; use Shlinkio\Shlink\Core\Service\ShortUrlService; use Shlinkio\Shlink\Rest\Action\EditShortcodeTagsAction; -use ShlinkioTest\Shlink\Common\Util\TestUtils; use Zend\Diactoros\ServerRequestFactory; use Zend\I18n\Translator\Translator; @@ -35,10 +34,7 @@ class EditShortcodeTagsActionTest extends TestCase */ public function notProvidingTagsReturnsError() { - $response = $this->action->process( - ServerRequestFactory::fromGlobals()->withAttribute('shortCode', 'abc123'), - TestUtils::createDelegateMock()->reveal() - ); + $response = $this->action->handle(ServerRequestFactory::fromGlobals()->withAttribute('shortCode', 'abc123')); $this->assertEquals(400, $response->getStatusCode()); } @@ -51,10 +47,9 @@ class EditShortcodeTagsActionTest extends TestCase $this->shortUrlService->setTagsByShortCode($shortCode, [])->willThrow(InvalidShortCodeException::class) ->shouldBeCalledTimes(1); - $response = $this->action->process( + $response = $this->action->handle( ServerRequestFactory::fromGlobals()->withAttribute('shortCode', 'abc123') - ->withParsedBody(['tags' => []]), - TestUtils::createDelegateMock()->reveal() + ->withParsedBody(['tags' => []]) ); $this->assertEquals(404, $response->getStatusCode()); } @@ -68,10 +63,9 @@ class EditShortcodeTagsActionTest extends TestCase $this->shortUrlService->setTagsByShortCode($shortCode, [])->willReturn(new ShortUrl()) ->shouldBeCalledTimes(1); - $response = $this->action->process( + $response = $this->action->handle( ServerRequestFactory::fromGlobals()->withAttribute('shortCode', 'abc123') - ->withParsedBody(['tags' => []]), - TestUtils::createDelegateMock()->reveal() + ->withParsedBody(['tags' => []]) ); $this->assertEquals(200, $response->getStatusCode()); } diff --git a/module/Rest/test/Action/GetVisitsActionTest.php b/module/Rest/test/Action/GetVisitsActionTest.php index eb892e74..1ac988ba 100644 --- a/module/Rest/test/Action/GetVisitsActionTest.php +++ b/module/Rest/test/Action/GetVisitsActionTest.php @@ -10,7 +10,6 @@ use Shlinkio\Shlink\Common\Exception\InvalidArgumentException; use Shlinkio\Shlink\Common\Util\DateRange; use Shlinkio\Shlink\Core\Service\VisitsTracker; use Shlinkio\Shlink\Rest\Action\GetVisitsAction; -use ShlinkioTest\Shlink\Common\Util\TestUtils; use Zend\Diactoros\ServerRequestFactory; use Zend\I18n\Translator\Translator; @@ -40,10 +39,7 @@ class GetVisitsActionTest extends TestCase $this->visitsTracker->info($shortCode, Argument::type(DateRange::class))->willReturn([]) ->shouldBeCalledTimes(1); - $response = $this->action->process( - ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode), - TestUtils::createDelegateMock()->reveal() - ); + $response = $this->action->handle(ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode)); $this->assertEquals(200, $response->getStatusCode()); } @@ -57,10 +53,7 @@ class GetVisitsActionTest extends TestCase InvalidArgumentException::class )->shouldBeCalledTimes(1); - $response = $this->action->process( - ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode), - TestUtils::createDelegateMock()->reveal() - ); + $response = $this->action->handle(ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode)); $this->assertEquals(404, $response->getStatusCode()); } @@ -74,10 +67,7 @@ class GetVisitsActionTest extends TestCase \Exception::class )->shouldBeCalledTimes(1); - $response = $this->action->process( - ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode), - TestUtils::createDelegateMock()->reveal() - ); + $response = $this->action->handle(ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode)); $this->assertEquals(500, $response->getStatusCode()); } @@ -91,10 +81,9 @@ class GetVisitsActionTest extends TestCase ->willReturn([]) ->shouldBeCalledTimes(1); - $response = $this->action->process( + $response = $this->action->handle( ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode) - ->withQueryParams(['endDate' => '2016-01-01 00:00:00']), - TestUtils::createDelegateMock()->reveal() + ->withQueryParams(['endDate' => '2016-01-01 00:00:00']) ); $this->assertEquals(200, $response->getStatusCode()); } diff --git a/module/Rest/test/Action/ListShortcodesActionTest.php b/module/Rest/test/Action/ListShortCodesActionTest.php similarity index 75% rename from module/Rest/test/Action/ListShortcodesActionTest.php rename to module/Rest/test/Action/ListShortCodesActionTest.php index 1867d15a..85e6737a 100644 --- a/module/Rest/test/Action/ListShortcodesActionTest.php +++ b/module/Rest/test/Action/ListShortCodesActionTest.php @@ -7,7 +7,6 @@ use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\ObjectProphecy; use Shlinkio\Shlink\Core\Service\ShortUrlService; use Shlinkio\Shlink\Rest\Action\ListShortcodesAction; -use ShlinkioTest\Shlink\Common\Util\TestUtils; use Zend\Diactoros\ServerRequestFactory; use Zend\I18n\Translator\Translator; use Zend\Paginator\Adapter\ArrayAdapter; @@ -39,12 +38,9 @@ class ListShortCodesActionTest extends TestCase $this->service->listShortUrls($page, null, [], null)->willReturn(new Paginator(new ArrayAdapter())) ->shouldBeCalledTimes(1); - $response = $this->action->process( - ServerRequestFactory::fromGlobals()->withQueryParams([ - 'page' => $page, - ]), - TestUtils::createDelegateMock()->reveal() - ); + $response = $this->action->handle(ServerRequestFactory::fromGlobals()->withQueryParams([ + 'page' => $page, + ])); $this->assertEquals(200, $response->getStatusCode()); } @@ -57,12 +53,9 @@ class ListShortCodesActionTest extends TestCase $this->service->listShortUrls($page, null, [], null)->willThrow(\Exception::class) ->shouldBeCalledTimes(1); - $response = $this->action->process( - ServerRequestFactory::fromGlobals()->withQueryParams([ - 'page' => $page, - ]), - TestUtils::createDelegateMock()->reveal() - ); + $response = $this->action->handle(ServerRequestFactory::fromGlobals()->withQueryParams([ + 'page' => $page, + ])); $this->assertEquals(500, $response->getStatusCode()); } } diff --git a/module/Rest/test/Action/ResolveUrlActionTest.php b/module/Rest/test/Action/ResolveUrlActionTest.php index 884fae55..feafc425 100644 --- a/module/Rest/test/Action/ResolveUrlActionTest.php +++ b/module/Rest/test/Action/ResolveUrlActionTest.php @@ -10,7 +10,6 @@ use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException; use Shlinkio\Shlink\Core\Service\UrlShortener; use Shlinkio\Shlink\Rest\Action\ResolveUrlAction; use Shlinkio\Shlink\Rest\Util\RestUtils; -use ShlinkioTest\Shlink\Common\Util\TestUtils; use Zend\Diactoros\ServerRequestFactory; use Zend\I18n\Translator\Translator; @@ -41,7 +40,7 @@ class ResolveUrlActionTest extends TestCase ->shouldBeCalledTimes(1); $request = ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode); - $response = $this->action->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->action->handle($request); $this->assertEquals(404, $response->getStatusCode()); $this->assertTrue(strpos($response->getBody()->getContents(), RestUtils::INVALID_ARGUMENT_ERROR) > 0); } @@ -56,7 +55,7 @@ class ResolveUrlActionTest extends TestCase ->shouldBeCalledTimes(1); $request = ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode); - $response = $this->action->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->action->handle($request); $this->assertEquals(200, $response->getStatusCode()); $this->assertTrue(strpos($response->getBody()->getContents(), 'http://domain.com/foo/bar') > 0); } @@ -71,7 +70,7 @@ class ResolveUrlActionTest extends TestCase ->shouldBeCalledTimes(1); $request = ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode); - $response = $this->action->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->action->handle($request); $this->assertEquals(400, $response->getStatusCode()); $this->assertTrue(strpos($response->getBody()->getContents(), RestUtils::INVALID_SHORTCODE_ERROR) > 0); } @@ -86,7 +85,7 @@ class ResolveUrlActionTest extends TestCase ->shouldBeCalledTimes(1); $request = ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode); - $response = $this->action->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->action->handle($request); $this->assertEquals(500, $response->getStatusCode()); $this->assertTrue(strpos($response->getBody()->getContents(), RestUtils::UNKNOWN_ERROR) > 0); } diff --git a/module/Rest/test/Action/Tag/CreateTagsActionTest.php b/module/Rest/test/Action/Tag/CreateTagsActionTest.php index b7231472..e94a0ea8 100644 --- a/module/Rest/test/Action/Tag/CreateTagsActionTest.php +++ b/module/Rest/test/Action/Tag/CreateTagsActionTest.php @@ -7,7 +7,6 @@ use Doctrine\Common\Collections\ArrayCollection; use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\MethodProphecy; use Prophecy\Prophecy\ObjectProphecy; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface; use Shlinkio\Shlink\Rest\Action\Tag\CreateTagsAction; use Zend\Diactoros\ServerRequestFactory; @@ -40,7 +39,7 @@ class CreateTagsActionTest extends TestCase /** @var MethodProphecy $deleteTags */ $deleteTags = $this->tagService->createTags($tags ?: [])->willReturn(new ArrayCollection()); - $response = $this->action->process($request, $this->prophesize(DelegateInterface::class)->reveal()); + $response = $this->action->handle($request); $this->assertEquals(200, $response->getStatusCode()); $deleteTags->shouldHaveBeenCalled(); diff --git a/module/Rest/test/Action/Tag/DeleteTagsActionTest.php b/module/Rest/test/Action/Tag/DeleteTagsActionTest.php index 81e7ca7f..fc376576 100644 --- a/module/Rest/test/Action/Tag/DeleteTagsActionTest.php +++ b/module/Rest/test/Action/Tag/DeleteTagsActionTest.php @@ -6,7 +6,6 @@ namespace ShlinkioTest\Shlink\Rest\Action\Tag; use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\MethodProphecy; use Prophecy\Prophecy\ObjectProphecy; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface; use Shlinkio\Shlink\Rest\Action\Tag\DeleteTagsAction; use Zend\Diactoros\ServerRequestFactory; @@ -39,7 +38,7 @@ class DeleteTagsActionTest extends TestCase /** @var MethodProphecy $deleteTags */ $deleteTags = $this->tagService->deleteTags($tags ?: []); - $response = $this->action->process($request, $this->prophesize(DelegateInterface::class)->reveal()); + $response = $this->action->handle($request); $this->assertEquals(204, $response->getStatusCode()); $deleteTags->shouldHaveBeenCalled(); diff --git a/module/Rest/test/Action/Tag/ListTagsActionTest.php b/module/Rest/test/Action/Tag/ListTagsActionTest.php index 96f4d7bd..7fb73404 100644 --- a/module/Rest/test/Action/Tag/ListTagsActionTest.php +++ b/module/Rest/test/Action/Tag/ListTagsActionTest.php @@ -6,7 +6,6 @@ namespace ShlinkioTest\Shlink\Rest\Action\Tag; use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\MethodProphecy; use Prophecy\Prophecy\ObjectProphecy; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; use Shlinkio\Shlink\Core\Entity\Tag; use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface; use Shlinkio\Shlink\Rest\Action\Tag\ListTagsAction; @@ -37,10 +36,7 @@ class ListTagsActionTest extends TestCase /** @var MethodProphecy $listTags */ $listTags = $this->tagService->listTags()->willReturn([new Tag('foo'), new Tag('bar')]); - $resp = $this->action->process( - ServerRequestFactory::fromGlobals(), - $this->prophesize(DelegateInterface::class)->reveal() - ); + $resp = $this->action->handle(ServerRequestFactory::fromGlobals()); $this->assertEquals([ 'tags' => [ diff --git a/module/Rest/test/Action/Tag/UpdateTagActionTest.php b/module/Rest/test/Action/Tag/UpdateTagActionTest.php index a554e40d..c073f270 100644 --- a/module/Rest/test/Action/Tag/UpdateTagActionTest.php +++ b/module/Rest/test/Action/Tag/UpdateTagActionTest.php @@ -6,7 +6,6 @@ namespace ShlinkioTest\Shlink\Rest\Action\Tag; use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\MethodProphecy; use Prophecy\Prophecy\ObjectProphecy; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; use Shlinkio\Shlink\Core\Entity\Tag; use Shlinkio\Shlink\Core\Exception\EntityDoesNotExistException; use Shlinkio\Shlink\Core\Service\Tag\TagServiceInterface; @@ -39,7 +38,7 @@ class UpdateTagActionTest extends TestCase public function whenInvalidParamsAreProvidedAnErrorIsReturned(array $bodyParams) { $request = ServerRequestFactory::fromGlobals()->withParsedBody($bodyParams); - $resp = $this->action->process($request, $this->prophesize(DelegateInterface::class)->reveal()); + $resp = $this->action->handle($request); $this->assertEquals(400, $resp->getStatusCode()); } @@ -65,7 +64,7 @@ class UpdateTagActionTest extends TestCase /** @var MethodProphecy $rename */ $rename = $this->tagService->renameTag('foo', 'bar')->willThrow(EntityDoesNotExistException::class); - $resp = $this->action->process($request, $this->prophesize(DelegateInterface::class)->reveal()); + $resp = $this->action->handle($request); $this->assertEquals(404, $resp->getStatusCode()); $rename->shouldHaveBeenCalled(); @@ -83,7 +82,7 @@ class UpdateTagActionTest extends TestCase /** @var MethodProphecy $rename */ $rename = $this->tagService->renameTag('foo', 'bar')->willReturn(new Tag()); - $resp = $this->action->process($request, $this->prophesize(DelegateInterface::class)->reveal()); + $resp = $this->action->handle($request); $this->assertEquals(204, $resp->getStatusCode()); $rename->shouldHaveBeenCalled(); diff --git a/module/Rest/test/Middleware/BodyParserMiddlewareTest.php b/module/Rest/test/Middleware/BodyParserMiddlewareTest.php index 4e1157d0..e433322b 100644 --- a/module/Rest/test/Middleware/BodyParserMiddlewareTest.php +++ b/module/Rest/test/Middleware/BodyParserMiddlewareTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\Prophecy\MethodProphecy; use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; +use Psr\Http\Server\RequestHandlerInterface; use Shlinkio\Shlink\Rest\Middleware\BodyParserMiddleware; use Zend\Diactoros\Response; use Zend\Diactoros\ServerRequestFactory; @@ -31,9 +31,9 @@ class BodyParserMiddlewareTest extends TestCase public function requestsFromOtherMethodsJustFallbackToNextMiddleware() { $request = ServerRequestFactory::fromGlobals()->withMethod('GET'); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); /** @var MethodProphecy $process */ - $process = $delegate->process($request)->willReturn(new Response()); + $process = $delegate->handle($request)->willReturn(new Response()); $this->middleware->process($request, $delegate->reveal()); @@ -51,9 +51,9 @@ class BodyParserMiddlewareTest extends TestCase $request = ServerRequestFactory::fromGlobals()->withMethod('PUT') ->withBody($body) ->withHeader('content-type', 'application/json'); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); /** @var MethodProphecy $process */ - $process = $delegate->process(Argument::type(ServerRequestInterface::class))->will( + $process = $delegate->handle(Argument::type(ServerRequestInterface::class))->will( function (array $args) use ($test) { /** @var ServerRequestInterface $req */ $req = array_shift($args); @@ -82,9 +82,9 @@ class BodyParserMiddlewareTest extends TestCase $body->write('foo=bar&bar[]=one&bar[]=5'); $request = ServerRequestFactory::fromGlobals()->withMethod('PUT') ->withBody($body); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); /** @var MethodProphecy $process */ - $process = $delegate->process(Argument::type(ServerRequestInterface::class))->will( + $process = $delegate->handle(Argument::type(ServerRequestInterface::class))->will( function (array $args) use ($test) { /** @var ServerRequestInterface $req */ $req = array_shift($args); diff --git a/module/Rest/test/Middleware/CheckAuthenticationMiddlewareTest.php b/module/Rest/test/Middleware/CheckAuthenticationMiddlewareTest.php index c8e26afe..fa7f7d06 100644 --- a/module/Rest/test/Middleware/CheckAuthenticationMiddlewareTest.php +++ b/module/Rest/test/Middleware/CheckAuthenticationMiddlewareTest.php @@ -6,7 +6,7 @@ namespace ShlinkioTest\Shlink\Rest\Middleware; use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\MethodProphecy; use Prophecy\Prophecy\ObjectProphecy; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; +use Psr\Http\Server\RequestHandlerInterface; use Shlinkio\Shlink\Rest\Action\AuthenticateAction; use Shlinkio\Shlink\Rest\Authentication\JWTService; use Shlinkio\Shlink\Rest\Middleware\CheckAuthenticationMiddleware; @@ -49,9 +49,9 @@ class CheckAuthenticationMiddlewareTest extends TestCase public function someWhiteListedSituationsFallbackToNextMiddleware() { $request = ServerRequestFactory::fromGlobals(); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); /** @var MethodProphecy $process */ - $process = $delegate->process($request)->willReturn(new Response()); + $process = $delegate->handle($request)->willReturn(new Response()); $this->middleware->process($request, $delegate->reveal()); $process->shouldHaveBeenCalledTimes(1); @@ -60,9 +60,9 @@ class CheckAuthenticationMiddlewareTest extends TestCase RouteResult::class, RouteResult::fromRouteFailure(['GET']) ); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); /** @var MethodProphecy $process */ - $process = $delegate->process($request)->willReturn(new Response()); + $process = $delegate->handle($request)->willReturn(new Response()); $this->middleware->process($request, $delegate->reveal()); $process->shouldHaveBeenCalledTimes(1); @@ -75,9 +75,9 @@ class CheckAuthenticationMiddlewareTest extends TestCase AuthenticateAction::class )) ); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); /** @var MethodProphecy $process */ - $process = $delegate->process($request)->willReturn(new Response()); + $process = $delegate->handle($request)->willReturn(new Response()); $this->middleware->process($request, $delegate->reveal()); $process->shouldHaveBeenCalledTimes(1); @@ -85,9 +85,9 @@ class CheckAuthenticationMiddlewareTest extends TestCase RouteResult::class, RouteResult::fromRoute(new Route('bar', $this->dummyMiddleware), []) )->withMethod('OPTIONS'); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); /** @var MethodProphecy $process */ - $process = $delegate->process($request)->willReturn(new Response()); + $process = $delegate->handle($request)->willReturn(new Response()); $this->middleware->process($request, $delegate->reveal()); $process->shouldHaveBeenCalledTimes(1); } @@ -101,7 +101,7 @@ class CheckAuthenticationMiddlewareTest extends TestCase RouteResult::class, RouteResult::fromRoute(new Route('bar', $this->dummyMiddleware), []) ); - $response = $this->middleware->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->middleware->process($request, TestUtils::createReqHandlerMock()->reveal()); $this->assertEquals(401, $response->getStatusCode()); } @@ -116,7 +116,7 @@ class CheckAuthenticationMiddlewareTest extends TestCase RouteResult::fromRoute(new Route('bar', $this->dummyMiddleware), []) )->withHeader(CheckAuthenticationMiddleware::AUTHORIZATION_HEADER, $authToken); - $response = $this->middleware->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->middleware->process($request, TestUtils::createReqHandlerMock()->reveal()); $this->assertEquals(401, $response->getStatusCode()); $this->assertTrue(strpos($response->getBody()->getContents(), 'You need to provide the Bearer type') > 0); @@ -133,7 +133,7 @@ class CheckAuthenticationMiddlewareTest extends TestCase RouteResult::fromRoute(new Route('bar', $this->dummyMiddleware), []) )->withHeader(CheckAuthenticationMiddleware::AUTHORIZATION_HEADER, 'Basic ' . $authToken); - $response = $this->middleware->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->middleware->process($request, TestUtils::createReqHandlerMock()->reveal()); $this->assertEquals(401, $response->getStatusCode()); $this->assertTrue( @@ -153,7 +153,7 @@ class CheckAuthenticationMiddlewareTest extends TestCase )->withHeader(CheckAuthenticationMiddleware::AUTHORIZATION_HEADER, 'Bearer ' . $authToken); $this->jwtService->verify($authToken)->willReturn(false)->shouldBeCalledTimes(1); - $response = $this->middleware->process($request, TestUtils::createDelegateMock()->reveal()); + $response = $this->middleware->process($request, TestUtils::createReqHandlerMock()->reveal()); $this->assertEquals(401, $response->getStatusCode()); } @@ -170,9 +170,9 @@ class CheckAuthenticationMiddlewareTest extends TestCase $this->jwtService->verify($authToken)->willReturn(true)->shouldBeCalledTimes(1); $this->jwtService->refresh($authToken)->willReturn($authToken)->shouldBeCalledTimes(1); - $delegate = $this->prophesize(DelegateInterface::class); + $delegate = $this->prophesize(RequestHandlerInterface::class); /** @var MethodProphecy $process */ - $process = $delegate->process($request)->willReturn(new Response()); + $process = $delegate->handle($request)->willReturn(new Response()); $resp = $this->middleware->process($request, $delegate->reveal()); $process->shouldHaveBeenCalledTimes(1); diff --git a/module/Rest/test/Middleware/CrossDomainMiddlewareTest.php b/module/Rest/test/Middleware/CrossDomainMiddlewareTest.php index 813f2e92..478113ff 100644 --- a/module/Rest/test/Middleware/CrossDomainMiddlewareTest.php +++ b/module/Rest/test/Middleware/CrossDomainMiddlewareTest.php @@ -6,7 +6,7 @@ namespace ShlinkioTest\Shlink\Rest\Middleware; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; +use Psr\Http\Server\RequestHandlerInterface; use Shlinkio\Shlink\Rest\Middleware\CrossDomainMiddleware; use Zend\Diactoros\Response; use Zend\Diactoros\ServerRequestFactory; @@ -25,7 +25,7 @@ class CrossDomainMiddlewareTest extends TestCase public function setUp() { $this->middleware = new CrossDomainMiddleware(); - $this->delegate = $this->prophesize(DelegateInterface::class); + $this->delegate = $this->prophesize(RequestHandlerInterface::class); } /** @@ -34,7 +34,7 @@ class CrossDomainMiddlewareTest extends TestCase public function nonCrossDomainRequestsAreNotAffected() { $originalResponse = new Response(); - $this->delegate->process(Argument::any())->willReturn($originalResponse)->shouldbeCalledTimes(1); + $this->delegate->handle(Argument::any())->willReturn($originalResponse)->shouldbeCalledTimes(1); $response = $this->middleware->process(ServerRequestFactory::fromGlobals(), $this->delegate->reveal()); $this->assertSame($originalResponse, $response); @@ -50,7 +50,7 @@ class CrossDomainMiddlewareTest extends TestCase public function anyRequestIncludesTheAllowAccessHeader() { $originalResponse = new Response(); - $this->delegate->process(Argument::any())->willReturn($originalResponse)->shouldbeCalledTimes(1); + $this->delegate->handle(Argument::any())->willReturn($originalResponse)->shouldbeCalledTimes(1); $response = $this->middleware->process( ServerRequestFactory::fromGlobals()->withHeader('Origin', 'local'), @@ -70,7 +70,7 @@ class CrossDomainMiddlewareTest extends TestCase { $originalResponse = new Response(); $request = ServerRequestFactory::fromGlobals()->withMethod('OPTIONS')->withHeader('Origin', 'local'); - $this->delegate->process(Argument::any())->willReturn($originalResponse)->shouldbeCalledTimes(1); + $this->delegate->handle(Argument::any())->willReturn($originalResponse)->shouldbeCalledTimes(1); $response = $this->middleware->process($request, $this->delegate->reveal()); $this->assertNotSame($originalResponse, $response); diff --git a/module/Rest/test/Middleware/PathVersionMiddlewareTest.php b/module/Rest/test/Middleware/PathVersionMiddlewareTest.php index f7d068de..e024c128 100644 --- a/module/Rest/test/Middleware/PathVersionMiddlewareTest.php +++ b/module/Rest/test/Middleware/PathVersionMiddlewareTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Psr\Http\Message\ServerRequestInterface as Request; -use Psr\Http\Server\RequestHandlerInterface as DelegateInterface; +use Psr\Http\Server\RequestHandlerInterface; use Shlinkio\Shlink\Rest\Middleware\PathVersionMiddleware; use Zend\Diactoros\Response; use Zend\Diactoros\ServerRequestFactory; @@ -32,8 +32,8 @@ class PathVersionMiddlewareTest extends TestCase { $request = ServerRequestFactory::fromGlobals()->withUri(new Uri('/rest/v2/foo')); - $delegate = $this->prophesize(DelegateInterface::class); - $process = $delegate->process($request)->willReturn(new Response()); + $delegate = $this->prophesize(RequestHandlerInterface::class); + $process = $delegate->handle($request)->willReturn(new Response()); $this->middleware->process($request, $delegate->reveal()); @@ -47,8 +47,8 @@ class PathVersionMiddlewareTest extends TestCase { $request = ServerRequestFactory::fromGlobals()->withUri(new Uri('/foo')); - $delegate = $this->prophesize(DelegateInterface::class); - $process = $delegate->process($request)->willReturn(new Response()); + $delegate = $this->prophesize(RequestHandlerInterface::class); + $process = $delegate->handle($request)->willReturn(new Response()); $this->middleware->process($request, $delegate->reveal()); @@ -62,8 +62,8 @@ class PathVersionMiddlewareTest extends TestCase { $request = ServerRequestFactory::fromGlobals()->withUri(new Uri('/rest/bar/baz')); - $delegate = $this->prophesize(DelegateInterface::class); - $delegate->process(Argument::type(Request::class))->will(function (array $args) use ($request) { + $delegate = $this->prophesize(RequestHandlerInterface::class); + $delegate->handle(Argument::type(Request::class))->will(function (array $args) use ($request) { $req = \array_shift($args); Assert::assertNotSame($request, $req);