Skip to content

Commit

Permalink
Merge pull request magento#8611 from magento-l3/Tier4-PR-10-30-2023
Browse files Browse the repository at this point in the history
Tier4 PR Delivery 10.30.23
  • Loading branch information
dhorytskyi authored Nov 21, 2023
2 parents edd599b + 2f58bf9 commit 97e33f5
Show file tree
Hide file tree
Showing 24 changed files with 576 additions and 105 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/Bundle/Model/LinkManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ private function processLinkedProduct(
}

$selectionModel = $this->bundleSelection->create();
$selectionModel->load($linkedProduct->getId());
$selectionModel = $this->mapProductLinkToBundleSelectionModel(
$selectionModel,
$linkedProduct,
Expand Down
9 changes: 7 additions & 2 deletions app/code/Magento/Bundle/Model/Selection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Magento\Bundle\Model;

use Magento\Framework\App\ObjectManager;

/**
* Bundle Selection Model
*
Expand Down Expand Up @@ -36,8 +38,6 @@
class Selection extends \Magento\Framework\Model\AbstractModel
{
/**
* Catalog data
*
* @var \Magento\Catalog\Helper\Data
*/
protected $_catalogData;
Expand Down Expand Up @@ -82,7 +82,9 @@ public function beforeSave()
{
if (!$this->_catalogData->isPriceGlobal() && $this->getWebsiteId()) {
$this->setData('tmp_selection_price_value', $this->getSelectionPriceValue());
$this->setData('tmp_selection_price_type', $this->getSelectionPriceType());
$this->setSelectionPriceValue($this->getOrigData('selection_price_value'));
$this->setSelectionPriceType($this->getOrigData('selection_price_type'));
}
parent::beforeSave();
}
Expand All @@ -98,6 +100,9 @@ public function afterSave()
if (null !== $this->getData('tmp_selection_price_value')) {
$this->setSelectionPriceValue($this->getData('tmp_selection_price_value'));
}
if (null !== $this->getData('tmp_selection_price_type')) {
$this->setSelectionPriceType($this->getData('tmp_selection_price_type'));
}
$this->getResource()->saveSelectionPrice($this);

if (!$this->getDefaultPriceScope()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ public function testAddChildCouldNotSave(): void
->method('create')
->willReturn($bundle);

$selection = $this->createPartialMock(Selection::class, ['save']);
$selection = $this->createPartialMock(Selection::class, ['save', 'load']);
$selection->expects($this->once())->method('save')
->willReturnCallback(
static function () {
Expand Down Expand Up @@ -696,7 +696,7 @@ public function testAddChild(): void
->willReturn($selections);
$this->bundleFactoryMock->expects($this->once())->method('create')->willReturn($bundle);

$selection = $this->createPartialMock(Selection::class, ['save', 'getId']);
$selection = $this->createPartialMock(Selection::class, ['save', 'getId', 'load']);
$selection->expects($this->once())->method('save');
$selection->expects($this->once())->method('getId')->willReturn(42);
$this->bundleSelectionMock->expects($this->once())->method('create')->willReturn($selection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertSeeProductDetailsOnStorefrontRecentlyViewedWidgetActionGroup">
<annotations>
<description>Goes to the home Page Recently VIewed Product and Grab the Prdouct name and Position from it.</description>
<description>Goes to the home Page Recently Viewed Product and Grab the Product name and Position from it.</description>
</annotations>
<arguments>
<argument name="productName" type="string"/>
<argument name="productPosition" type="string"/>
</arguments>
<waitForElementVisible selector="{{StoreFrontRecentlyViewedProductSection.ProductName(productPosition)}}" stepKey="waitForProductToShowAtPosition"/>
<grabTextFrom selector="{{StoreFrontRecentlyViewedProductSection.ProductName(productPosition)}}" stepKey="grabRelatedProductPosition"/>
<assertStringContainsString stepKey="assertRelatedProductName">
<actualResult type="const">$grabRelatedProductPosition</actualResult>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ $mainImageData = $mainImage ?
<?= $imageWidth ? 'width="'. $escaper->escapeHtmlAttr($imageWidth) .'"' : '' ?>
<?= $imageHeight ? 'height="'. $escaper->escapeHtmlAttr($imageHeight) .'"' : '' ?>
/>
<link itemprop="image" href="<?= /* @noEscape */ $mainImageData ?>">
</div>
<?php // phpcs:ignore Magento2.Legacy.PhtmlTemplate ?>
<script type="text/x-magento-init">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,15 @@ define([
return;
}

// Filter initial ids to remove "out of scope" and "outdated" data
this.ids(
this.filterIds(this.ids())
);
this.initIdsListener();
this.idsMerger(
this.idsStorage.get(),
this.prepareDataFromCustomerData(customerData.get(this.identifiersConfig.namespace)())
);

if (!_.isEmpty(this.productStorage.data())) {
this.dataCollectionHandler(this.productStorage.data());
} else {
this.productStorage.setIds(this.data.currency, this.data.store, this.ids());
}
},

/**
Expand Down Expand Up @@ -176,7 +174,7 @@ define([

if (!_.isEmpty(data)) {
this.ids(
this.filterIds(_.extend(this.ids(), data))
this.filterIds(_.extend(utils.copy(this.ids()), data))
);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ define([
if (data.items && ids.length) {
//we can extend only items
data = data.items;
this.data(_.extend(data, currentData));
this.data(_.extend(currentData, data));
}
},

Expand Down Expand Up @@ -271,13 +271,9 @@ define([
sentDataIds = _.keys(this.request.data);
currentDataIds = _.keys(ids);

_.each(currentDataIds, function (id) {
if (_.lastIndexOf(sentDataIds, id) === -1) {
return false;
}
return _.every(currentDataIds, function (id) {
return _.lastIndexOf(sentDataIds, id) !== -1;
});

return true;
}

return false;
Expand Down
6 changes: 6 additions & 0 deletions app/code/Magento/Config/Model/Config/Backend/Email/Sender.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public function beforeSave()
);
}

if (str_contains($value, ":")) {
throw new \Magento\Framework\Exception\LocalizedException(
__('The sender name "%1" is not valid. The colon character is not allowed.', $value)
);
}

if (strlen($value) > 255) {
throw new \Magento\Framework\Exception\LocalizedException(
__('Maximum sender name length is 255. Please correct your settings.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function beforeSaveDataProvider()
{
return [
['Mr. Real Name', 'Mr. Real Name'],
['No colons:', false],
[str_repeat('a', 256), false],
[null, false],
['', false],
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Config/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ System,System
"Sorry, the default display currency you selected is not available in allowed currencies.","Sorry, the default display currency you selected is not available in allowed currencies."
"The ""%1"" email address is incorrect. Verify the email address and try again.","The ""%1"" email address is incorrect. Verify the email address and try again."
"The sender name ""%1"" is not valid. Please use only visible characters and spaces.","The sender name ""%1"" is not valid. Please use only visible characters and spaces."
"The sender name ""%1"" is not valid. The colon character is not allowed.","The sender name ""%1"" is not valid. The colon character is not allowed."
"Maximum sender name length is 255. Please correct your settings.","Maximum sender name length is 255. Please correct your settings."
"The file you're uploading exceeds the server size limit of %1 kilobytes.","The file you're uploading exceeds the server size limit of %1 kilobytes."
"The base directory to upload file is not specified.","The base directory to upload file is not specified."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ define([
options: {
superSelector: '.super-attribute-select',
selectSimpleProduct: '[name="selected_configurable_option"]',

/**
* @deprecated Not used anymore
* @see selectorProductPrice
*/
priceHolderSelector: '.price-box',
spConfig: {},
state: {},
Expand Down Expand Up @@ -86,7 +91,7 @@ define([
_initializeOptions: function () {
var options = this.options,
gallery = $(options.mediaGallerySelector),
priceBoxOptions = $(this.options.priceHolderSelector).priceBox('option').priceConfig || null;
priceBoxOptions = this._getPriceBoxElement().priceBox('option').priceConfig || null;

if (priceBoxOptions && priceBoxOptions.optionTemplate) {
options.optionTemplate = priceBoxOptions.optionTemplate;
Expand All @@ -100,7 +105,7 @@ define([

options.settings = options.spConfig.containerId ?
$(options.spConfig.containerId).find(options.superSelector) :
$(options.superSelector);
this.element.parents(this.options.selectorProduct).find(options.superSelector);

options.values = options.spConfig.defaultValues || {};
options.parentImage = $('[data-role=base-image-container] img').attr('src');
Expand Down Expand Up @@ -580,7 +585,7 @@ define([
* configurable product's option selections.
*/
_reloadPrice: function () {
$(this.options.priceHolderSelector).trigger('updatePrice', this._getPrices());
this._getPriceBoxElement().trigger('updatePrice', this._getPrices());
},

/**
Expand Down Expand Up @@ -654,7 +659,7 @@ define([
* @private
*/
_calculatePrice: function (config) {
var displayPrices = $(this.options.priceHolderSelector).priceBox('option').prices,
var displayPrices = this._getPriceBoxElement().priceBox('option').prices,
newPrices = this.options.spConfig.optionPrices[_.first(config.allowedProducts)] || {};

_.each(displayPrices, function (price, code) {
Expand Down Expand Up @@ -702,8 +707,7 @@ define([
*/
_displayRegularPriceBlock: function (optionId) {
var shouldBeShown = true,
$priceBox = this.element.parents(this.options.selectorProduct)
.find(this.options.selectorProductPrice);
$priceBox = this._getPriceBoxElement();

_.each(this.options.settings, function (element) {
if (element.value === '') {
Expand Down Expand Up @@ -785,6 +789,18 @@ define([
} else {
$(this.options.tierPriceBlockSelector).hide();
}
},

/**
* Returns the price container element
*
* @returns {*}
* @private
*/
_getPriceBoxElement: function () {
return this.element
.parents(this.options.selectorProduct)
.find(this.options.selectorProductPrice);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@

namespace Magento\Customer\Model\Address;

use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Model\Config\Share;
use Magento\Directory\Model\AllowedCountries;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\LocalizedException;

/**
* Provides customer address data.
*/
class CustomerAddressDataProvider
{
/**
* Customer addresses.
*
* @var array
*/
private $customerAddresses = [];
Expand Down Expand Up @@ -58,12 +55,14 @@ public function __construct(
/**
* Get addresses for customer.
*
* @param \Magento\Customer\Api\Data\CustomerInterface $customer
* @param CustomerInterface $customer
* @param int|null $addressLimit
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
* @throws LocalizedException
*/
public function getAddressDataByCustomer(
\Magento\Customer\Api\Data\CustomerInterface $customer
\Magento\Customer\Api\Data\CustomerInterface $customer,
?int $addressLimit = null
): array {
if (!empty($this->customerAddresses)) {
return $this->customerAddresses;
Expand All @@ -83,6 +82,9 @@ public function getAddressDataByCustomer(
}

$customerAddresses[$address->getId()] = $this->customerAddressDataFormatter->prepareAddress($address);
if ($addressLimit && count($customerAddresses) >= $addressLimit) {
break;
}
}

$this->customerAddresses = $customerAddresses;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
/**
* Copyright 2023 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
*/
declare(strict_types=1);

namespace Magento\Customer\Test\Unit\Model\Address;

use Magento\Customer\Api\Data\AddressInterface;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Model\Address\CustomerAddressDataFormatter;
use Magento\Customer\Model\Address\CustomerAddressDataProvider;
use Magento\Customer\Model\Config\Share;
use Magento\Directory\Model\AllowedCountries;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class CustomerAddressDataProviderTest extends TestCase
{
/**
* @var CustomerAddressDataFormatter|MockObject
*/
private CustomerAddressDataFormatter $customerAddressDataFormatter;

/**
* @var Share|MockObject
*/
private Share $shareConfig;

/**
* @var AllowedCountries|MockObject
*/
private AllowedCountries $allowedCountryReader;

/**
* @var CustomerAddressDataProvider
*/
private CustomerAddressDataProvider $provider;

/**
* @inheritdoc
*/
protected function setUp(): void
{
$this->customerAddressDataFormatter = $this->createMock(CustomerAddressDataFormatter::class);
$this->shareConfig = $this->createMock(Share::class);
$this->allowedCountryReader = $this->createMock(AllowedCountries::class);

$this->provider = new CustomerAddressDataProvider(
$this->customerAddressDataFormatter,
$this->shareConfig,
$this->allowedCountryReader
);
}

/**
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function testGetAddressDataByCustomer(): void
{
$addressLimit = 1;
$this->allowedCountryReader->expects($this->once())->method('getAllowedCountries')->willReturn(['1']);
$this->customerAddressDataFormatter->expects($this->once())
->method('prepareAddress')
->willreturn([1]);
$this->shareConfig->expects($this->any())->method('isGlobalScope')->willReturn(false);

$viableAddress = $this->getMockForAbstractClass(AddressInterface::class);
$viableAddress->expects($this->once())->method('getId')->willReturn(1);
$faultyAddress = $this->getMockForAbstractClass(AddressInterface::class);

$customer = $this->getMockForAbstractClass(CustomerInterface::class);
$customer->expects($this->once())
->method('getAddresses')
->willReturn([$viableAddress, $faultyAddress]);

$expectedResult = [
'1' => [1]
];
$this->assertSame($expectedResult, $this->provider->getAddressDataByCustomer($customer, $addressLimit));
}
}
Loading

0 comments on commit 97e33f5

Please sign in to comment.