55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
|
|
<?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);
|
||
|
|
}
|
||
|
|
}
|