52 lines
1.5 KiB
PHP
Raw Normal View History

<?php
namespace AppTest\Action\Article;
use App\Action\Article\DeleteAction;
use App\Action\Article\DeleteFactory;
use App\Service\Article\ArticleService;
use Interop\Container\ContainerInterface;
use Zend\Expressive\Template\TemplateRendererInterface;
class DeleteFactoryTest extends \PHPUnit_Framework_TestCase
{
/** @var ContainerInterface */
protected $container;
protected function setUp()
{
$this->container = $this->prophesize(ContainerInterface::class);
$articleService = $this->prophesize(ArticleService::class);
$this->container->get(ArticleService::class)->willReturn($articleService);
}
public function testFactoryWithoutTemplate()
{
$factory = new DeleteFactory();
$this->container->has(TemplateRendererInterface::class)->willReturn(false);
$this->assertTrue($factory instanceof DeleteFactory);
$page = $factory($this->container->reveal());
$this->assertTrue($page instanceof DeleteAction);
}
public function testFactoryWithTemplate()
{
$factory = new DeleteFactory();
$this->container->has(TemplateRendererInterface::class)->willReturn(true);
$this->container
->get(TemplateRendererInterface::class)
->willReturn($this->prophesize(TemplateRendererInterface::class));
$this->assertTrue($factory instanceof DeleteFactory);
$homePage = $factory($this->container->reveal());
$this->assertTrue($homePage instanceof DeleteAction);
}
}