From 72dc773a1c840e7e33ced8cece6e751a9d38ba1e Mon Sep 17 00:00:00 2001 From: laurynas-baltsoft <38224044+laurynas-baltsoft@users.noreply.github.com> Date: Tue, 18 Jul 2023 22:30:59 +0300 Subject: [PATCH] Handle multiple file params (#44) --- lib/ConvertApi/Task.php | 6 +++--- tests/ConvertApi/ConvertApiTest.php | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/ConvertApi/Task.php b/lib/ConvertApi/Task.php index cd9b8d7..fca394e 100644 --- a/lib/ConvertApi/Task.php +++ b/lib/ConvertApi/Task.php @@ -46,12 +46,12 @@ private function normalizedParams() foreach ($this->params as $key => $val) { - switch($key) { - case 'File': + switch(true) { + case $key != 'StoreFile' && preg_match('/File$/', $key): $result[$key] = FileParam::build($val); break; - case 'Files': + case $key == 'Files': $result[$key] = $this->filesBatch($val); break; diff --git a/tests/ConvertApi/ConvertApiTest.php b/tests/ConvertApi/ConvertApiTest.php index 4429f40..3cb76f5 100644 --- a/tests/ConvertApi/ConvertApiTest.php +++ b/tests/ConvertApi/ConvertApiTest.php @@ -159,6 +159,18 @@ public function testChainedConversion() $this->assertEquals('test.zip', $result->getFile()->getFileName()); } + public function testCompare() + { + $params = [ + 'File' => 'examples/files/test.docx', + 'CompareFile' => 'examples/files/test.docx' + ]; + + $result = ConvertApi::convert('compare', $params); + + $this->assertEquals('test.docx', $result->getFile()->getFileName()); + } + public function testApiError() { $params = ['Url' => 'https://www.w3.org/TR/PNG/iso_8859-1.txt'];