camera-picture-slide/test/AppTest/Action/ShowCameraImageActionTest.php
2018-01-15 23:07:21 +01:00

45 lines
1.3 KiB
PHP

<?php
namespace AppTest\Action;
use App\Action\ShowCameraImageAction;
use App\Service\CameraPictureManagerService;
use Interop\Http\ServerMiddleware\DelegateInterface;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\JsonResponse;
class ShowCameraImageActionTest extends TestCase
{
const CAM_DIR = "cam1";
const IMG_FILE = "img1.png";
/** @var CameraPictureManagerService */
protected $cameraPictureManager;
protected function setUp()
{
$this->cameraPictureManager = $this->prophesize(CameraPictureManagerService::class);
$this->cameraPictureManager->getCameraImage(self::CAM_DIR, self::IMG_FILE)
->willReturn($this->prophesize(JsonResponse::class));
}
public function testReturnsJsonResponse()
{
$homePage = new ShowCameraImageAction(
$this->cameraPictureManager->reveal()
);
$request = $this->prophesize(ServerRequestInterface::class);
$request->getAttribute('camera')->willReturn(self::CAM_DIR);
$request->getAttribute('image')->willReturn(self::IMG_FILE);
$response = $homePage->process(
$request->reveal(),
$this->prophesize(DelegateInterface::class)->reveal()
);
$this->assertInstanceOf(JsonResponse::class, $response);
}
}