Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/develop' into S55-Bug-Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiych committed Aug 14, 2015
2 parents 9408602 + 1d40050 commit e9063ea
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ define([
var $checkbox = $(event.currentTarget);
var $imageContainer = $checkbox.closest('[data-role=dialog]').data('imageContainer');
$imageContainer.toggleClass('hidden-for-front', $checkbox.is(':checked'));
$imageContainer.find('[name*="disabled"]').val($checkbox.is(':checked') ? 1 : 0);
},

/**
Expand Down
9 changes: 6 additions & 3 deletions app/code/Magento/CatalogImportExport/Model/Export/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -928,13 +928,14 @@ protected function collectMultirawData()
array_keys($this->_websiteIdToCode),
$item->getWebsites()
);
$rowCategories[$item->getId()] = $item->getCategoryIds();
$rowCategories[$item->getId()] = array_combine($item->getCategoryIds(), $item->getCategoryIds());
}
$collection->clear();

$allCategoriesIds = array_merge(array_keys($this->_categories), array_keys($this->_rootCategories));
$allCategoriesIds = array_combine($allCategoriesIds, $allCategoriesIds);
foreach ($rowCategories as &$categories) {
$categories = array_intersect($categories, $allCategoriesIds);
$categories = array_intersect_key($categories, $allCategoriesIds);
}

$data['rowWebsites'] = $rowWebsites;
Expand Down Expand Up @@ -1218,14 +1219,16 @@ protected function getCustomOptionsData($productIds)
public function filterAttributeCollection(\Magento\Eav\Model\Resource\Entity\Attribute\Collection $collection)
{
$validTypes = array_keys($this->_productTypeModels);
$validTypes = array_combine($validTypes, $validTypes);

foreach (parent::filterAttributeCollection($collection) as $attribute) {
if (in_array($attribute->getAttributeCode(), $this->_bannedAttributes)) {
$collection->removeItemByKey($attribute->getId());
continue;
}
$attrApplyTo = $attribute->getApplyTo();
$attrApplyTo = $attrApplyTo ? array_intersect($attrApplyTo, $validTypes) : $validTypes;
$attrApplyTo = array_combine($attrApplyTo, $attrApplyTo);
$attrApplyTo = $attrApplyTo ? array_intersect_key($attrApplyTo, $validTypes) : $validTypes;

if ($attrApplyTo) {
foreach ($attrApplyTo as $productType) {
Expand Down
4 changes: 1 addition & 3 deletions app/code/Magento/Customer/Model/Customer/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ public function getData()
$addresses[$addressId] = $address->getData();
$this->prepareAddressData($addressId, $addresses, $result['customer']);
}
if (!empty($addresses)) {
$result['address'] = $addresses;
}
$result['address'] = $addresses;

$this->loadedData[$customer->getId()] = $result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Template for filter items block
*
* @var $block \Magento\LayeredNavigation\Block\Layer\Filter\Renderer
* @var $block \Magento\LayeredNavigation\Block\Navigation\FilterRenderer
*/
?>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ public function capture(OrderPaymentInterface $payment, $invoice)
//TODO replace for sale usage
$method->capture($payment, $amountToCapture);

$transaction = $this->transactionBuilder->setPayment($this)
->setOrder($order)
->setFailSafe(true)
->setTransactionId($payment->getTransactionId())
->setAdditionalInformation($payment->getTransactionAdditionalInfo())
->setSalesDocument($invoice)->build(Transaction::TYPE_CAPTURE);
$transactionBuilder = $this->transactionBuilder->setPayment($payment);
$transactionBuilder->setOrder($order);
$transactionBuilder->setFailSafe(true);
$transactionBuilder->setTransactionId($payment->getTransactionId());
$transactionBuilder->setAdditionalInformation($payment->getTransactionAdditionalInfo());
$transactionBuilder->setSalesDocument($invoice);
$transaction = $transactionBuilder->build(Transaction::TYPE_CAPTURE);

$message = $this->stateCommand->execute($payment, $amountToCapture, $order);
if ($payment->getIsTransactionPending()) {
$invoice->setIsPaid(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ public function build($type)
$transaction = $this->transactionRepository->create()->setTxnId($this->transactionId);
}
$transaction->setPaymentId($this->payment->getId())
->setPayment($this->payment)
->setOrderId($this->order->getId())
->setOrder($this->order)
->setTxnType($type)
->isFailsafe($this->failSafe);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Sales\Test\Unit\Model\Order\Payment\Operations;

use Magento\Framework\ObjectManager\ObjectManager;
use Magento\Payment\Model\Method;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;

class CaptureOperationTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $transactionManager;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $eventManager;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $transactionBuilder;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $stateCommand;

/**
* @var \Magento\Sales\Model\Order\Payment\Operations\CaptureOperation
*/
protected $model;

protected function setUp()
{
$transactionClass = 'Magento\Sales\Model\Order\Payment\Transaction\ManagerInterface';
$transactionBuilderClass = 'Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface';
$this->transactionManager = $this->getMockBuilder($transactionClass)
->disableOriginalConstructor()
->getMock();
$this->eventManager = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface')
->disableOriginalConstructor()
->getMock();
$this->transactionBuilder = $this->getMockBuilder($transactionBuilderClass)
->disableOriginalConstructor()
->getMock();
$this->stateCommand = $this->getMockBuilder('Magento\Sales\Model\Order\Payment\State\CommandInterface')
->disableOriginalConstructor()
->getMock();
$objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $objectManagerHelper->getObject(
'Magento\Sales\Model\Order\Payment\Operations\CaptureOperation',
[
'transactionManager' => $this->transactionManager,
'eventManager' => $this->eventManager,
'transactionBuilder' => $this->transactionBuilder,
'stateCommand' => $this->stateCommand
]
);
}

public function testCapture()
{
$baseGrandTotal = 10;

$order = $this->getMockBuilder('Magento\Sales\Model\Order')
->disableOriginalConstructor()
->getMock();

$paymentMethod = $this->getMockBuilder('Magento\Payment\Model\MethodInterface')
->disableOriginalConstructor()
->getMock();

$orderPayment = $this->getMockBuilder('Magento\Sales\Model\Order\Payment')
->disableOriginalConstructor()
->getMock();
$orderPayment->expects($this->any())
->method('formatAmount')
->with($baseGrandTotal)
->willReturnArgument(0);
$orderPayment->expects($this->any())
->method('getOrder')
->willReturn($order);
$orderPayment->expects($this->any())
->method('getMethodInstance')
->willReturn($paymentMethod);
$orderPayment->expects($this->once())
->method('getIsTransactionPending')
->willReturn(true);
$orderPayment->expects($this->once())
->method('getTransactionAdditionalInfo')
->willReturn([]);

$paymentMethod->expects($this->once())
->method('capture')
->with($orderPayment, $baseGrandTotal);

$this->transactionBuilder->expects($this->once())
->method('setPayment')
->with($orderPayment)
->willReturnSelf();

$invoice = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice')
->disableOriginalConstructor()
->getMock();
$invoice->expects($this->any())
->method('getBaseGrandTotal')
->willReturn($baseGrandTotal);

$this->model->capture($orderPayment, $invoice);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ public function testCreate(
$parentTransaction = $this->expectTransaction($orderId, $paymentId);
$transaction = $this->expectTransaction($orderId, $paymentId);
$transaction->expects($this->atLeastOnce())->method('getTxnId')->willReturn($transactionId);
$transaction->expects($this->once())
->method('setPayment')
->withAnyParameters()
->willReturnSelf();
$transaction->expects($this->once())
->method('setOrder')
->withAnyParameters()
->willReturnSelf();

if ($isTransactionExists) {
$this->repositoryMock->method('getByTransactionId')
Expand Down Expand Up @@ -210,7 +218,9 @@ protected function expectTransaction($orderId, $paymentId)
'setAdditionalInformation',
'setParentTxnId',
'close',
'getIsClosed'
'getIsClosed',
'setPayment',
'setOrder'
],
[],
'',
Expand Down

0 comments on commit e9063ea

Please sign in to comment.