-
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 pull request #94 from magento-mpi/MPI-BUGFIXES
[MPI] Bugfixes
- Loading branch information
Showing
16 changed files
with
293 additions
and
29 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
app/code/Magento/Braintree/Gateway/Request/ChannelDataBuilder.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,50 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Braintree\Gateway\Request; | ||
|
||
use Magento\Payment\Gateway\Request\BuilderInterface; | ||
use Magento\Framework\App\ProductMetadataInterface; | ||
|
||
/** | ||
* Class BnCodeDataBuilder | ||
*/ | ||
class ChannelDataBuilder implements BuilderInterface | ||
{ | ||
/** | ||
* @var ProductMetadataInterface | ||
*/ | ||
private $productMetadata; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $channel = 'channel'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static $channelValue = 'Magento2_Cart_%s_BT'; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param ProductMetadataInterface $productMetadata | ||
*/ | ||
public function __construct(ProductMetadataInterface $productMetadata) | ||
{ | ||
$this->productMetadata = $productMetadata; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function build(array $buildSubject) | ||
{ | ||
return [ | ||
self::$channel => sprintf(self::$channelValue, $this->productMetadata->getEdition()) | ||
]; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
app/code/Magento/Braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.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,61 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Braintree\Test\Unit\Gateway\Request; | ||
|
||
use Magento\Braintree\Gateway\Request\ChannelDataBuilder; | ||
use Magento\Framework\App\ProductMetadataInterface; | ||
|
||
/** | ||
* Class PaymentDataBuilderTest | ||
* | ||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) | ||
*/ | ||
class ChannelDataBuilderTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var ProductMetadataInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $productMetadataMock; | ||
|
||
/** | ||
* @var ChannelDataBuilder | ||
*/ | ||
private $builder; | ||
|
||
protected function setUp() | ||
{ | ||
$this->productMetadataMock = $this->getMock(ProductMetadataInterface::class); | ||
$this->builder = new ChannelDataBuilder($this->productMetadataMock); | ||
} | ||
|
||
/** | ||
* @param string $edition | ||
* @param array $expected | ||
* @covers \Magento\Braintree\Gateway\Request\ChannelDataBuilder::build | ||
* @dataProvider buildDataProvider | ||
*/ | ||
public function testBuild($edition, array $expected) | ||
{ | ||
$buildSubject = []; | ||
$this->productMetadataMock->expects(static::once()) | ||
->method('getEdition') | ||
->willReturn($edition); | ||
|
||
$this->assertEquals($expected, $this->builder->build($buildSubject)); | ||
} | ||
|
||
/** | ||
* Get list of variations for build test | ||
* @return array | ||
*/ | ||
public function buildDataProvider() | ||
{ | ||
return [ | ||
['FirstEdition', ['channel' => 'Magento2_Cart_FirstEdition_BT']], | ||
['SecondEdition', ['channel' => 'Magento2_Cart_SecondEdition_BT']], | ||
]; | ||
} | ||
} |
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
73 changes: 73 additions & 0 deletions
73
app/code/Magento/Payment/Test/Unit/Model/Method/CcTest.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,73 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Payment\Test\Unit\Model\Method; | ||
|
||
use Magento\Framework\DataObject; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use Magento\Payment\Model\Method\Cc; | ||
use Magento\Quote\Api\Data\PaymentInterface; | ||
use Magento\Quote\Model\Quote\Payment; | ||
|
||
class CcTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Cc | ||
*/ | ||
private $ccModel; | ||
|
||
public function setUp() | ||
{ | ||
$objectManager = new ObjectManager($this); | ||
$this->ccModel = $objectManager->getObject(Cc::class); | ||
} | ||
|
||
public function testAssignData() | ||
{ | ||
$additionalData = [ | ||
'cc_type' => 'VI', | ||
'cc_owner' => 'Bruce', | ||
'cc_number' => '41111111111111', | ||
'cc_cid' => '42', | ||
'cc_exp_month' => '02', | ||
'cc_exp_year' => '30', | ||
'cc_ss_issue' => '9', | ||
'cc_ss_start_month' => '01', | ||
'cc_ss_start_year' => '30' | ||
]; | ||
|
||
$inputData = new DataObject( | ||
[ | ||
PaymentInterface::KEY_ADDITIONAL_DATA => $additionalData | ||
] | ||
); | ||
|
||
$payment = $this->getMockBuilder(Payment::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$expectedData = [ | ||
'cc_type' => 'VI', | ||
'cc_owner' => 'Bruce', | ||
'cc_last_4' => '1111', | ||
'cc_number' => '41111111111111', | ||
'cc_cid' => '42', | ||
'cc_exp_month' => '02', | ||
'cc_exp_year' => '30', | ||
'cc_ss_issue' => '9', | ||
'cc_ss_start_month' => '01', | ||
'cc_ss_start_year' => '30' | ||
]; | ||
|
||
$payment->expects(static::once()) | ||
->method('addData') | ||
->with( | ||
$expectedData | ||
); | ||
|
||
$this->ccModel->setInfoInstance($payment); | ||
$this->ccModel->assignData($inputData); | ||
} | ||
} |
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.