From d975959ca156ed4dfa526bd7b502913f9eff5e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Agneray?= <francois.agneray@lam.fr> Date: Fri, 1 Apr 2022 21:30:50 +0200 Subject: [PATCH] Fixed tests --- .../tests/Action/DownloadFileActionTest.php | 54 ------------------- server/tests/Action/InstanceActionTest.php | 1 + .../tests/Action/InstanceListActionTest.php | 1 + 3 files changed, 2 insertions(+), 54 deletions(-) delete mode 100644 server/tests/Action/DownloadFileActionTest.php diff --git a/server/tests/Action/DownloadFileActionTest.php b/server/tests/Action/DownloadFileActionTest.php deleted file mode 100644 index a250e03e..00000000 --- a/server/tests/Action/DownloadFileActionTest.php +++ /dev/null @@ -1,54 +0,0 @@ -<?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' - )); - } -} diff --git a/server/tests/Action/InstanceActionTest.php b/server/tests/Action/InstanceActionTest.php index 1340c77e..60645f6a 100644 --- a/server/tests/Action/InstanceActionTest.php +++ b/server/tests/Action/InstanceActionTest.php @@ -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, diff --git a/server/tests/Action/InstanceListActionTest.php b/server/tests/Action/InstanceListActionTest.php index 2254c0b9..5ad65130 100644 --- a/server/tests/Action/InstanceListActionTest.php +++ b/server/tests/Action/InstanceListActionTest.php @@ -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, -- GitLab