slovocast/app/test/AppTest/Handler/HomePageHandlerFactoryTest.php

39 lines
1.2 KiB
PHP
Raw Normal View History

2024-02-22 03:14:42 +00:00
<?php
declare(strict_types=1);
namespace AppTest\Handler;
use App\Handler\HomePageHandler;
use App\Handler\HomePageHandlerFactory;
use AppTest\InMemoryContainer;
use Mezzio\Router\RouterInterface;
use Mezzio\Template\TemplateRendererInterface;
use PHPUnit\Framework\TestCase;
class HomePageHandlerFactoryTest extends TestCase
{
public function testFactoryWithoutTemplate(): void
{
$container = new InMemoryContainer();
$container->setService(RouterInterface::class, $this->createMock(RouterInterface::class));
$factory = new HomePageHandlerFactory();
$homePage = $factory($container);
self::assertInstanceOf(HomePageHandler::class, $homePage);
}
public function testFactoryWithTemplate(): void
{
$container = new InMemoryContainer();
$container->setService(RouterInterface::class, $this->createMock(RouterInterface::class));
$container->setService(TemplateRendererInterface::class, $this->createMock(TemplateRendererInterface::class));
$factory = new HomePageHandlerFactory();
$homePage = $factory($container);
self::assertInstanceOf(HomePageHandler::class, $homePage);
}
}