52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace AppTest\Action\Article;
|
|
|
|
use App\Action\Article\ListAction;
|
|
use App\Action\Article\ListFactory;
|
|
use App\Service\Article\ArticleService;
|
|
use Interop\Container\ContainerInterface;
|
|
use Zend\Expressive\Template\TemplateRendererInterface;
|
|
|
|
class ListFactoryTest 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 ListFactory();
|
|
$this->container->has(TemplateRendererInterface::class)->willReturn(false);
|
|
|
|
$this->assertTrue($factory instanceof ListFactory);
|
|
|
|
$page = $factory($this->container->reveal());
|
|
|
|
$this->assertTrue($page instanceof ListAction);
|
|
}
|
|
|
|
public function testFactoryWithTemplate()
|
|
{
|
|
$factory = new ListFactory();
|
|
$this->container->has(TemplateRendererInterface::class)->willReturn(true);
|
|
$this->container
|
|
->get(TemplateRendererInterface::class)
|
|
->willReturn($this->prophesize(TemplateRendererInterface::class));
|
|
|
|
$this->assertTrue($factory instanceof ListFactory);
|
|
|
|
$homePage = $factory($this->container->reveal());
|
|
|
|
$this->assertTrue($homePage instanceof ListAction);
|
|
}
|
|
}
|