PdfFormReaderServiceTest.php
1 <?php 2 3 namespace Tests\Services; 4 5 use App\Http\Services\PdfFormReaderService; 6 use Tests\TestCase; 7 8 class PdfFormReaderServiceTest extends TestCase 9 { 10 public string $sgoc = "test_files/certification_request/01. FOR-001/certification_request_v1.0.0.pdf"; 11 public string $ccn = "test_files/certification_request_ccn/01. FOR-001/solicitud_certificacion.pdf"; 12 13 public function testReadFieldsFromPdf() 14 { 15 $response = PdfFormReaderService::getDataFields($this->sgoc); 16 $this->assertIsArray($response); 17 $this->assertTrue(count($response) > 0); 18 $this->assertArrayHasKey('FieldType', $response[0]); 19 $this->assertArrayHasKey('FieldName', $response[0]); 20 $this->assertArrayHasKey('FieldValue', $response[0]); 21 } 22 23 public function testGetArrayKeyFromPdfForm() 24 { 25 $fieldName = 'toe_name'; 26 27 $response = PdfFormReaderService::read($this->sgoc); 28 $this->assertIsArray($response); 29 $this->assertArrayHasKey($fieldName, $response); 30 $this->assertEquals($response[$fieldName], 'Ramon\'s Laptop, Ramon\'s Laptop CODE1'); 31 } 32 33 /** @test */ 34 public function can_read_pdf_sgoc() 35 { 36 $response = PdfFormReaderService::getDataFields($this->sgoc); 37 $this->assertNotEquals([], $response); 38 } 39 40 /** @test */ 41 public function can_read_pdf_ccn() 42 { 43 $response = PdfFormReaderService::read($this->ccn); 44 $this->assertNotEquals([], $response); 45 } 46 }