11<?php
22
3- namespace V2 \parsing ;
3+ namespace V2 \Parsing ;
44
55use Mindee \Error \ErrorItem ;
66use Mindee \Geometry \Point ;
@@ -24,7 +24,7 @@ class InferenceResponseTest extends TestCase
2424{
2525 private function loadFromResource (string $ resourcePath ): InferenceResponse
2626 {
27- $ fullPath = TestingUtilities::getRootDataDir () . "/ $ resourcePath " ;
27+ $ fullPath = TestingUtilities::getV2ProductDir () . "/ $ resourcePath " ;
2828 $ this ->assertFileExists ($ fullPath , "Resource file must exist: $ resourcePath " );
2929
3030 $ localResponse = new LocalResponse ($ fullPath );
@@ -39,11 +39,12 @@ private function readFileAsString(string $path): string
3939 }
4040
4141 /**
42- * When the async prediction is blank - all properties must be valid
42+ * When the async prediction is blank - all properties must be valid.
43+ * @return void
4344 */
4445 public function testAsyncPredictWhenEmptyMustHaveValidProperties (): void
4546 {
46- $ response = $ this ->loadFromResource ('v2/products/ extraction/financial_document/blank.json ' );
47+ $ response = $ this ->loadFromResource ('extraction/financial_document/blank.json ' );
4748 $ fields = $ response ->inference ->result ->fields ;
4849
4950 $ this ->assertCount (21 , $ fields , 'Expected 21 fields ' );
@@ -91,11 +92,12 @@ public function testAsyncPredictWhenEmptyMustHaveValidProperties(): void
9192 }
9293
9394 /**
94- * When the async prediction is complete - every exposed property must be valid and consistent
95+ * When the async prediction is complete - every exposed property must be valid and consistent.
96+ * @return void
9597 */
9698 public function testAsyncPredictWhenCompleteMustExposeAllProperties (): void
9799 {
98- $ response = $ this ->loadFromResource ('v2/products/ extraction/financial_document/complete.json ' );
100+ $ response = $ this ->loadFromResource ('extraction/financial_document/complete.json ' );
99101 $ inference = $ response ->inference ;
100102
101103 $ this ->assertNotNull ($ inference , 'Inference must not be null ' );
@@ -154,11 +156,12 @@ public function testAsyncPredictWhenCompleteMustExposeAllProperties(): void
154156 }
155157
156158 /**
157- * Deep nested fields - all nested structures must be typed correctly
159+ * Deep nested fields - all nested structures must be typed correctly.
160+ * @return void
158161 */
159162 public function testDeepNestedFieldsMustExposeCorrectTypes (): void
160163 {
161- $ response = $ this ->loadFromResource ('v2/products/ extraction/deep_nested_fields.json ' );
164+ $ response = $ this ->loadFromResource ('extraction/deep_nested_fields.json ' );
162165 $ inference = $ response ->inference ;
163166 $ this ->assertNotNull ($ inference );
164167
@@ -198,11 +201,12 @@ public function testDeepNestedFieldsMustExposeCorrectTypes(): void
198201 }
199202
200203 /**
201- * Standard field types - simple / object / list variants must be recognised
204+ * Standard field types - simple / object / list variants must be recognised.
205+ * @return void
202206 */
203207 public function testStandardFieldTypesMustExposeCorrectTypes (): void
204208 {
205- $ response = $ this ->loadFromResource ('v2/products/ extraction/standard_field_types.json ' );
209+ $ response = $ this ->loadFromResource ('extraction/standard_field_types.json ' );
206210 $ inference = $ response ->inference ;
207211 $ this ->assertNotNull ($ inference );
208212
@@ -279,11 +283,12 @@ public function testStandardFieldTypesMustExposeCorrectTypes(): void
279283 }
280284
281285 /**
282- * Raw texts option must be parsed and exposed
286+ * Raw texts option must be parsed and exposed.
287+ * @return void
283288 */
284289 public function testRawTextsMustBeAccessible (): void
285290 {
286- $ response = $ this ->loadFromResource ('v2/products/ extraction/raw_texts.json ' );
291+ $ response = $ this ->loadFromResource ('extraction/raw_texts.json ' );
287292 $ inference = $ response ->inference ;
288293 $ this ->assertNotNull ($ inference );
289294
@@ -306,13 +311,14 @@ public function testRawTextsMustBeAccessible(): void
306311 }
307312
308313 /**
309- * RST display must be parsed and exposed
314+ * RST display must be parsed and exposed.
315+ * @return void
310316 */
311317 public function testRstDisplayMustBeAccessible (): void
312318 {
313- $ response = $ this ->loadFromResource ('v2/products/ extraction/standard_field_types.json ' );
319+ $ response = $ this ->loadFromResource ('extraction/standard_field_types.json ' );
314320 $ expectedRst = $ this ->readFileAsString (
315- \TestingUtilities::getV2DataDir () . '/products /extraction/standard_field_types.rst '
321+ \TestingUtilities::getV2ProductDir () . '/extraction/standard_field_types.rst '
316322 );
317323 $ inference = $ response ->inference ;
318324 $ this ->assertNotNull ($ inference );
@@ -321,10 +327,11 @@ public function testRstDisplayMustBeAccessible(): void
321327
322328 /**
323329 * Coordinates & location data must be parsed and exposed.
330+ * @return void
324331 */
325332 public function testCoordinatesAndLocationDataMustBeAccessible (): void
326333 {
327- $ response = $ this ->loadFromResource ('v2/products/ extraction/financial_document/complete_with_coordinates.json ' );
334+ $ response = $ this ->loadFromResource ('extraction/financial_document/complete_with_coordinates.json ' );
328335 $ inference = $ response ->inference ;
329336 $ this ->assertNotNull ($ inference );
330337
@@ -383,23 +390,25 @@ public function testCoordinatesAndLocationDataMustBeAccessible(): void
383390
384391 public function testRagMetadataWhenMatched ()
385392 {
386- $ response = $ this ->loadFromResource ('v2/products/ extraction/rag_matched.json ' );
393+ $ response = $ this ->loadFromResource ('extraction/rag_matched.json ' );
387394 $ inference = $ response ->inference ;
388395 $ this ->assertNotNull ($ inference );
389396 $ this ->assertEquals ('12345abc-1234-1234-1234-123456789abc ' , $ inference ->result ->rag ->retrievedDocumentId );
390397 }
391398
392399 public function testRagMetadataWhenNotMatched ()
393400 {
394- $ response = $ this ->loadFromResource ('v2/products/ extraction/rag_not_matched.json ' );
401+ $ response = $ this ->loadFromResource ('extraction/rag_not_matched.json ' );
395402 $ inference = $ response ->inference ;
396403 $ this ->assertNotNull ($ inference );
397404 $ this ->assertNull ($ inference ->result ->rag ->retrievedDocumentId );
398405 }
399406
400407 public function testShouldLoadWith422Error ()
401408 {
402- $ jsonResponse = json_decode (file_get_contents (\TestingUtilities::getV2DataDir () . '/job/fail_422.json ' ), true );
409+ $ jsonResponse = json_decode (
410+ file_get_contents (\TestingUtilities::getV2DataDir () . '/job/fail_422.json ' ), true
411+ );
403412 $ response = new JobResponse ($ jsonResponse );
404413 $ this ->assertNotNull ($ response ->job );
405414 $ this ->assertInstanceOf (ErrorResponse::class, $ response ->job ->error );
@@ -411,7 +420,7 @@ public function testShouldLoadWith422Error()
411420
412421 public function testTextContextIsTrue (): void
413422 {
414- $ response = $ this ->loadFromResource ('v2/products/ extraction/text_context_enabled.json ' );
423+ $ response = $ this ->loadFromResource ('extraction/text_context_enabled.json ' );
415424 $ inference = $ response ->inference ;
416425 $ this ->assertNotNull ($ inference );
417426 $ activeOptions = $ inference ->activeOptions ;
@@ -424,7 +433,7 @@ public function testTextContextIsTrue(): void
424433
425434 public function testTextContextIsFalse (): void
426435 {
427- $ response = $ this ->loadFromResource ('v2/products/ extraction/financial_document/complete.json ' );
436+ $ response = $ this ->loadFromResource ('extraction/financial_document/complete.json ' );
428437 $ inference = $ response ->inference ;
429438 $ this ->assertNotNull ($ inference );
430439 $ activeOptions = $ inference ->activeOptions ;
0 commit comments