-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor #320 [RefundPayment] Make the Refund customization easier (G…
…Sadee) This PR was merged into the 1.0-dev branch. Discussion ---------- Commits ------- 7cc7471 [RefundPayment] Refactor factory to make it easier to overwrite 6cda314 Fix FailedRefundPaymentFactory after refactoring 36f0c60 [RefundPayment] CS fixes 60001b0 Refactor RefundUnitsCommandCreator by extracting converter c2ea3bc [Behat] Try to fix the problem with randomly failing scenario by using sleep 7c40e8c [RefundPayment] Add additional note to UPGRADE file about changing factory 51c4cb9 [RefundPayment] Minor fixes after PR review
- Loading branch information
Showing
20 changed files
with
338 additions
and
149 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
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,71 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\Sylius\RefundPlugin\Converter; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Sylius\RefundPlugin\Calculator\UnitRefundTotalCalculatorInterface; | ||
use Sylius\RefundPlugin\Converter\RefundUnitsConverterInterface; | ||
use Sylius\RefundPlugin\Model\OrderItemUnitRefund; | ||
use Sylius\RefundPlugin\Model\RefundType; | ||
|
||
final class RefundUnitsConverterSpec extends ObjectBehavior | ||
{ | ||
public function let(UnitRefundTotalCalculatorInterface $unitRefundTotalCalculator): void | ||
{ | ||
$this->beConstructedWith($unitRefundTotalCalculator); | ||
} | ||
|
||
public function it_implements_refund_units_converter_interface(): void | ||
{ | ||
$this->shouldImplement(RefundUnitsConverterInterface::class); | ||
} | ||
|
||
public function it_converts_refund_units_from_request_with_full_prices_to_models( | ||
UnitRefundTotalCalculatorInterface $unitRefundTotalCalculator | ||
): void { | ||
$unitRefundTotalCalculator->calculateForUnitWithIdAndType(1, RefundType::orderItemUnit(), null)->willReturn(1000); | ||
$unitRefundTotalCalculator->calculateForUnitWithIdAndType(2, RefundType::orderItemUnit(), null)->willReturn(3000); | ||
|
||
$this | ||
->convert( | ||
[ | ||
1 => ['full' => 'on'], | ||
2 => ['full' => 'on'], | ||
], | ||
RefundType::orderItemUnit(), | ||
OrderItemUnitRefund::class | ||
) | ||
->shouldBeLike([new OrderItemUnitRefund(1, 1000), new OrderItemUnitRefund(2, 3000)]) | ||
; | ||
} | ||
|
||
public function it_converts_refund_units_from_request_with_partial_prices_to_models( | ||
UnitRefundTotalCalculatorInterface $unitRefundTotalCalculator | ||
): void { | ||
$unitRefundTotalCalculator->calculateForUnitWithIdAndType(1, RefundType::orderItemUnit(), 10.00)->willReturn(1000); | ||
$unitRefundTotalCalculator->calculateForUnitWithIdAndType(2, RefundType::orderItemUnit(), null)->willReturn(3000); | ||
|
||
$this | ||
->convert( | ||
[ | ||
1 => ['amount' => '10.00'], | ||
2 => ['full' => 'on'], | ||
], | ||
RefundType::orderItemUnit(), | ||
OrderItemUnitRefund::class | ||
) | ||
->shouldBeLike([new OrderItemUnitRefund(1, 1000), new OrderItemUnitRefund(2, 3000)]) | ||
; | ||
} | ||
} |
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
Oops, something went wrong.