Skip to content

Commit

Permalink
[M2P-587] Flips in_array args to be correct (#1276)
Browse files Browse the repository at this point in the history
* Flips in_array args to be correct

* Fixed typo in CustomFieldsHandler, added new test case

* whitespace
  • Loading branch information
njfaries committed May 10, 2021
1 parent b0b84e8 commit 0101907
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Helper/CustomFieldsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function handle($order, $customFields)
$comment .= '<br>' . $customField['label'] . ': ' . $customField['value'];
}

$needSubscribe = isset($customField['features']) && in_array($customField['features'], self::FEATURE_SUBSCRIBE_TO_PLATFORM_NEWSLETTER);
$needSubscribe = isset($customField['features']) && in_array(self::FEATURE_SUBSCRIBE_TO_PLATFORM_NEWSLETTER, $customField['features']);
}

if ($comment) {
Expand Down
9 changes: 7 additions & 2 deletions Test/Unit/Helper/CustomFieldsHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,20 @@ public function handle($customFields, $comment, $needSubscribe)

public function handleCustomFieldsDataProvider()
{
$customField1 = ['label' => 'Gift', 'type'=>'CHECKBOX', 'is_custom_field' => true, 'value' => false];
$customField1 = ['label' => 'Gift', 'type' => 'CHECKBOX', 'is_custom_field' => true, 'value' => false];
$comment1 = '<br>Gift: No';

$customField2 = ['label' => 'Question', 'type' => 'DROPDOWN', 'is_custom_field' => true, 'value' => 'Answer'];
$comment2 = '<br>Question: Answer';

$customField3 = ['label' => 'Subscription', 'type' => 'CHECKBOX', 'is_custom_field' => true, 'value' => true, 'features' => ['subscribe_to_platform_newsletter']];
$comment3 = '<br>Subscription: Yes';

return [
[[], '', false],
[[$customField1], $comment1, false],
[[$customField2], $comment2, false]
[[$customField2], $comment2, false],
[[$customField3], $comment3, true]
];
}
}

0 comments on commit 0101907

Please sign in to comment.