* initial commit
This commit is contained in:
47
test/AppTest/Action/ShowCameraImageActionTest.php
Normal file
47
test/AppTest/Action/ShowCameraImageActionTest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user