-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.2-develop' into 2.2-develop-PR-port-16537
- Loading branch information
Showing
114 changed files
with
943 additions
and
210 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
89 changes: 89 additions & 0 deletions
89
app/code/Magento/Braintree/Test/Unit/Gateway/Http/Client/TransactionRefundTest.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,89 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Braintree\Test\Unit\Gateway\Http\Client; | ||
|
||
use Braintree\Result\Successful; | ||
use Magento\Braintree\Gateway\Http\Client\TransactionRefund; | ||
use Magento\Braintree\Model\Adapter\BraintreeAdapter; | ||
use Magento\Braintree\Model\Adapter\BraintreeAdapterFactory; | ||
use Magento\Payment\Gateway\Http\ClientException; | ||
use Magento\Payment\Gateway\Http\ConverterException; | ||
use Magento\Payment\Gateway\Http\TransferInterface; | ||
use Magento\Braintree\Gateway\Request\PaymentDataBuilder; | ||
use Magento\Payment\Model\Method\Logger; | ||
use PHPUnit_Framework_MockObject_MockObject as MockObject; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* Class TransactionRefundTest | ||
*/ | ||
class TransactionRefundTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var TransactionRefund | ||
*/ | ||
private $transactionRefundModel; | ||
|
||
/** | ||
* @var BraintreeAdapter|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $adapterMock; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp() | ||
{ | ||
/** @var LoggerInterface|MockObject $criticalLoggerMock */ | ||
$criticalLoggerMock = $this->getMockForAbstractClass(LoggerInterface::class); | ||
/** @var Logger|\PHPUnit_Framework_MockObject_MockObject $loggerMock */ | ||
$loggerMock = $this->getMockBuilder(Logger::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->adapterMock = $this->getMockBuilder(BraintreeAdapter::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
/** @var BraintreeAdapterFactory|MockObject $adapterFactoryMock */ | ||
$adapterFactoryMock = $this->getMockBuilder(BraintreeAdapterFactory::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$adapterFactoryMock->method('create') | ||
->willReturn($this->adapterMock); | ||
|
||
$this->transactionRefundModel = new TransactionRefund($criticalLoggerMock, $loggerMock, $adapterFactoryMock); | ||
} | ||
|
||
/** | ||
* @throws ClientException | ||
* @throws ConverterException | ||
*/ | ||
public function testRefundRequestWithStoreId() | ||
{ | ||
$transactionId = '11223344'; | ||
$refundAmount = 10; | ||
$data = [ | ||
'store_id' => 0, | ||
'transaction_id' => $transactionId, | ||
PaymentDataBuilder::AMOUNT => $refundAmount | ||
]; | ||
$successfulResponse = new Successful(); | ||
|
||
/** @var TransferInterface|\PHPUnit_Framework_MockObject_MockObject $transferObjectMock */ | ||
$transferObjectMock = $this->createMock(TransferInterface::class); | ||
$transferObjectMock->method('getBody') | ||
->willReturn($data); | ||
$this->adapterMock->expects($this->once()) | ||
->method('refund') | ||
->with($transactionId, $refundAmount) | ||
->willReturn($successfulResponse); | ||
|
||
$response = $this->transactionRefundModel->placeRequest($transferObjectMock); | ||
|
||
self::assertEquals($successfulResponse, $response['object']); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
app/code/Magento/Braintree/Test/Unit/Gateway/Http/Client/TransactionVoidTest.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,86 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Braintree\Test\Unit\Gateway\Http\Client; | ||
|
||
use Braintree\Result\Successful; | ||
use Magento\Braintree\Gateway\Http\Client\TransactionVoid; | ||
use Magento\Braintree\Model\Adapter\BraintreeAdapter; | ||
use Magento\Braintree\Model\Adapter\BraintreeAdapterFactory; | ||
use Magento\Payment\Gateway\Http\ClientException; | ||
use Magento\Payment\Gateway\Http\ConverterException; | ||
use Magento\Payment\Gateway\Http\TransferInterface; | ||
use Magento\Payment\Model\Method\Logger; | ||
use PHPUnit_Framework_MockObject_MockObject as MockObject; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* Class TransactionVoidTest | ||
*/ | ||
class TransactionVoidTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var TransactionVoid | ||
*/ | ||
private $transactionVoidModel; | ||
|
||
/** | ||
* @var BraintreeAdapter|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $adapterMock; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp() | ||
{ | ||
/** @var LoggerInterface|MockObject $criticalLoggerMock */ | ||
$criticalLoggerMock = $this->getMockForAbstractClass(LoggerInterface::class); | ||
/** @var Logger|\PHPUnit_Framework_MockObject_MockObject $loggerMock */ | ||
$loggerMock = $this->getMockBuilder(Logger::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->adapterMock = $this->getMockBuilder(BraintreeAdapter::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
/** @var BraintreeAdapterFactory|MockObject $adapterFactoryMock */ | ||
$adapterFactoryMock = $this->getMockBuilder(BraintreeAdapterFactory::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$adapterFactoryMock->method('create') | ||
->willReturn($this->adapterMock); | ||
|
||
$this->transactionVoidModel = new TransactionVoid($criticalLoggerMock, $loggerMock, $adapterFactoryMock); | ||
} | ||
|
||
/** | ||
* @throws ClientException | ||
* @throws ConverterException | ||
*/ | ||
public function testVoidRequestWithStoreId() | ||
{ | ||
$transactionId = '11223344'; | ||
$data = [ | ||
'store_id' => 0, | ||
'transaction_id' => $transactionId | ||
]; | ||
$successfulResponse = new Successful(); | ||
|
||
/** @var TransferInterface|\PHPUnit_Framework_MockObject_MockObject $transferObjectMock */ | ||
$transferObjectMock = $this->createMock(TransferInterface::class); | ||
$transferObjectMock->method('getBody') | ||
->willReturn($data); | ||
$this->adapterMock->expects($this->once()) | ||
->method('void') | ||
->with($transactionId) | ||
->willReturn($successfulResponse); | ||
|
||
$response = $this->transactionVoidModel->placeRequest($transferObjectMock); | ||
|
||
self::assertEquals($successfulResponse, $response['object']); | ||
} | ||
} |
Oops, something went wrong.