camera-picture-slide/test/AppTest/Action/ShowCameraImageActionTest.php

48 lines
1.4 KiB
PHP
Raw Normal View History

2018-01-15 20:50:40 +01:00
<?php
namespace AppTest\Action;
use App\Action\ShowCameraImageAction;
use App\Service\CameraPictureManagerService;
use Interop\Http\ServerMiddleware\DelegateInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
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('cam1');
$request->getAttribute('image')
->willReturn('img1.png');
$response = $homePage->process(
$request->reveal(),
$this->prophesize(DelegateInterface::class)->reveal()
);
$this->assertInstanceOf(JsonResponse::class, $response);
}
}