-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the custom_info object as OrderRequest argument
- Loading branch information
1 parent
16a7cea
commit 6f58b4f
Showing
4 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/Api/Transactions/OrderRequest/Arguments/CustomInfo.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* Copyright © MultiSafepay, Inc. All rights reserved. | ||
* See DISCLAIMER.md for disclaimer details. | ||
*/ | ||
|
||
namespace MultiSafepay\Api\Transactions\OrderRequest\Arguments; | ||
|
||
use MultiSafepay\Exception\InvalidArgumentException; | ||
use MultiSafepay\Util\Version; | ||
|
||
/** | ||
* Class CustomInfo | ||
* @package MultiSafepay\Api\Transactions\OrderRequest\Arguments | ||
* phpcs:disable ObjectCalisthenics.Metrics.MethodPerClassLimit | ||
* phpcs:disable ObjectCalisthenics.Files.ClassTraitAndInterfaceLength | ||
*/ | ||
class CustomInfo | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $custom1; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $custom2; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $custom3; | ||
|
||
|
||
/** | ||
* @param string $custom1 | ||
* @return CustomInfo | ||
*/ | ||
public function addCustom1(string $custom1): CustomInfo | ||
{ | ||
$this->custom1 = $custom1; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getCustom1(): ?string | ||
{ | ||
return $this->custom1; | ||
} | ||
|
||
|
||
/** | ||
* @param string $custom2 | ||
* @return CustomInfo | ||
*/ | ||
public function addCustom2(string $custom2): CustomInfo | ||
{ | ||
$this->custom2 = $custom2; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getCustom2(): ?string | ||
{ | ||
return $this->custom2; | ||
} | ||
|
||
/** | ||
* @param string $custom3 | ||
* @return CustomInfo | ||
*/ | ||
public function addCustom3(string $custom3): CustomInfo | ||
{ | ||
$this->custom3 = $custom3; | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getCustom3(): ?string | ||
{ | ||
return $this->custom3; | ||
} | ||
|
||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getData(): array | ||
{ | ||
return [ | ||
'custom_1' => $this->getCustom1(), | ||
'custom_2' => $this->getCustom2(), | ||
'custom_3' => $this->getCustom3() | ||
]; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
tests/Unit/Api/Transactions/OrderRequest/Arguments/CustomInfoTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php declare(strict_types=1); | ||
namespace MultiSafepay\Tests\Unit\Api\Transactions\OrderRequest\Arguments; | ||
|
||
use MultiSafepay\Api\Transactions\OrderRequest\Arguments\CustomInfo; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class DescriptionTest | ||
* @package MultiSafepay\Tests\Unit\Api\Transactions\OrderRequest\Arguments | ||
*/ | ||
class CustomInfoTest extends TestCase | ||
{ | ||
/** | ||
* Test case to guarantee that Custominfo properties is set properly | ||
*/ | ||
public function testAddCustomInfo() | ||
{ | ||
$customInfo = $this->getCustomInfo(); | ||
$this->assertEquals('Multi', $customInfo->getCustom1()); | ||
$this->assertEquals('Safe', $customInfo->getCustom2()); | ||
$this->assertEquals('pay', $customInfo->getCustom3()); | ||
} | ||
|
||
/** | ||
* Test case to guarantee that Custominfo getData return data array properly | ||
*/ | ||
public function testWorkingCustomInfo() | ||
{ | ||
$customInfo = $this->getCustomInfo(); | ||
$customInfoData = $customInfo->getData(); | ||
$this->assertEquals('Multi', $customInfoData['custom_1']); | ||
$this->assertEquals('Safe', $customInfoData['custom_2']); | ||
$this->assertEquals('pay', $customInfoData['custom_3']); | ||
} | ||
|
||
/** | ||
* @return CustomInfo | ||
*/ | ||
private function getCustomInfo(): CustomInfo | ||
{ | ||
$customInfo = new CustomInfo(); | ||
$customInfo->addCustom1('Multi'); | ||
$customInfo->addCustom2('Safe'); | ||
$customInfo->addCustom3('pay'); | ||
return $customInfo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters