/ tests / Services / PolServiceTest.php
PolServiceTest.php
 1  <?php
 2  
 3  namespace Tests\Unit;
 4  
 5  use App\Enums\InboxFileTypeEnum;
 6  use App\Http\Services\PolService;
 7  use Tests\TestCase;
 8  
 9  class PolServiceTest extends TestCase
10  {
11      public string $dir = "templates/POL_files/";
12  
13      public function setUp(): void
14      {
15          parent::setUp();
16      }
17  
18      public function fileToTypeProvider()
19      {
20          return [
21              ['2024-01-01_2024-00_solicitud_certificacion.zip', InboxFileTypeEnum::certification_request()],
22              ['2024-01-01_2024-01_solicitud_evaluacion.zip', InboxFileTypeEnum::evaluation_request()],
23              ['2024-01-01_2024-01_ORs.zip', InboxFileTypeEnum::OR()],
24              ['2024-01-01_2024-01_informe_parcial_ASE_v1.zip', InboxFileTypeEnum::partial_report()],
25              ['2024-01-01_2024-01_ETR_v1.2.zip', InboxFileTypeEnum::ETR()],
26          ];
27      }
28  
29      /**
30       * @dataProvider fileToTypeProvider
31       */
32      public function test_extract_type(string $path, InboxFileTypeEnum $expectedType)
33      {
34          $got = PolService::extractType($this->dir . $path);
35          $this->assertIsString($got);
36          $this->assertEquals($expectedType, $got);
37      }
38  
39      public function commonCriteriaFileProvider()
40      {
41          return [
42              ['certification_request', '2024-01-01_2024-00_solicitud_certificacion.zip'],
43              ['evaluation_request', '2024-01-01_2024-01_solicitud_evaluacion.zip'],
44              ['ORs', '2024-01-01_2024-01_ORs.zip'],
45              ['partial_report', '2024-01-01_2024-01_informe_parcial_ASE_v1.zip'],
46              ['ETR', '2024-01-01_2024-01_ETR_v1.zip'],
47          ];
48      }
49  
50      /**
51       * @dataProvider commonCriteriaFileProvider
52       */
53      public function test_compare_structure_cc(string $type, string $path)
54      {
55          $polService = new PolService('Common Criteria', $type);
56          $succeeded = $polService->verifyDirectoryStructure($this->dir . 'CC/' . $path);
57          $this->assertTrue($succeeded);
58      }
59  
60      public function linceFileProvider()
61      {
62          return [
63              ['certification_request', '2024-01-01_2024-00_solicitud_certificacion.zip'],
64              ['evaluation_request', '2024-01-01_2024-01_solicitud_evaluacion.zip'],
65              ['ORs', '2024-01-01_2024-01_ORs.zip'],
66              ['ETR', '2024-01-01_2024-01_ETR_v1.zip'],
67          ];
68      }
69  
70      /**
71       * @dataProvider linceFileProvider
72       */
73      public function test_compare_structure_lince(string $type, string $path)
74      {
75          $polService = new PolService('LINCE', $type);
76          $succeeded = $polService->verifyDirectoryStructure($this->dir . 'LINCE/' . $path);
77          $this->assertTrue($succeeded);
78      }
79  }