* cleanup skeleton project files
* fixed entity mapping * added documentation
This commit is contained in:
48
test/AppTest/Action/Article/DeleteActionTest.php
Normal file
48
test/AppTest/Action/Article/DeleteActionTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace AppTest\Action\Article;
|
||||
|
||||
use App\Action\Article\DeleteAction;
|
||||
use App\Service\Article\ArticleService;
|
||||
use App\Service\EntityServiceInterface;
|
||||
use Zend\Diactoros\Response;
|
||||
use Zend\Diactoros\ServerRequest;
|
||||
|
||||
class DeleteActionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/** @var EntityServiceInterface */
|
||||
protected $entityService;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->entityService = $this->prophesize(ArticleService::class);
|
||||
$this->entityService->willImplement(EntityServiceInterface::class);
|
||||
$this->entityService->delete(1)->willReturn(true);
|
||||
$this->entityService->delete(10)->willReturn(false);
|
||||
}
|
||||
|
||||
public function testCanDelete()
|
||||
{
|
||||
$page = new DeleteAction($this->entityService->reveal());
|
||||
$request = new ServerRequest();
|
||||
$response = $page($request->withAttribute('id', 1), new Response(), function () {
|
||||
|
||||
});
|
||||
|
||||
$this->assertTrue($response instanceof Response);
|
||||
$this->assertEquals('true', $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
public function testCantDelete()
|
||||
{
|
||||
$page = new DeleteAction($this->entityService->reveal());
|
||||
$request = new ServerRequest();
|
||||
$response = $page($request->withAttribute('id', 10), new Response(), function () {
|
||||
|
||||
});
|
||||
|
||||
$this->assertTrue($response instanceof Response);
|
||||
$this->assertEquals('false', $response->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
51
test/AppTest/Action/Article/DeleteFactoryTest.php
Normal file
51
test/AppTest/Action/Article/DeleteFactoryTest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace AppTest\Action\Article;
|
||||
|
||||
use App\Action\Article\ListAction;
|
||||
use App\Entity\User;
|
||||
use App\Service\Article\ArticleService;
|
||||
use App\Service\EntityServiceInterface;
|
||||
use Zend\Diactoros\Response;
|
||||
@@ -17,13 +16,9 @@ class ListActionTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
$entityService = $this->prophesize(ArticleService::class);
|
||||
$entityService->willImplement(EntityServiceInterface::class);
|
||||
$entityService->getList()->willReturn([]);
|
||||
|
||||
$this->entityService = $entityService;
|
||||
$this->entityService = $this->prophesize(ArticleService::class);
|
||||
$this->entityService->willImplement(EntityServiceInterface::class);
|
||||
$this->entityService->getList()->willReturn([]);
|
||||
}
|
||||
|
||||
public function testResponse()
|
||||
|
||||
Reference in New Issue
Block a user