Skip to content

Commit

Permalink
Merge pull request #98 from magento-mpi/MAGETWO-54214
Browse files Browse the repository at this point in the history
[MPI] Bug Fixes
  • Loading branch information
kandy authored Jun 11, 2016
2 parents c201d36 + 6ccada9 commit 6a38dd7
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 6 deletions.
41 changes: 35 additions & 6 deletions app/code/Magento/Paypal/Model/Payflowpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
use Magento\Framework\DataObject;
use Magento\Framework\Exception\LocalizedException;
use Magento\Payment\Model\InfoInterface;
use Magento\Payment\Model\Method\ConfigInterface;
use Magento\Payment\Model\Method\ConfigInterfaceFactory;
use Magento\Payment\Model\Method\Online\GatewayInterface;
use Magento\Payment\Observer\AbstractDataAssignObserver;
use Magento\Paypal\Model\Config;
use Magento\Paypal\Model\Payflow\Service\Gateway;
use Magento\Paypal\Model\Payflow\Service\Response\Handler\HandlerInterface;
use Magento\Paypal\Model\Payflow\Transparent;
use Magento\Quote\Model\Quote;
use Magento\Sales\Model\Order\Payment;
use Magento\Payment\Model\Method\Online\GatewayInterface;
use Magento\Payment\Model\Method\ConfigInterface;
use Magento\Paypal\Model\Config;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Payment;
use Magento\Store\Model\ScopeInterface;
use Magento\Vault\Api\Data\PaymentTokenInterface;

/**
* Payflow Pro payment gateway model
Expand Down Expand Up @@ -861,6 +860,36 @@ public function addRequestOrderInfo(DataObject $request, Order $order)
->setComment1($orderIncrementId);
}

/**
* Assign data to info model instance
*
* @param array|DataObject $data
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function assignData(DataObject $data)
{
$this->_eventManager->dispatch(
'payment_method_assign_data_' . $this->getCode(),
[
AbstractDataAssignObserver::METHOD_CODE => $this,
AbstractDataAssignObserver::MODEL_CODE => $this->getInfoInstance(),
AbstractDataAssignObserver::DATA_CODE => $data
]
);

$this->_eventManager->dispatch(
'payment_method_assign_data',
[
AbstractDataAssignObserver::METHOD_CODE => $this,
AbstractDataAssignObserver::MODEL_CODE => $this->getInfoInstance(),
AbstractDataAssignObserver::DATA_CODE => $data
]
);

return $this;
}

/**
* @param InfoInterface $payment
* @param string $transactionId
Expand Down
32 changes: 32 additions & 0 deletions app/code/Magento/Paypal/Test/Unit/Model/PayflowproTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

use Magento\Framework\DataObject;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Event\ManagerInterface;
use Magento\Payment\Model\Method\ConfigInterface;
use Magento\Paypal\Model\Config;
use Magento\Paypal\Model\Payflowpro;
use Magento\Store\Model\ScopeInterface;
use Magento\Payment\Model\InfoInterface;

/**
* Class PayflowproTest
Expand Down Expand Up @@ -54,6 +56,11 @@ class PayflowproTest extends \PHPUnit_Framework_TestCase
*/
protected $scopeConfigMock;

/**
* @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $eventManager;

protected function setUp()
{
$configFactoryMock = $this->getMock(
Expand Down Expand Up @@ -114,10 +121,13 @@ protected function setUp()
$clientFactory = $this->getMock('Magento\Framework\HTTP\ZendClientFactory', ['create'], [], '', false);
$clientFactory->expects($this->any())->method('create')->will($this->returnValue($client));

$this->eventManager = $this->getMockForAbstractClass(ManagerInterface::class);

$this->helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->payflowpro = $this->helper->getObject(
'Magento\Paypal\Model\Payflowpro',
[
'eventDispatcher' => $this->eventManager,
'configFactory' => $configFactoryMock,
'httpClientFactory' => $clientFactory,
'storeManager' => $this->storeManagerMock,
Expand Down Expand Up @@ -498,4 +508,26 @@ public function testPostRequestException()

$this->payflowpro->postRequest($request, $config);
}

/**
* @covers \Magento\Paypal\Model\Payflowpro::assignData
*/
public function testAssignData()
{
$data = [
'cc_type' => 'VI',
'cc_last_4' => 1111,
'cc_exp_month' => 12,
'cc_exp_year' => 2023
];
$dataObject = new DataObject($data);

$infoInstance = $this->getMockForAbstractClass(InfoInterface::class);
$this->payflowpro->setData('info_instance', $infoInstance);

$this->eventManager->expects(static::exactly(2))
->method('dispatch');

$this->payflowpro->assignData($dataObject);
}
}

0 comments on commit 6a38dd7

Please sign in to comment.