-
Notifications
You must be signed in to change notification settings - Fork 211
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 #2429 from Adyen/develop
Release 9.0.6
- Loading branch information
Showing
16 changed files
with
367 additions
and
37 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
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
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
123 changes: 123 additions & 0 deletions
123
Test/Unit/Gateway/Request/ShopperInteractionDataBuilderTest.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,123 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment module (https://www.adyen.com/) | ||
* | ||
* Copyright (c) 2024 Adyen N.V. (https://www.adyen.com/) | ||
* See LICENSE.txt for license details. | ||
* | ||
* Author: Adyen <magento@adyen.com> | ||
*/ | ||
|
||
namespace Adyen\Payment\Test\Gateway\Request; | ||
|
||
use Adyen\Payment\Gateway\Request\ShopperInteractionDataBuilder; | ||
use Adyen\Payment\Helper\StateData; | ||
use Adyen\Payment\Model\Method\Adapter; | ||
use Adyen\Payment\Model\Ui\Adminhtml\AdyenMotoConfigProvider; | ||
use Adyen\Payment\Model\Ui\AdyenCcConfigProvider; | ||
use Adyen\Payment\Model\Ui\AdyenPayByLinkConfigProvider; | ||
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase; | ||
use Magento\Framework\App\Area; | ||
use Magento\Framework\App\State; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use Magento\Payment\Gateway\Data\PaymentDataObject; | ||
use Magento\Sales\Model\Order; | ||
use Magento\Sales\Model\Order\Payment; | ||
|
||
class ShopperInteractionDataBuilderTest extends AbstractAdyenTestCase | ||
{ | ||
private $shopperInteractionDataBuilder; | ||
private $appState; | ||
private $stateData; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->objectManager = new ObjectManager($this); | ||
|
||
$this->appState = $this->createMock(State::class); | ||
$this->stateData = $this->createPartialMock(StateData::class, [ | ||
'getStateData' | ||
]); | ||
|
||
$this->shopperInteractionDataBuilder = $this->objectManager->getObject( | ||
ShopperInteractionDataBuilder::class, [ | ||
'appState' => $this->appState, | ||
'stateData' => $this->stateData | ||
] | ||
); | ||
} | ||
|
||
public function testPayByLinkRequest() | ||
{ | ||
$buildSubject = [ | ||
'payment' => $this->createConfiguredMock(PaymentDataObject::class, [ | ||
'getPayment' => $this->createConfiguredMock(Payment::class, [ | ||
'getMethodInstance' => $this->createConfiguredMock(Adapter::class, [ | ||
'getCode' => AdyenPayByLinkConfigProvider::CODE | ||
]) | ||
]) | ||
]) | ||
]; | ||
|
||
$this->assertEmpty($this->shopperInteractionDataBuilder->build($buildSubject)); | ||
} | ||
|
||
public function testMotoRequest() | ||
{ | ||
$buildSubject = [ | ||
'payment' => $this->createConfiguredMock(PaymentDataObject::class, [ | ||
'getPayment' => $this->createConfiguredMock(Payment::class, [ | ||
'getMethodInstance' => $this->createConfiguredMock(Adapter::class, [ | ||
'getCode' => AdyenMotoConfigProvider::CODE | ||
]), | ||
'getOrder' => $this->createConfiguredMock(Order::class, [ | ||
'getQuoteId' => 1 | ||
]) | ||
]) | ||
]) | ||
]; | ||
|
||
$this->appState->method('getAreaCode')->willReturn(Area::AREA_ADMINHTML); | ||
$this->stateData->method('getStateData')->willReturn([]); | ||
|
||
$request = $this->shopperInteractionDataBuilder->build($buildSubject); | ||
|
||
$this->assertArrayHasKey('shopperInteraction', $request['body']); | ||
$this->assertEquals( | ||
ShopperInteractionDataBuilder::SHOPPER_INTERACTION_MOTO, | ||
$request['body']['shopperInteraction'] | ||
); | ||
} | ||
|
||
public function testRecurringRequest() | ||
{ | ||
$buildSubject = [ | ||
'payment' => $this->createConfiguredMock(PaymentDataObject::class, [ | ||
'getPayment' => $this->createConfiguredMock(Payment::class, [ | ||
'getMethodInstance' => $this->createConfiguredMock(Adapter::class, [ | ||
'getCode' => AdyenCcConfigProvider::CODE | ||
]), | ||
'getOrder' => $this->createConfiguredMock(Order::class, [ | ||
'getQuoteId' => 1 | ||
]) | ||
]) | ||
]) | ||
]; | ||
|
||
$this->appState->method('getAreaCode')->willReturn(Area::AREA_ADMINHTML); | ||
$this->stateData->method('getStateData')->willReturn([ | ||
'paymentMethod' => [ | ||
'storedPaymentMethodId' => hash('md5', time()) | ||
] | ||
]); | ||
|
||
$request = $this->shopperInteractionDataBuilder->build($buildSubject); | ||
|
||
$this->assertArrayHasKey('shopperInteraction', $request['body']); | ||
$this->assertEquals( | ||
ShopperInteractionDataBuilder::SHOPPER_INTERACTION_CONTAUTH, | ||
$request['body']['shopperInteraction'] | ||
); | ||
} | ||
} |
Oops, something went wrong.