Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.3-develop' into 2.3-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nirav-kadiya committed Dec 11, 2018
2 parents e9db3ff + f77f96b commit 776ac6c
Show file tree
Hide file tree
Showing 43 changed files with 210 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
var config = {
map: {
'*': {
transparent: 'Magento_Payment/js/transparent'
transparent: 'Magento_Payment/js/transparent',
'Magento_Payment/transparent': 'Magento_Payment/js/transparent'
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ $permissions = $block->getData('permissions');
?>
<?php if ($permissions && $permissions->hasAccessToAdditionalActions()): ?>
<div class="additional-cache-management">
<h2>
<span><?= $block->escapeHtml(__('Additional Cache Management')); ?></span>
</h2>
<?php if ($permissions->hasAccessToFlushCatalogImages()): ?>
<h2>
<span><?= $block->escapeHtml(__('Additional Cache Management')); ?></span>
</h2>
<p>
<button onclick="setLocation('<?= $block->escapeJs($block->getCleanImagesUrl()); ?>')" type="button">
<?= $block->escapeHtml(__('Flush Catalog Images Cache')); ?>
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Captcha/view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
var config = {
map: {
'*': {
captcha: 'Magento_Captcha/js/captcha'
captcha: 'Magento_Captcha/js/captcha',
'Magento_Captcha/captcha': 'Magento_Captcha/js/captcha'
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

use Magento\Framework\Exception\InputException;

/**
* Option management model for product attribute.
*/
class OptionManagement implements \Magento\Catalog\Api\ProductAttributeOptionManagementInterface
{
/**
Expand All @@ -25,7 +28,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getItems($attributeCode)
{
Expand All @@ -36,7 +39,7 @@ public function getItems($attributeCode)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function add($attributeCode, $option)
{
Expand All @@ -47,7 +50,7 @@ public function add($attributeCode, $option)
/** @var \Magento\Eav\Api\Data\AttributeOptionInterface $attributeOption */
$attributeOption = $attributeOption->getLabel();
});
if (in_array($option->getLabel(), $currentOptions)) {
if (in_array($option->getLabel(), $currentOptions, true)) {
return false;
}
}
Expand All @@ -59,7 +62,7 @@ public function add($attributeCode, $option)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function delete($attributeCode, $optionId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,

if (!isset($jobConfig['instance'], $jobConfig['method'])) {
$schedule->setStatus(Schedule::STATUS_ERROR);
throw new \Exception('No callbacks found');
throw new \Exception(sprintf('No callbacks found for cron job %s', $jobCode));
}
$model = $this->_objectManager->create($jobConfig['instance']);
$callback = [$model, $jobConfig['method']];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ public function testDispatchExceptionTooLate()
*/
public function testDispatchExceptionNoCallback()
{
$exceptionMessage = 'No callbacks found';
$jobName = 'test_job1';
$exceptionMessage = 'No callbacks found for cron job ' . $jobName;
$exception = new \Exception(__($exceptionMessage));

$dateScheduledAt = date('Y-m-d H:i:s', $this->time - 86400);
Expand Down Expand Up @@ -383,7 +384,7 @@ public function testDispatchExceptionNoCallback()

$this->loggerMock->expects($this->once())->method('critical')->with($exception);

$jobConfig = ['test_group' => ['test_job1' => ['instance' => 'Some_Class']]];
$jobConfig = ['test_group' => [$jobName => ['instance' => 'Some_Class']]];

$this->_config->expects($this->exactly(2))->method('getJobs')->will($this->returnValue($jobConfig));

Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Customer/view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ var config = {
changeEmailPassword: 'Magento_Customer/js/change-email-password',
passwordStrengthIndicator: 'Magento_Customer/js/password-strength-indicator',
zxcvbn: 'Magento_Customer/js/zxcvbn',
addressValidation: 'Magento_Customer/js/addressValidation'
addressValidation: 'Magento_Customer/js/addressValidation',
'Magento_Customer/address': 'Magento_Customer/js/address',
'Magento_Customer/change-email-password': 'Magento_Customer/js/change-email-password'
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
<div class="control">
<select id="region_id" name="region_id"
title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?>"
class="validate-select" <?= /* @noEscape */ !$block->getConfig('general/region/display_all') ? ' disabled="disabled"' : '' ?>>
class="validate-select region_id" <?= /* @noEscape */ !$block->getConfig('general/region/display_all') ? ' disabled="disabled"' : '' ?>>
<option value=""><?= $block->escapeHtml(__('Please select a region, state or province.')) ?></option>
</select>
<input type="text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<div class="field region required">
<label for="region_id" class="label"><span><?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?></span></label>
<div class="control">
<select id="region_id" name="region_id" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?>" class="validate-select" style="display:none;">
<select id="region_id" name="region_id" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?>" class="validate-select region_id" style="display:none;">
<option value=""><?= $block->escapeHtml(__('Please select a region, state or province.')) ?></option>
</select>
<input type="text" id="region" name="region" value="<?= $block->escapeHtml($block->getRegion()) ?>" title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('region') ?>" class="input-text <?= $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('region')) ?>" style="display:none;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
var config = {
map: {
'*': {
downloadable: 'Magento_Downloadable/js/downloadable'
downloadable: 'Magento_Downloadable/js/downloadable',
'Magento_Downloadable/downloadable': 'Magento_Downloadable/js/downloadable'
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ var config = {
map: {
'*': {
giftOptions: 'Magento_GiftMessage/js/gift-options',
extraOptions: 'Magento_GiftMessage/js/extra-options'
extraOptions: 'Magento_GiftMessage/js/extra-options',
'Magento_GiftMessage/gift-options': 'Magento_GiftMessage/js/gift-options',
'Magento_GiftMessage/extra-options': 'Magento_GiftMessage/js/extra-options'
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ public function __construct(
protected function validateEmailAvailable($email)
{
$websiteId = $this->_storeManager->getStore()->getWebsiteId();
if ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email
&& !$this->customerAccountManagement->isEmailAvailable($email, $websiteId)
if ($this->_customerSession->isLoggedIn()
&& ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email
&& !$this->customerAccountManagement->isEmailAvailable($email, $websiteId))
) {
throw new LocalizedException(
__('This email address is already assigned to another user.')
Expand Down
10 changes: 10 additions & 0 deletions app/code/Magento/Payment/Observer/SalesOrderBeforeSaveObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,29 @@

use Magento\Framework\Event\ObserverInterface;

/**
* Verify order payment observer
*/
class SalesOrderBeforeSaveObserver implements ObserverInterface
{
/**
* Set forced canCreditmemo flag
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException in case order has no payment specified.
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
/** @var \Magento\Sales\Model\Order $order */
$order = $observer->getEvent()->getOrder();

if (!$order->getPayment()) {
throw new \Magento\Framework\Exception\LocalizedException(
__('Please provide payment for the order.')
);
}

if ($order->getPayment()->getMethodInstance()->getCode() != 'free') {
return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testSalesOrderBeforeSaveCantUnhold()
$paymentMock = $this->getMockBuilder(
\Magento\Sales\Model\Order\Payment::class
)->disableOriginalConstructor()->setMethods([])->getMock();
$order->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock));
$order->method('getPayment')->will($this->returnValue($paymentMock));
$methodInstance = $this->getMockBuilder(
\Magento\Payment\Model\MethodInterface::class
)->getMockForAbstractClass();
Expand All @@ -86,7 +86,7 @@ public function testSalesOrderBeforeSaveIsCanceled()
$paymentMock = $this->getMockBuilder(
\Magento\Sales\Model\Order\Payment::class
)->disableOriginalConstructor()->setMethods([])->getMock();
$order->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock));
$order->method('getPayment')->will($this->returnValue($paymentMock));
$methodInstance = $this->getMockBuilder(
\Magento\Payment\Model\MethodInterface::class
)->getMockForAbstractClass();
Expand Down Expand Up @@ -114,7 +114,7 @@ public function testSalesOrderBeforeSaveIsClosed()
$paymentMock = $this->getMockBuilder(
\Magento\Sales\Model\Order\Payment::class
)->disableOriginalConstructor()->setMethods([])->getMock();
$order->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock));
$order->method('getPayment')->will($this->returnValue($paymentMock));
$methodInstance = $this->getMockBuilder(
\Magento\Payment\Model\MethodInterface::class
)->getMockForAbstractClass();
Expand Down Expand Up @@ -156,6 +156,29 @@ public function testSalesOrderBeforeSaveSetForced()
$this->salesOrderBeforeSaveObserver->execute($this->observerMock);
}

/**
* The method should check that the payment is available, as this is not always the case.
*
* @expectedException \Magento\Framework\Exception\LocalizedException
* @exceptedExceptionMessage Please provide payment for the order.
*/
public function testDoesNothingWhenNoPaymentIsAvailable()
{
$this->_prepareEventMockWithMethods(['getOrder']);

$order = $this->getMockBuilder(\Magento\Sales\Model\Order::class)->disableOriginalConstructor()->setMethods(
array_merge(['__wakeup', 'getPayment'])
)->getMock();

$this->eventMock->expects($this->once())->method('getOrder')->will(
$this->returnValue($order)
);

$order->expects($this->exactly(1))->method('getPayment')->willReturn(null);

$this->salesOrderBeforeSaveObserver->execute($this->observerMock);
}

/**
* Prepares EventMock with set of methods
*
Expand Down Expand Up @@ -184,7 +207,7 @@ private function _getPreparedOrderMethod($methodCode, $orderMethods = [])
$paymentMock = $this->getMockBuilder(
\Magento\Sales\Model\Order\Payment::class
)->disableOriginalConstructor()->setMethods([])->getMock();
$order->expects($this->once())->method('getPayment')->will($this->returnValue($paymentMock));
$order->method('getPayment')->will($this->returnValue($paymentMock));
$methodInstance = $this->getMockBuilder(
\Magento\Payment\Model\MethodInterface::class
)->getMockForAbstractClass();
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Payment/view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
var config = {
map: {
'*': {
creditCardType: 'Magento_Payment/js/cc-type'
creditCardType: 'Magento_Payment/js/cc-type',
'Magento_Payment/cc-type': 'Magento_Payment/js/cc-type'
}
}
};
15 changes: 14 additions & 1 deletion app/code/Magento/Paypal/Model/Payflowpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount)
$request->setTrxtype(self::TRXTYPE_SALE);
$request->setOrigid($payment->getAdditionalInformation(self::PNREF));
$payment->unsAdditionalInformation(self::PNREF);
$request->setData('currency', $payment->getOrder()->getBaseCurrencyCode());
} elseif ($payment->getParentTransactionId()) {
$request = $this->buildBasicRequest();
$request->setOrigid($payment->getParentTransactionId());
Expand Down Expand Up @@ -472,6 +473,7 @@ public function void(\Magento\Payment\Model\InfoInterface $payment)

/**
* Check void availability
*
* @return bool
* @throws \Magento\Framework\Exception\LocalizedException
*/
Expand Down Expand Up @@ -584,7 +586,7 @@ public function getConfig()
}

/**
* {inheritdoc}
* @inheritdoc
*/
public function postRequest(DataObject $request, ConfigInterface $config)
{
Expand Down Expand Up @@ -719,6 +721,8 @@ public function reviewPayment(InfoInterface $payment, $action)
}

/**
* Set billing address
*
* @param DataObject $request
* @param DataObject $billing
*
Expand All @@ -745,6 +749,8 @@ public function setBilling(DataObject $request, $billing)
}

/**
* Set shipping address
*
* @param DataObject $request
* @param DataObject $shipping
*
Expand Down Expand Up @@ -815,6 +821,8 @@ public function mapGatewayResponse(array $postData, DataObject $response)
}

/**
* Set transaction status
*
* @param DataObject $payment
* @param DataObject $response
*
Expand Down Expand Up @@ -848,6 +856,8 @@ public function setTransStatus($payment, $response)
}

/**
* Fill customer contacts
*
* @param DataObject $order
* @param DataObject $request
* @return DataObject
Expand All @@ -869,6 +879,7 @@ public function fillCustomerContacts(DataObject $order, DataObject $request)

/**
* Add order details to payment request
*
* @param DataObject $request
* @param Order $order
* @return void
Expand Down Expand Up @@ -917,6 +928,8 @@ public function assignData(DataObject $data)
}

/**
* Make a transaction Inquiry Request
*
* @param InfoInterface $payment
* @param string $transactionId
* @return DataObject
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/Paypal/Plugin/OrderCanInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public function __construct(Express $express)
*/
public function afterCanInvoice(Order $order, bool $result): bool
{
if (!$order->getPayment()) {
return false;
}

if ($this->express->isOrderAuthorizationAllowed($order->getPayment())) {
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Paypal/view/base/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
var config = {
map: {
'*': {
transparent: 'Magento_Payment/js/transparent'
transparent: 'Magento_Payment/js/transparent',
'Magento_Payment/transparent': 'Magento_Payment/js/transparent'
}
}
};
1 change: 1 addition & 0 deletions app/code/Magento/Paypal/view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var config = {
map: {
'*': {
orderReview: 'Magento_Paypal/js/order-review',
'Magento_Paypal/order-review': 'Magento_Paypal/js/order-review',
paypalCheckout: 'Magento_Paypal/js/paypal-checkout'
}
},
Expand Down
Loading

0 comments on commit 776ac6c

Please sign in to comment.