-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #371 from mollie/1.24.0
1.24.0
- Loading branch information
Showing
19 changed files
with
246 additions
and
43 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
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,38 @@ | ||
name: Lint PHP files | ||
on: push | ||
|
||
jobs: | ||
php-70: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: StephaneBour/actions-php-lint@7.0 | ||
with: | ||
dir: './' | ||
|
||
php-71: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: StephaneBour/actions-php-lint@7.1 | ||
with: | ||
dir: './' | ||
|
||
php-72: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: StephaneBour/actions-php-lint@7.2 | ||
with: | ||
dir: './' | ||
|
||
php-73: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: StephaneBour/actions-php-lint@7.3 | ||
with: | ||
dir: './' | ||
|
||
php-74: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: StephaneBour/actions-php-lint@7.4 | ||
with: | ||
dir: './' |
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
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
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
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
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
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,35 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\Service\Mollie; | ||
|
||
use Magento\Quote\Api\Data\CartInterface; | ||
use Mollie\Payment\Service\Mollie\Parameters\ParameterPartInterface; | ||
|
||
class MethodParameters | ||
{ | ||
/** | ||
* @var ParameterPartInterface[] | ||
*/ | ||
private $parametersParts; | ||
|
||
/** | ||
* @param ParameterPartInterface[] $parametersParts | ||
*/ | ||
public function __construct(array $parametersParts) | ||
{ | ||
$this->parametersParts = $parametersParts; | ||
} | ||
|
||
public function enhance(array $parameters, CartInterface $cart): array | ||
{ | ||
foreach ($this->parametersParts as $parametersPart) { | ||
$parameters = $parametersPart->enhance($parameters, $cart); | ||
} | ||
|
||
return $parameters; | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\Service\Mollie\Parameters; | ||
|
||
use Magento\Quote\Api\Data\CartInterface; | ||
|
||
interface ParameterPartInterface | ||
{ | ||
/** | ||
* @param array $parameters | ||
* @param CartInterface|null $cart | ||
* @return array | ||
*/ | ||
public function enhance(array $parameters, CartInterface $cart): array; | ||
} |
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
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
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
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
79 changes: 79 additions & 0 deletions
79
Test/Integration/Service/Mollie/MethodParameterPartTest.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,79 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Mollie\Payment\Service\Mollie; | ||
|
||
use Magento\Quote\Api\Data\CartInterface; | ||
use Mollie\Payment\Service\Mollie\Parameters\ParameterPartInterface; | ||
use Mollie\Payment\Test\Integration\IntegrationTestCase; | ||
|
||
class MethodParametersTest extends IntegrationTestCase | ||
{ | ||
const DEFAULT_INPUT = [ | ||
'amount[value]' => 10, | ||
'amount[currency]' => 'EUR', | ||
'resource' => 'orders', | ||
'includeWallets' => 'applepay', | ||
]; | ||
|
||
public function testChangesNothingWhenNoPartsAreConfigured() | ||
{ | ||
/** @var MethodParameters $instance */ | ||
$instance = $this->objectManager->create(MethodParameters::class, ['parametersParts' => []]); | ||
|
||
$result = $instance->enhance(static::DEFAULT_INPUT, $this->objectManager->create(CartInterface::class)); | ||
|
||
$this->assertEquals(static::DEFAULT_INPUT, $result); | ||
} | ||
|
||
public function testTheParametersCanBeAdjusted() | ||
{ | ||
$part = new class() implements ParameterPartInterface { | ||
public function enhance(array $parameters, CartInterface $cart): array | ||
{ | ||
return $parameters + ['test' => true]; | ||
} | ||
}; | ||
|
||
/** @var MethodParameters $instance */ | ||
$instance = $this->objectManager->create(MethodParameters::class, ['parametersParts' => [ | ||
'testPart' => $part, | ||
]]); | ||
|
||
$result = $instance->enhance(static::DEFAULT_INPUT, $this->objectManager->create(CartInterface::class)); | ||
|
||
$this->assertEquals(static::DEFAULT_INPUT + ['test' => true], $result); | ||
} | ||
|
||
public function testSupportsMultipleParameterParts() | ||
{ | ||
$part1 = new class() implements ParameterPartInterface { | ||
public function enhance(array $parameters, CartInterface $cart): array | ||
{ | ||
return $parameters + ['test1' => true]; | ||
} | ||
}; | ||
|
||
$part2 = new class() implements ParameterPartInterface { | ||
public function enhance(array $parameters, CartInterface $cart): array | ||
{ | ||
return $parameters + ['test2' => true]; | ||
} | ||
}; | ||
|
||
/** @var MethodParameters $instance */ | ||
$instance = $this->objectManager->create(MethodParameters::class, [ | ||
'parametersParts' => [ | ||
'test1' => $part1, | ||
'test2' => $part2, | ||
] | ||
]); | ||
|
||
$result = $instance->enhance(static::DEFAULT_INPUT, $this->objectManager->create(CartInterface::class)); | ||
|
||
$this->assertEquals(static::DEFAULT_INPUT + ['test1' => true, 'test2' => true], $result); | ||
} | ||
} |
Oops, something went wrong.