From b4d3484d2e68a801a5b23f90a4fcb438627b37ff Mon Sep 17 00:00:00 2001 From: Nikita Pimenov Date: Mon, 24 Jun 2024 18:48:12 +0400 Subject: [PATCH] fix: splat operator for PHP 7.4 --- model/DataStore/DeliverySyncTask.php | 2 +- test/unit/model/DataStore/DeliverySyncTaskTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/model/DataStore/DeliverySyncTask.php b/model/DataStore/DeliverySyncTask.php index f9751249..a058b332 100644 --- a/model/DataStore/DeliverySyncTask.php +++ b/model/DataStore/DeliverySyncTask.php @@ -40,7 +40,7 @@ class DeliverySyncTask extends AbstractAction implements JsonSerializable public function __invoke($params) { $report = new Report(Report::TYPE_SUCCESS); - $resourceSyncDTO = new ResourceSyncDTO(...$params[0]); + $resourceSyncDTO = new ResourceSyncDTO(...array_values($params[0])); $tryNumber = $params[1]; if ($tryNumber < $resourceSyncDTO->getMaxTries()) { diff --git a/test/unit/model/DataStore/DeliverySyncTaskTest.php b/test/unit/model/DataStore/DeliverySyncTaskTest.php index 2d1ff66b..ae3fc2a6 100644 --- a/test/unit/model/DataStore/DeliverySyncTaskTest.php +++ b/test/unit/model/DataStore/DeliverySyncTaskTest.php @@ -27,6 +27,7 @@ use oat\generis\test\OntologyMockTrait; use oat\generis\test\TestCase; use oat\oatbox\reporting\Report; +use oat\oatbox\service\exception\InvalidServiceManagerException; use oat\tao\model\featureFlag\FeatureFlagChecker; use oat\tao\model\featureFlag\FeatureFlagCheckerInterface; use oat\tao\model\metadata\compiler\ResourceJsonMetadataCompiler; @@ -99,6 +100,9 @@ public function testJsonSerialize(): void ); } + /** + * @throws InvalidServiceManagerException + */ public function testInvoke() { $this->persistDataService->method('persist'); @@ -124,5 +128,15 @@ public function testInvoke() $expected = new Report(Report::TYPE_SUCCESS); $expected->setMessage('Success MetaData syncing for delivery: ' . $mockDelivery->getUri()); $this->assertEquals($expected, $response); + + try { + $subject = $this->subject; + $subject([ + ['resourceId' => $mockDelivery->getUri(), 'fileSystemId' => 'dataStore'], // check assoc array + 0 + ]); + } catch (\Throwable $e) { + $this->fail(sprintf('Exception thrown during the task invoke %s', $e->getMessage())); + } } }