Skip to content

Commit

Permalink
feat: change return type of formatConfigurationPayload
Browse files Browse the repository at this point in the history
  • Loading branch information
joyet-simon committed Oct 21, 2024
1 parent 4b9ab73 commit 8ed5363
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 2 additions & 4 deletions src/Lib/PayloadFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ class PayloadFormatter
/**
* @param CmsInfo $cmsInfo
* @param CmsFeatures $cmsFeatures
* @return string
* @return array
*/
public function formatConfigurationPayload(CmsInfo $cmsInfo, CmsFeatures $cmsFeatures)
{
$payload = [
return [
"cms_info" => $cmsInfo->getProperties(),
"cms_features" => $cmsFeatures->getProperties(),
];

return json_encode($payload);
}

}
12 changes: 6 additions & 6 deletions tests/Unit/Lib/PayloadFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public function testFormatIntegrationConfigurationPayload()
$result = $this->payloadFormatter->formatConfigurationPayload($cmsInfo, $cmsFeatures);

// Expected result in JSON format
$expectedPayload = json_encode([
$expectedPayload = [
'cms_info' => $cmsInfo->getProperties(),
'cms_features' => $cmsFeatures->getProperties(),
]);
];

// Assertion: Check if the output matches the expected JSON payload
$this->assertJsonStringEqualsJsonString($expectedPayload, $result);
$this->assertEquals($expectedPayload, $result);
}

public function testFormatIntegrationConfigurationPayloadWithEmptyValues()
Expand Down Expand Up @@ -101,12 +101,12 @@ public function testFormatIntegrationConfigurationPayloadWithEmptyValues()
$result = $this->payloadFormatter->formatConfigurationPayload($cmsInfo, $cmsFeatures);

// Expected result in JSON format (should not include keys with null or empty values)
$expectedPayload = json_encode([
$expectedPayload = [
'cms_info' => $cmsInfo->getProperties(),
'cms_features' => $cmsFeatures->getProperties(),
]);
];

// Assertion: Check if the output matches the expected JSON payload
$this->assertJsonStringEqualsJsonString($expectedPayload, $result);
$this->assertEquals($expectedPayload, $result);
}
}

0 comments on commit 8ed5363

Please sign in to comment.