* cleanup skeleton project files

* fixed entity mapping
* added documentation
This commit is contained in:
Danyi Dávid
2016-08-01 18:33:33 +02:00
parent 2de0bf8add
commit 15fe800840
10 changed files with 130 additions and 878 deletions

View 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());
}
}

View 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);
}
}

View File

@@ -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()