Skip to content

Commit

Permalink
replace testableAbstractHandler with an anoymous class
Browse files Browse the repository at this point in the history
  • Loading branch information
MishNajam committed Dec 8, 2023
1 parent c8700af commit f16a444
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
18 changes: 15 additions & 3 deletions service-front/app/test/CommonTest/Handler/AbstractHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

namespace CommonTest\Handler;

use CommonTest\Handler\TestableAbstractHandler;
use Common\Handler\AbstractHandler;
use Mezzio\Helper\UrlHelper;
use Mezzio\Template\TemplateRendererInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

class AbstractHandlerTest extends TestCase
{
Expand All @@ -33,7 +35,12 @@ public function testRedirectToRouteWithOverride(): void

$renderer = $this->prophesize(TemplateRendererInterface::class);

$abstractHandler = new TestableAbstractHandler($renderer->reveal(), $urlHelperMock->reveal());
$abstractHandler = new class ($renderer->reveal(), $urlHelperMock->reveal()) extends AbstractHandler {
public function handle(ServerRequestInterface $request): ResponseInterface
{
throw new Exception('Not implemented');
}
};
$response = $abstractHandler->redirectToRoute(
'fake-route',
['fake-route-parameters'],
Expand All @@ -55,7 +62,12 @@ public function testRedirectToRouteOverrideSetToNull(): void

$renderer = $this->prophesize(TemplateRendererInterface::class);

$abstractHandler = new TestableAbstractHandler($renderer->reveal(), $urlHelperMock->reveal());
$abstractHandler = new class($renderer->reveal(), $urlHelperMock->reveal()) extends AbstractHandler {
public function handle(ServerRequestInterface $request): ResponseInterface
{
throw new Exception('Not implemented');
}
};
$response = $abstractHandler->redirectToRoute('fake-route');
$this->assertEquals('/fake-route', $response->getHeader('location')[0]);
}
Expand Down

This file was deleted.

0 comments on commit f16a444

Please sign in to comment.