* 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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user