simen-backend-zf3mw/test/AppTest/Action/HomePageFactoryTest.php

51 lines
1.5 KiB
PHP
Raw Normal View History

2016-07-31 20:47:25 +02:00
<?php
namespace AppTest\Action;
use App\Action\HomePageAction;
use App\Action\HomePageFactory;
use Interop\Container\ContainerInterface;
use Doctrine\ORM\EntityManager;
2016-07-31 20:47:25 +02:00
use Zend\Expressive\Template\TemplateRendererInterface;
class HomePageFactoryTest extends \PHPUnit_Framework_TestCase
{
/** @var ContainerInterface */
protected $container;
protected function setUp()
{
$this->container = $this->prophesize(ContainerInterface::class);
$em = $this->prophesize(EntityManager::class);
2016-07-31 20:47:25 +02:00
$this->container->get('doctrine.entity_manager.orm_default')->willReturn($em);
2016-07-31 20:47:25 +02:00
}
public function testFactoryWithoutTemplate()
{
$factory = new HomePageFactory();
$this->container->has(TemplateRendererInterface::class)->willReturn(false);
$this->assertTrue($factory instanceof HomePageFactory);
$homePage = $factory($this->container->reveal());
$this->assertTrue($homePage instanceof HomePageAction);
}
public function testFactoryWithTemplate()
{
$factory = new HomePageFactory();
$this->container->has(TemplateRendererInterface::class)->willReturn(true);
$this->container
->get(TemplateRendererInterface::class)
->willReturn($this->prophesize(TemplateRendererInterface::class));
$this->assertTrue($factory instanceof HomePageFactory);
$homePage = $factory($this->container->reveal());
$this->assertTrue($homePage instanceof HomePageAction);
}
}