@@ -21,28 +21,23 @@ class ClientTest extends TestCase
2121 private Client $ dummyClient ;
2222 private Client $ envClient ;
2323 private string $ oldKey ;
24- private string $ fileTypesDir ;
2524 private string $ multiReceiptsDetectorPath ;
2625 private string $ failedJobPath ;
2726
2827
2928 protected function setUp (): void
3029 {
31- $ rootPath = (getenv ('GITHUB_WORKSPACE ' ) ?: ". " );
3230 $ this ->oldKey = getenv ('MINDEE_API_KEY ' );
3331 $ this ->dummyClient = new Client ("dummy-key " );
3432 putenv ('MINDEE_API_KEY= ' );
3533 $ this ->emptyClient = new Client ();
3634 putenv ('MINDEE_API_KEY=dummy-env-key ' );
3735 $ this ->envClient = new Client ();
38- $ this ->fileTypesDir = (
39- $ rootPath . "/tests/resources/file_types/ "
40- );
4136 $ this ->multiReceiptsDetectorPath = (
42- $ rootPath . "/tests/resources /products/multi_receipts_detector/response_v1/complete.json "
37+ \TestingUtilities:: getV1DataDir () . "/products/multi_receipts_detector/response_v1/complete.json "
4338 );
4439 $ this ->failedJobPath = (
45- $ rootPath . "/tests/resources /async/get_failed_job_error.json "
40+ \TestingUtilities:: getV1DataDir () . "/async/get_failed_job_error.json "
4641 );
4742 }
4843
@@ -56,37 +51,37 @@ public function testParsePathWithoutToken()
5651 {
5752 $ this ->expectException (MindeeHttpClientException::class);
5853
59- $ inputDoc = $ this ->emptyClient ->sourceFromPath ($ this -> fileTypesDir . "pdf/blank.pdf " );
54+ $ inputDoc = $ this ->emptyClient ->sourceFromPath (\TestingUtilities:: getFileTypesDir () . "/ pdf/blank.pdf " );
6055 $ this ->emptyClient ->parse (InvoiceV4::class, $ inputDoc );
6156 }
6257
6358 public function testParsePathWithEnvToken ()
6459 {
6560 $ this ->expectException (MindeeHttpException::class);
6661
67- $ inputDoc = $ this ->envClient ->sourceFromPath ($ this -> fileTypesDir . "pdf/blank.pdf " );
62+ $ inputDoc = $ this ->envClient ->sourceFromPath (\TestingUtilities:: getFileTypesDir () . "/ pdf/blank.pdf " );
6863 $ this ->envClient ->parse (InvoiceV4::class, $ inputDoc );
6964 }
7065
7166 public function testParsePathWithWrongFileType ()
7267 {
7368 $ this ->expectException (Mindee \Error \MindeeMimeTypeException::class);
7469
75- $ inputDoc = $ this ->dummyClient ->sourceFromPath ($ this -> fileTypesDir . " receipt.txt " );
70+ $ inputDoc = $ this ->dummyClient ->sourceFromPath (\TestingUtilities:: getFileTypesDir () . " / receipt.txt " );
7671 }
7772
7873 public function testParsePathWithWrongToken ()
7974 {
8075 $ this ->expectException (MindeeHttpClientException::class);
8176
82- $ inputDoc = $ this ->dummyClient ->sourceFromPath ($ this -> fileTypesDir . "pdf/blank.pdf " );
77+ $ inputDoc = $ this ->dummyClient ->sourceFromPath (\TestingUtilities:: getFileTypesDir () . "/ pdf/blank.pdf " );
8378 $ this ->dummyClient ->parse (InvoiceV4::class, $ inputDoc );
8479 }
8580
8681 public function testInterfaceVersion ()
8782 {
8883 $ dummyEndpoint = $ this ->dummyClient ->createEndpoint ("dummy " , "dummy " , "1.1 " );
89- $ inputDoc = $ this ->dummyClient ->sourceFromPath ($ this -> fileTypesDir . "pdf/blank.pdf " );
84+ $ inputDoc = $ this ->dummyClient ->sourceFromPath (\TestingUtilities:: getFileTypesDir () . "/ pdf/blank.pdf " );
9085 $ predictOptions = new PredictMethodOptions ();
9186 $ this ->assertEquals ("1.1 " , $ dummyEndpoint ->settings ->version );
9287
@@ -100,7 +95,7 @@ public function testInterfaceVersion()
10095
10196 public function testCutOptions ()
10297 {
103- $ inputDoc = $ this ->dummyClient ->sourceFromPath ($ this -> fileTypesDir . "pdf/multipage.pdf " );
98+ $ inputDoc = $ this ->dummyClient ->sourceFromPath (\TestingUtilities:: getFileTypesDir () . "/ pdf/multipage.pdf " );
10499 $ this ->expectException (MindeeHttpClientException::class);
105100 $ pageOptions = new PageOptions (range (0 , 4 ));
106101 $ this ->dummyClient ->parse (ReceiptV5::class, $ inputDoc , null , $ pageOptions );
@@ -138,7 +133,7 @@ public function testPredictOptionsValidInputType()
138133 {
139134 $ predictOptions = new PredictMethodOptions ();
140135 $ this ->assertTrue ($ predictOptions ->pageOptions ->isEmpty ());
141- $ inputDoc = $ this ->dummyClient ->sourceFromPath ($ this -> fileTypesDir . "pdf/blank.pdf " );
136+ $ inputDoc = $ this ->dummyClient ->sourceFromPath (\TestingUtilities:: getFileTypesDir () . "/ pdf/blank.pdf " );
142137 $ this ->expectException (MindeeHttpClientException::class);
143138 $ this ->dummyClient ->parse (InvoiceV4::class, $ inputDoc , $ predictOptions );
144139 $ this ->expectException (MindeeHttpClientException::class);
0 commit comments