Skip to content

Commit

Permalink
Merge pull request #5715 from magento-tsg-csl3/2.4.1-develop-pr25
Browse files Browse the repository at this point in the history
[TSG-CSL3] For 2.4.1 (pr25)
  • Loading branch information
viktym authored May 22, 2020
2 parents d5e419c + a11f111 commit 697d4b7
Show file tree
Hide file tree
Showing 62 changed files with 2,780 additions and 482 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Show extends Action implements HttpGetActionInterface
/**
* @inheritdoc
*/
const ADMIN_RESOURCE = 'Magento_Analytics::analytics_settings';
const ADMIN_RESOURCE = 'Magento_Analytics::advanced_reporting';

/**
* @param Context $context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Magento\Quote\Model\Quote;

/**
* Class ShippingMethodUpdater
* Class for updating shipping method in the quote.
*/
class ShippingMethodUpdater extends AbstractHelper
{
Expand Down Expand Up @@ -58,6 +58,12 @@ public function execute($shippingMethod, Quote $quote)
$this->disabledQuoteAddressValidation($quote);

$shippingAddress->setShippingMethod($shippingMethod);
$quoteExtensionAttributes = $quote->getExtensionAttributes();
if ($quoteExtensionAttributes && $quoteExtensionAttributes->getShippingAssignments()) {
$quoteExtensionAttributes->getShippingAssignments()[0]
->getShipping()
->setMethod($shippingMethod);
}
$shippingAddress->setCollectShippingRates(true);

$quote->collectTotals();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use PHPUnit\Framework\TestCase;

/**
* @see \Magento\Braintree\Model\Paypal\Helper\ShippingMethodUpdater
* Test shipping method updater
*/
class ShippingMethodUpdaterTest extends TestCase
{
Expand All @@ -39,11 +39,19 @@ class ShippingMethodUpdaterTest extends TestCase
*/
private $shippingAddressMock;

/**
* @var Address|MockObject
*/
private $billingAddressMock;

/**
* @var ShippingMethodUpdater
*/
private $shippingMethodUpdater;

/**
* @inheritdoc
*/
protected function setUp(): void
{
$this->configMock = $this->getMockBuilder(Config::class)
Expand All @@ -69,16 +77,24 @@ protected function setUp(): void
);
}

public function testExecuteException()
/**
* Test execute exception
*
* @return void
*/
public function testExecuteException(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The "shippingMethod" field does not exists.');
$this->expectExceptionMessage("The \"shippingMethod\" field does not exists.");
$quoteMock = $this->getQuoteMock();

$this->shippingMethodUpdater->execute('', $quoteMock);
}

public function testExecute()
/**
* Test execute
*/
public function testExecute(): void
{
$quoteMock = $this->getQuoteMock();

Expand Down Expand Up @@ -114,9 +130,13 @@ public function testExecute()
}

/**
* Disable quote address validation
*
* @param MockObject $quoteMock
*
* @return void
*/
private function disabledQuoteAddressValidationStep(MockObject $quoteMock)
private function disabledQuoteAddressValidationStep(MockObject $quoteMock): void
{
$billingAddressMock = $this->getBillingAddressMock($quoteMock);

Expand All @@ -139,35 +159,42 @@ private function disabledQuoteAddressValidationStep(MockObject $quoteMock)
}

/**
* Get billing address mock object
*
* @param MockObject $quoteMock
* @return Address|MockObject
*/
private function getBillingAddressMock(MockObject $quoteMock)
private function getBillingAddressMock(MockObject $quoteMock): MockObject
{
$billingAddressMock = $this->getMockBuilder(Address::class)
->setMethods(['setShouldIgnoreValidation', 'getEmail', 'setSameAsBilling'])
->disableOriginalConstructor()
->getMock();
if (!isset($this->billingAddressMock)) {
$this->billingAddressMock = $this->getMockBuilder(Address::class)
->setMethods(['setShouldIgnoreValidation', 'getEmail', 'setSameAsBilling'])
->disableOriginalConstructor()
->getMock();
}

$quoteMock->expects(self::any())
->method('getBillingAddress')
->willReturn($billingAddressMock);
->willReturn($this->billingAddressMock);

return $billingAddressMock;
return $this->billingAddressMock;
}

/**
* Get quote mock object
*
* @return Quote|MockObject
*/
private function getQuoteMock()
private function getQuoteMock(): MockObject
{
return $this->getMockBuilder(Quote::class)
->setMethods(
[
'collectTotals',
'getBillingAddress',
'getShippingAddress',
'getIsVirtual'
'getIsVirtual',
'getExtensionAttributes'
]
)->disableOriginalConstructor()
->getMock();
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Braintree/view/adminhtml/web/js/braintree.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ define([
}

if (!self.validateCardType()) {
$('body').trigger('processStop');
self.error($t('Some payment input fields are invalid.'));

return false;
}

Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Braintree/view/adminhtml/web/js/vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ define([
this.createPublicHashSelector();

this.$selector.find('[name="payment[public_hash]"]').val(this.publicHash);
this.$container.find('#' + this.getNonceSelectorName()).val(nonce);
$('#' + this.getNonceSelectorName()).val(nonce);
},

/**
Expand All @@ -140,7 +140,7 @@ define([
createPublicHashSelector: function () {
var $input;

if (this.$container.find('#' + this.getNonceSelectorName()).size() === 0) {
if ($('#' + this.getNonceSelectorName()).length === 0) {
$input = $('<input>').attr(
{
type: 'hidden',
Expand All @@ -149,7 +149,7 @@ define([
}
);

$input.appendTo(this.$container);
$input.appendTo($('#edit_form'));
$input.prop('disabled', false);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(
* @param string $value
* @param int $length
* @param string $etc
* @param string &$remainder
* @param string $remainder
* @param bool $breakWords
* @return string
*/
Expand Down Expand Up @@ -83,6 +83,7 @@ public function getChildren($item)
}

if ($items) {
$itemsArray[$item->getOrderItem()->getId()][$item->getOrderItemId()] = $item;
foreach ($items as $value) {
$parentItem = $value->getOrderItem()->getParentItem();
if ($parentItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* Test Renderer order item
*/
class RendererTest extends TestCase
{
/** @var Item|MockObject */
Expand Down Expand Up @@ -98,25 +101,27 @@ public function testGetChildren($parentItem)
$parentItem = $this->createPartialMock(Item::class, ['getId', '__wakeup']);
$parentItem->expects($this->any())->method('getId')->willReturn(1);
}
$this->orderItem->expects($this->any())->method('getOrderItem')->willReturnSelf();
$this->orderItem->expects($this->any())->method('getParentItem')->willReturn($parentItem);
$this->orderItem->expects($this->any())->method('getOrderItemId')->willReturn(2);
$this->orderItem->expects($this->any())->method('getId')->willReturn(1);
$this->orderItem->method('getOrderItem')->willReturnSelf();
$this->orderItem->method('getParentItem')->willReturn($parentItem);
$this->orderItem->method('getOrderItemId')->willReturn(2);
$this->orderItem->method('getId')->willReturn(1);

$salesModel = $this->createPartialMock(
Invoice::class,
['getAllItems', '__wakeup']
);
$salesModel->expects($this->once())->method('getAllItems')->willReturn([$this->orderItem]);
$salesModel->method('getAllItems')->willReturn([$this->orderItem]);

$item = $this->createPartialMock(
\Magento\Sales\Model\Order\Invoice\Item::class,
['getInvoice', 'getOrderItem', '__wakeup']
['getInvoice', 'getOrderItem', 'getOrderItemId', '__wakeup']
);
$item->expects($this->once())->method('getInvoice')->willReturn($salesModel);
$item->expects($this->any())->method('getOrderItem')->willReturn($this->orderItem);
$item->method('getInvoice')->willReturn($salesModel);
$item->method('getOrderItem')->willReturn($this->orderItem);
$item->method('getOrderItemId')->willReturn($this->orderItem->getOrderItemId());

$this->assertSame([2 => $this->orderItem], $this->model->getChildren($item));
$orderItem = $this->model->getChildren($item);
$this->assertSame([2 => $this->orderItem], $orderItem);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$defaultMinSaleQty = $block->getDefaultConfigValue('min_sale_qty');
if (!is_numeric($defaultMinSaleQty)) {
$defaultMinSaleQty = json_decode($defaultMinSaleQty, true);
$defaultMinSaleQty = (float) $defaultMinSaleQty[\Magento\Customer\Api\Data\GroupInterface::CUST_GROUP_ALL] ?? 1;
$defaultMinSaleQty = (float) ($defaultMinSaleQty[\Magento\Customer\Api\Data\GroupInterface::CUST_GROUP_ALL] ?? 1);
}
?>
<div class="fieldset-wrapper form-inline advanced-inventory-edit">
Expand All @@ -52,17 +52,19 @@ if (!is_numeric($defaultMinSaleQty)) {
<div class="control">
<div class="fields-group-2">
<div class="field">
<select id="inventory_manage_stock" name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[manage_stock]"
<select id="inventory_manage_stock"
name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[manage_stock]"
class="select" disabled="disabled">
<option value="1"><?= $block->escapeHtml(__('Yes')) ?></option>
<option value="0"
<?php if ($block->getFieldValue('manage_stock') == 0) :?>
<?php if ($block->getFieldValue('manage_stock') == 0):?>
selected="selected"
<?php endif; ?>><?= $block->escapeHtml(__('No')) ?></option>
</select>
</div>
<div class="field choice">
<input name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[use_config_manage_stock]" type="checkbox"
<input name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[use_config_manage_stock]"
type="checkbox"
id="inventory_use_config_manage_stock" data-role="toggle-editability" value="1"
checked="checked" disabled="disabled"/>
<label for="inventory_use_config_manage_stock"
Expand Down Expand Up @@ -211,13 +213,15 @@ if (!is_numeric($defaultMinSaleQty)) {
disabled="disabled">
<option value="0"><?= $block->escapeHtml(__('No')) ?></option>
<option value="1"
<?php if ($block->getDefaultConfigValue('is_qty_decimal') == 1) :?>
<?php if ($block->getDefaultConfigValue('is_qty_decimal') == 1):?>
selected="selected"
<?php endif; ?>><?= $block->escapeHtml(__('Yes')) ?></option>
</select>
</div>
<div class="field choice">
<input type="checkbox" id="inventory_is_qty_decimal_checkbox" data-role="toggle-editability-all"/>
<input type="checkbox"
id="inventory_is_qty_decimal_checkbox"
data-role="toggle-editability-all"/>
<label for="inventory_is_qty_decimal_checkbox"
class="label"><span><?= $block->escapeHtml(__('Change')) ?></span></label>
</div>
Expand All @@ -238,10 +242,12 @@ if (!is_numeric($defaultMinSaleQty)) {
name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[backorders]"
class="select"
disabled="disabled">
<?php foreach ($block->getBackordersOption() as $option) :?>
<?php $_selected = ($option['value'] == $block->getDefaultConfigValue('backorders')) ? ' selected="selected"' : '' ?>
<option
value="<?= $block->escapeHtmlAttr($option['value']) ?>"<?= /* @noEscape */ $_selected ?>><?= $block->escapeHtml($option['label']) ?></option>
<?php foreach ($block->getBackordersOption() as $option):?>
<?php $_selected = ($option['value'] == $block->getDefaultConfigValue('backorders'))
? ' selected="selected"' : '' ?>
<option value="<?= $block->escapeHtmlAttr($option['value']) ?>"
<?= /* @noEscape */ $_selected ?>><?= $block->escapeHtml($option['label']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
Expand Down Expand Up @@ -291,7 +297,9 @@ if (!is_numeric($defaultMinSaleQty)) {
class="label"><span><?= $block->escapeHtml(__('Use Config Settings')) ?></span></label>
</div>
<div class="field choice">
<input type="checkbox" id="inventory_notify_stock_qty_checkbox" data-role="toggle-editability-all"/>
<input type="checkbox"
id="inventory_notify_stock_qty_checkbox"
data-role="toggle-editability-all"/>
<label for="inventory_notify_stock_qty_checkbox"
class="label"><span><?= $block->escapeHtml(__('Change')) ?></span></label>
</div>
Expand All @@ -314,7 +322,7 @@ if (!is_numeric($defaultMinSaleQty)) {
disabled="disabled">
<option value="1"><?= $block->escapeHtml(__('Yes')) ?></option>
<option value="0"
<?php if ($block->getDefaultConfigValue('enable_qty_increments') == 0) :?>
<?php if ($block->getDefaultConfigValue('enable_qty_increments') == 0):?>
selected="selected"
<?php endif; ?>><?= $block->escapeHtml(__('No')) ?></option>
</select>
Expand All @@ -330,7 +338,9 @@ if (!is_numeric($defaultMinSaleQty)) {
class="label"><span><?= $block->escapeHtml(__('Use Config Settings')) ?></span></label>
</div>
<div class="field choice">
<input type="checkbox" id="inventory_enable_qty_increments_checkbox" data-role="toggle-editability-all"/>
<input type="checkbox"
id="inventory_enable_qty_increments_checkbox"
data-role="toggle-editability-all"/>
<label for="inventory_enable_qty_increments_checkbox"
class="label"><span><?= $block->escapeHtml(__('Change')) ?></span></label>
</div>
Expand Down Expand Up @@ -364,7 +374,9 @@ if (!is_numeric($defaultMinSaleQty)) {
class="label"><span><?= $block->escapeHtml(__('Use Config Settings')) ?></span></label>
</div>
<div class="field choice">
<input type="checkbox" id="inventory_qty_increments_checkbox" data-role="toggle-editability-all"/>
<input type="checkbox"
id="inventory_qty_increments_checkbox"
data-role="toggle-editability-all"/>
<label for="inventory_qty_increments_checkbox"
class="label"><span><?= $block->escapeHtml(__('Change')) ?></span></label>
</div>
Expand All @@ -385,11 +397,15 @@ if (!is_numeric($defaultMinSaleQty)) {
name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[is_in_stock]" class="select"
disabled="disabled">
<option value="1"><?= $block->escapeHtml(__('In Stock')) ?></option>
<option value="0"<?php if ($block->getDefaultConfigValue('is_in_stock') == 0) :?> selected<?php endif; ?>><?= $block->escapeHtml(__('Out of Stock')) ?></option>
<option value="0"<?php if ($block->getDefaultConfigValue('is_in_stock') == 0):?>
selected<?php endif; ?>><?= $block->escapeHtml(__('Out of Stock')) ?>
</option>
</select>
</div>
<div class="field choice">
<input type="checkbox" id="inventory_stock_availability_checkbox" data-role="toggle-editability-all"/>
<input type="checkbox"
id="inventory_stock_availability_checkbox"
data-role="toggle-editability-all"/>
<label for="inventory_stock_availability_checkbox"
class="label"><span><?= $block->escapeHtml(__('Change')) ?></span></label>
</div>
Expand Down
Loading

0 comments on commit 697d4b7

Please sign in to comment.