Skip to content
Snippets Groups Projects
Commit d975959c authored by François Agneray's avatar François Agneray
Browse files

Fixed tests

parent 05cd829f
No related branches found
No related tags found
2 merge requests!72Develop,!34New features
<?php
/*
* This file is part of Anis Server.
*
* (c) Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace App\Tests\Action;
use PHPUnit\Framework\TestCase;
use Slim\Exception\HttpNotFoundException;
use Nyholm\Psr7\ServerRequest;
use Nyholm\Psr7\Response;
use Doctrine\ORM\EntityManager;
final class DownloadFileActionTest extends TestCase
{
private $action;
private $entityManager;
protected function setUp(): void
{
$this->entityManager = $this->createMock(EntityManager::class);
$this->action = new \App\Action\DownloadFileAction($this->entityManager, '', array());
}
public function testOptionsHttpMethod(): void
{
$request = $this->getRequest('OPTIONS');
$response = ($this->action)($request, new Response(), array());
$this->assertSame($response->getHeaderLine('Access-Control-Allow-Methods'), 'GET, OPTIONS');
}
public function testDatasetIsNotFound(): void
{
$this->expectException(HttpNotFoundException::class);
$this->expectExceptionMessage('Dataset with name obs_cat is not found');
$request = $this->getRequest('GET');
$response = ($this->action)($request, new Response(), array('dname' => 'obs_cat'));
$this->assertEquals(404, (int) $response->getStatusCode());
}
private function getRequest(string $method): ServerRequest
{
return new ServerRequest($method, '/download-file/obs_cat/file.fits', array(
'Content-Type' => 'application/json'
));
}
}
......@@ -92,6 +92,7 @@ final class InstanceActionTest extends TestCase
'home_component' => 'WelcomeComponent',
'home_component_config' => '{}',
'samp_enabled' => true,
'back_to_portal' => true,
'search_by_criteria_allowed' => true,
'search_by_criteria_label' => 'Search',
'search_multiple_allowed' => false,
......
......@@ -91,6 +91,7 @@ final class InstanceListActionTest extends TestCase
'home_component' => 'WelcomeComponent',
'home_component_config' => '{}',
'samp_enabled' => true,
'back_to_portal' => true,
'search_by_criteria_allowed' => true,
'search_by_criteria_label' => 'Search',
'search_multiple_allowed' => false,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment