Skip to content

Commit

Permalink
Merge pull request #558 from magento-firedrakes/bugfixes49
Browse files Browse the repository at this point in the history
[Firedrakes] Sprint 49 bugfixes
  • Loading branch information
sivaschenko committed Aug 31, 2015
2 parents 79895c4 + 774b342 commit 84c18e3
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public function testPrepareItemsByPageId()
'href' => 'test/url/delete',
'label' => __('Delete'),
'confirm' => [
'title' => __('Delete "${ $.$data.title }"'),
'message' => __('Are you sure you wan\'t to delete a "${ $.$data.title }" record?')
'title' => __('Delete ${ $.$data.title }'),
'message' => __('Are you sure you wan\'t to delete a ${ $.$data.title } record?')
],
]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public function prepareDataSource(array & $dataSource)
'href' => $this->urlBuilder->getUrl(self::CMS_URL_PATH_DELETE, ['page_id' => $item['page_id']]),
'label' => __('Delete'),
'confirm' => [
'title' => __('Delete "${ $.$data.title }"'),
'message' => __('Are you sure you wan\'t to delete a "${ $.$data.title }" record?')
'title' => __('Delete ${ $.$data.title }'),
'message' => __('Are you sure you wan\'t to delete a ${ $.$data.title } record?')
]
];
}
Expand Down
10 changes: 6 additions & 4 deletions app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ protected function _construct()
['label' => __('Back'), 'onclick' => "setLocation('{$backUrl}')", 'class' => 'back']
);

if ($this->_authorization->isAllowed(
'Magento_Sales::transactions_fetch'
) && $this->orderPaymentRepository->get($this->_txn->getId())->getMethodInstance()->canFetchTransactionInfo()
) {
$fetchTransactionAllowed = $this->_authorization->isAllowed('Magento_Sales::transactions_fetch');
$canFetchTransaction = $this->orderPaymentRepository->get($this->_txn->getPaymentId())
->getMethodInstance()
->canFetchTransactionInfo();

if ($fetchTransactionAllowed && $canFetchTransaction) {
$fetchUrl = $this->getUrl('sales/*/fetch', ['_current' => true]);
$this->buttonList->add(
'fetch',
Expand Down
15 changes: 15 additions & 0 deletions app/code/Magento/Sales/Model/Order/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Magento\Sales\Model\Order;

use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Model\Order\Payment\Info;
use Magento\Sales\Api\Data\OrderPaymentInterface;
use Magento\Sales\Model\Order;
Expand Down Expand Up @@ -97,6 +98,11 @@ class Payment extends Info implements OrderPaymentInterface
*/
protected $orderPaymentProcessor;

/**
* @var OrderRepositoryInterface
*/
protected $orderRepository;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
Expand All @@ -109,6 +115,8 @@ class Payment extends Info implements OrderPaymentInterface
* @param \Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository
* @param \Magento\Sales\Model\Order\Payment\Transaction\ManagerInterface $transactionManager
* @param Transaction\BuilderInterface $transactionBuilder
* @param Payment\Processor $paymentProcessor
* @param OrderRepositoryInterface $orderRepository
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
Expand All @@ -127,6 +135,7 @@ public function __construct(
ManagerInterface $transactionManager,
\Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface $transactionBuilder,
\Magento\Sales\Model\Order\Payment\Processor $paymentProcessor,
OrderRepositoryInterface $orderRepository,
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
Expand All @@ -137,6 +146,7 @@ public function __construct(
$this->transactionManager = $transactionManager;
$this->transactionBuilder = $transactionBuilder;
$this->orderPaymentProcessor = $paymentProcessor;
$this->orderRepository = $orderRepository;
parent::__construct(
$context,
$registry,
Expand Down Expand Up @@ -178,11 +188,16 @@ public function setOrder(Order $order)
* Retrieve order model object
*
* @codeCoverageIgnore
* @deprecated
*
* @return Order
*/
public function getOrder()
{
if (!$this->_order && $this->getParentId()) {
$this->_order = $this->orderRepository->get($this->getParentId());
}

return $this->_order;
}

Expand Down
54 changes: 38 additions & 16 deletions app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
class PaymentTest extends \PHPUnit_Framework_TestCase
{
private $mockContext;
/**
* @var Payment
*/
Expand Down Expand Up @@ -91,9 +92,13 @@ class PaymentTest extends \PHPUnit_Framework_TestCase
/**
* @var \Magento\Sales\Model\Order\Payment\Processor|\PHPUnit_Framework_MockObject_MockObject
*/

protected $paymentProcessor;

/**
* @var \Magento\Sales\Model\OrderRepository|\PHPUnit_Framework_MockObject_MockObject
*/
protected $orderRepository;

/**
* @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
Expand All @@ -105,11 +110,11 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();

$context = $this->getMockBuilder('Magento\Framework\Model\Context')
$this->mockContext = $this->getMockBuilder('Magento\Framework\Model\Context')
->disableOriginalConstructor()
->getMock();

$context->expects($this->once())
$this->mockContext->expects($this->atLeastOnce())
->method('getEventDispatcher')
->will($this->returnValue($this->eventManagerMock));

Expand All @@ -132,6 +137,7 @@ protected function setUp()
->setMethods(['get', 'getByTransactionType', 'getByTransactionId'])
->getMock();
$this->paymentProcessor = $this->getMock('Magento\Sales\Model\Order\Payment\Processor', [], [], '', false);
$this->orderRepository = $this->getMock('Magento\Sales\Model\OrderRepository', ['get'], [], '', false);

$this->priceCurrencyMock->expects($this->any())
->method('format')
Expand Down Expand Up @@ -259,7 +265,10 @@ function ($value) {
false
);

$this->initPayment($context);
$this->payment = $this->initPayment();
$this->payment->setMethod('any');
$this->payment->setOrder($this->orderMock);
$this->transactionId = 100;
}

protected function tearDown()
Expand Down Expand Up @@ -1212,6 +1221,26 @@ public function testPay()
$this->assertEquals($expects['base_shipping_captured'], $this->payment->getData('base_shipping_captured'));
}

public function testGetOrder()
{
$payment = $this->initPayment();
$this->orderRepository->expects($this->once())->method('get')->willReturn($this->orderMock);
$payment->setParentId(1211);
$this->assertSame($this->orderMock, $payment->getOrder());
}

public function testGetOrderDefault()
{
$this->orderRepository->expects($this->never())->method('get');
$this->assertSame($this->orderMock, $this->payment->getOrder());
}

public function testGetOrderNull()
{
$payment = $this->initPayment();
$this->orderRepository->expects($this->never())->method('get');
$this->assertNull($payment->getOrder());
}

public function testCancelInvoice()
{
Expand Down Expand Up @@ -1408,29 +1437,22 @@ public function boolProvider()
];
}

/**
* @param $context
*/
protected function initPayment($context)
protected function initPayment()
{
$this->payment = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject(
return (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject(
'Magento\Sales\Model\Order\Payment',
[
'context' => $context,
'context' => $this->mockContext,
'creditmemoFactory' => $this->creditmemoFactoryMock,
'paymentData' => $this->helperMock,
'priceCurrency' => $this->priceCurrencyMock,
'transactionRepository' => $this->transactionRepositoryMock,
'transactionManager' => $this->transactionManagerMock,
'transactionBuilder' => $this->transactionBuilderMock,
'paymentProcessor' => $this->paymentProcessor
'paymentProcessor' => $this->paymentProcessor,
'orderRepository' => $this->orderRepository
]
);

$this->payment->setMethod('any');
$this->payment->setOrder($this->orderMock);

$this->transactionId = 100;
}

protected function assertOrderUpdated(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<h3 class="subtitle"><?php echo $block->getTitle() ?></h3>
<dl class="order comments">
<?php foreach ($block->getComments() as $_commentItem): ?>
<dt class="comment date"><?php echo $block->formatDate($_commentItem->getCreatedAtStoreDate(), \IntlDateFormatter::MEDIUM, true) ?></dt>
<dt class="comment date"><?php echo $block->formatDate($_commentItem->getCreatedAt(), \IntlDateFormatter::MEDIUM, true) ?></dt>
<dd class="comment text"><?php echo $block->escapeHtml($_commentItem->getComment()) ?></dd>
<?php endforeach; ?>
</dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<?php foreach ($_orders as $_order): ?>
<tr>
<td data-th="<?php echo $block->escapeHtml(__('Order #')) ?>" class="col id"><?php echo $_order->getRealOrderId() ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Date')) ?>" class="col date"><?php echo $block->formatDate($_order->getCreatedAtStoreDate()) ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Date')) ?>" class="col date"><?php echo $block->formatDate($_order->getCreatedAt()) ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Ship To')) ?>" class="col shipping"><?php echo $_order->getShippingAddress() ? $block->escapeHtml($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Order Total')) ?>" class="col total"><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Status')) ?>" class="col status"><?php echo $_order->getStatusLabel() ?></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="block-content">
<dl class="order-comments">
<?php foreach ($_history as $_historyItem): ?>
<dt class="comment-date"><?php echo $block->formatDate($_historyItem->getCreatedAtStoreDate(), \IntlDateFormatter::MEDIUM, true) ?></dt>
<dt class="comment-date"><?php echo $block->formatDate($_historyItem->getCreatedAt(), \IntlDateFormatter::MEDIUM, true) ?></dt>
<dd class="comment-content"><?php echo $block->escapeHtml($_historyItem->getComment()) ?></dd>
<?php endforeach; ?>
</dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

?>

<div class="order-date"><?php echo __('<span class="label">Order Date:</span> %1', '<date>' . $block->formatDate($block->getOrder()->getCreatedAtStoreDate(), \IntlDateFormatter::LONG) . '</date>') ?></div>
<div class="order-date"><?php echo __('<span class="label">Order Date:</span> %1', '<date>' . $block->formatDate($block->getOrder()->getCreatedAt(), \IntlDateFormatter::LONG) . '</date>') ?></div>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<?php foreach ($_orders as $_order): ?>
<tr>
<td data-th="<?php echo $block->escapeHtml(__('Order #')) ?>" class="col id"><?php echo $_order->getRealOrderId() ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Date')) ?>" class="col date"><?php echo $block->formatDate($_order->getCreatedAtStoreDate()) ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Date')) ?>" class="col date"><?php echo $block->formatDate($_order->getCreatedAt()) ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Ship To')) ?>" class="col shipping"><?php echo $_order->getShippingAddress() ? $block->escapeHtml($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Order Total')) ?>" class="col total"><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
<td data-th="<?php echo $block->escapeHtml(__('Status')) ?>" class="col status"><?php echo $_order->getStatusLabel() ?></td>
Expand Down
12 changes: 12 additions & 0 deletions app/code/Magento/SalesRule/etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,16 @@
<type name="Magento\SalesRule\Model\Rule">
<plugin name="catalog_rule_model_Rule_after_loader" type="Magento\SalesRule\Model\Plugin\Rule"/>
</type>
<type name="Magento\SalesRule\Helper\Coupon">
<arguments>
<argument name="couponParameters" xsi:type="array">
<item name="separator" xsi:type="string">-</item>
<item name="charset" xsi:type="array">
<item name="alphanum" xsi:type="string">ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</item>
<item name="alpha" xsi:type="string">ABCDEFGHIJKLMNOPQRSTUVWXYZ</item>
<item name="num" xsi:type="string">0123456789</item>
</item>
</argument>
</arguments>
</type>
</config>
2 changes: 1 addition & 1 deletion app/code/Magento/Ui/view/base/web/js/grid/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define([
*/
onError: function () {
alert({
content: $t('Something go wrong')
content: $t('Something goes wrong')
});
},

Expand Down

0 comments on commit 84c18e3

Please sign in to comment.