* added some example tests

This commit is contained in:
Dávid Danyi
2017-03-23 18:46:04 +01:00
parent c28fe6bd96
commit 217c1b599f
5 changed files with 219 additions and 1 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace AppTest\Action;
use App\Action\JcatPackageAction;
use App\Response\JsonCorsResponse;
use App\Service\CiExecutorService;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequest;
class JcatPackageActionTest extends \PHPUnit_Framework_TestCase
{
protected $testJcatVersions = [
"TSP_JCAT-138.3",
"TSP_JCAT-138.2",
"TSP_JCAT-138.1_TSPBUG-10203",
"TSP_JCAT-138.1",
"TSP_JCAT-138.0_CORE",
"TSP_JCAT-138.0_COMMON",
"TSP_JCAT-138.0",
];
/** @var CiExecutorService */
protected $ciExecutorService;
protected function setUp()
{
$this->ciExecutorService = $this->prophesize(CiExecutorService::class);
$this->ciExecutorService->getJcatPackages()->willReturn($this->testJcatVersions);
}
public function testResponse()
{
$ciConfigPage = new JcatPackageAction($this->ciExecutorService->reveal());
$response = $ciConfigPage(new ServerRequest(), new Response(), function () {
});
$this->assertTrue($response instanceof Response);
}
public function testGetList()
{
$ciConfigPage = new JcatPackageAction($this->ciExecutorService->reveal());
$response = $ciConfigPage(new ServerRequest(), new Response(), function () {
});
$this->assertTrue($response instanceof JsonCorsResponse);
$json = json_decode((string) $response->getBody());
$this->assertTrue(is_array($json));
$this->assertTrue($json == $this->testJcatVersions);
}
}