Skip to content

Commit 5b556f6

Browse files
Merge branch 'magento-commerce:2.4-develop' into eav-graphql
2 parents 3ae9e5b + 35e8e43 commit 5b556f6

File tree

11 files changed

+509
-52
lines changed

11 files changed

+509
-52
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Source/Countryofmanufacture.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,62 @@
1111
*/
1212
namespace Magento\Catalog\Model\Product\Attribute\Source;
1313

14+
use Magento\Directory\Model\CountryFactory;
1415
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
16+
use Magento\Framework\App\Cache\Type\Config;
1517
use Magento\Framework\Data\OptionSourceInterface;
18+
use Magento\Framework\Locale\ResolverInterface;
19+
use Magento\Framework\Serialize\SerializerInterface;
20+
use Magento\Store\Model\StoreManagerInterface;
1621

1722
class Countryofmanufacture extends AbstractSource implements OptionSourceInterface
1823
{
1924
/**
20-
* @var \Magento\Framework\App\Cache\Type\Config
25+
* @var Config
2126
*/
2227
protected $_configCacheType;
2328

2429
/**
25-
* Store manager
26-
*
27-
* @var \Magento\Store\Model\StoreManagerInterface
30+
* @var StoreManagerInterface
2831
*/
2932
protected $_storeManager;
3033

3134
/**
32-
* Country factory
33-
*
34-
* @var \Magento\Directory\Model\CountryFactory
35+
* @var CountryFactory
3536
*/
3637
protected $_countryFactory;
3738

3839
/**
39-
* @var \Magento\Framework\Serialize\SerializerInterface
40+
* @var SerializerInterface
4041
*/
4142
private $serializer;
4243

44+
/**
45+
* @var ResolverInterface
46+
*/
47+
private $localeResolver;
48+
4349
/**
4450
* Construct
4551
*
46-
* @param \Magento\Directory\Model\CountryFactory $countryFactory
47-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
48-
* @param \Magento\Framework\App\Cache\Type\Config $configCacheType
52+
* @param CountryFactory $countryFactory
53+
* @param StoreManagerInterface $storeManager
54+
* @param Config $configCacheType
55+
* @param ResolverInterface $localeResolver
56+
* @param SerializerInterface $serializer
4957
*/
5058
public function __construct(
51-
\Magento\Directory\Model\CountryFactory $countryFactory,
52-
\Magento\Store\Model\StoreManagerInterface $storeManager,
53-
\Magento\Framework\App\Cache\Type\Config $configCacheType
59+
CountryFactory $countryFactory,
60+
StoreManagerInterface $storeManager,
61+
Config $configCacheType,
62+
ResolverInterface $localeResolver,
63+
SerializerInterface $serializer
5464
) {
5565
$this->_countryFactory = $countryFactory;
5666
$this->_storeManager = $storeManager;
5767
$this->_configCacheType = $configCacheType;
68+
$this->localeResolver = $localeResolver;
69+
$this->serializer = $serializer;
5870
}
5971

6072
/**
@@ -64,32 +76,20 @@ public function __construct(
6476
*/
6577
public function getAllOptions()
6678
{
67-
$cacheKey = 'COUNTRYOFMANUFACTURE_SELECT_STORE_' . $this->_storeManager->getStore()->getCode();
79+
$storeCode = $this->_storeManager->getStore()->getCode();
80+
$locale = $this->localeResolver->getLocale();
81+
82+
$cacheKey = 'COUNTRYOFMANUFACTURE_SELECT_STORE_' . $storeCode . '_LOCALE_' . $locale;
6883
if ($cache = $this->_configCacheType->load($cacheKey)) {
69-
$options = $this->getSerializer()->unserialize($cache);
84+
$options = $this->serializer->unserialize($cache);
7085
} else {
7186
/** @var \Magento\Directory\Model\Country $country */
7287
$country = $this->_countryFactory->create();
7388
/** @var \Magento\Directory\Model\ResourceModel\Country\Collection $collection */
7489
$collection = $country->getResourceCollection();
7590
$options = $collection->load()->toOptionArray();
76-
$this->_configCacheType->save($this->getSerializer()->serialize($options), $cacheKey);
91+
$this->_configCacheType->save($this->serializer->serialize($options), $cacheKey);
7792
}
7893
return $options;
7994
}
80-
81-
/**
82-
* Get serializer
83-
*
84-
* @return \Magento\Framework\Serialize\SerializerInterface
85-
* @deprecated 102.0.0
86-
*/
87-
private function getSerializer()
88-
{
89-
if ($this->serializer === null) {
90-
$this->serializer = \Magento\Framework\App\ObjectManager::getInstance()
91-
->get(\Magento\Framework\Serialize\SerializerInterface::class);
92-
}
93-
return $this->serializer;
94-
}
9595
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Source/CountryofmanufactureTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Catalog\Model\Product\Attribute\Source\Countryofmanufacture;
1111
use Magento\Framework\App\Cache\Type\Config;
12+
use Magento\Framework\Locale\ResolverInterface;
1213
use Magento\Framework\Serialize\SerializerInterface;
1314
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1415
use Magento\Store\Model\Store;
@@ -46,17 +47,24 @@ class CountryofmanufactureTest extends TestCase
4647
*/
4748
private $serializerMock;
4849

50+
/**
51+
* @var ResolverInterface
52+
*/
53+
private $localeResolverMock;
54+
4955
protected function setUp(): void
5056
{
5157
$this->storeManagerMock = $this->getMockForAbstractClass(StoreManagerInterface::class);
5258
$this->storeMock = $this->createMock(Store::class);
5359
$this->cacheConfig = $this->createMock(Config::class);
60+
$this->localeResolverMock = $this->getMockForAbstractClass(ResolverInterface::class);
5461
$this->objectManagerHelper = new ObjectManager($this);
5562
$this->countryOfManufacture = $this->objectManagerHelper->getObject(
5663
Countryofmanufacture::class,
5764
[
5865
'storeManager' => $this->storeManagerMock,
5966
'configCacheType' => $this->cacheConfig,
67+
'localeResolver' => $this->localeResolverMock,
6068
]
6169
);
6270

@@ -80,9 +88,10 @@ public function testGetAllOptions($cachedDataSrl, $cachedDataUnsrl)
8088
{
8189
$this->storeMock->expects($this->once())->method('getCode')->willReturn('store_code');
8290
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock);
91+
$this->localeResolverMock->expects($this->once())->method('getLocale')->willReturn('en_US');
8392
$this->cacheConfig->expects($this->once())
8493
->method('load')
85-
->with($this->equalTo('COUNTRYOFMANUFACTURE_SELECT_STORE_store_code'))
94+
->with($this->equalTo('COUNTRYOFMANUFACTURE_SELECT_STORE_store_code_LOCALE_en_US'))
8695
->willReturn($cachedDataSrl);
8796
$this->serializerMock->expects($this->once())
8897
->method('unserialize')

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/summary.js

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,8 @@ define([
135135
if (productId && !images.file) {
136136
images = product.images;
137137
}
138-
productDataFromGrid = _.pick(
139-
productDataFromGrid,
140-
'sku',
141-
'name',
142-
'weight',
143-
'status',
144-
'price',
145-
'qty'
146-
);
138+
productDataFromGrid = this.prepareProductDataFromGrid(productDataFromGrid);
147139

148-
if (productDataFromGrid.hasOwnProperty('qty')) {
149-
productDataFromGrid[this.quantityFieldName] = productDataFromGrid.qty;
150-
}
151-
delete productDataFromGrid.qty;
152140
product = _.pick(
153141
product || {},
154142
'sku',
@@ -288,6 +276,32 @@ define([
288276
* Back.
289277
*/
290278
back: function () {
279+
},
280+
281+
/**
282+
* Prepare product data from grid to have all the current fields values
283+
*
284+
* @param {Object} productDataFromGrid
285+
* @return {Object}
286+
*/
287+
prepareProductDataFromGrid: function (productDataFromGrid) {
288+
productDataFromGrid = _.pick(
289+
productDataFromGrid,
290+
'sku',
291+
'name',
292+
'weight',
293+
'status',
294+
'price',
295+
'qty'
296+
);
297+
298+
if (productDataFromGrid.hasOwnProperty('qty')) {
299+
productDataFromGrid[this.quantityFieldName] = productDataFromGrid.qty;
300+
}
301+
302+
delete productDataFromGrid.qty;
303+
304+
return productDataFromGrid;
291305
}
292306
});
293307
});

app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerSignInFormSection/StorefrontCustomerSignInPopupFormSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
<element name="password" type="input" selector="#pass"/>
1414
<element name="signIn" type="button" selector="(//button[@id='send2'][contains(@class, 'login')])[1]" timeout="30"/>
1515
<element name="forgotYourPassword" type="button" selector="//a[@class='action']//span[contains(text(),'Forgot Your Password?')]" timeout="30"/>
16-
<element name="createAnAccount" type="button" selector="//div[contains(@class,'actions-toolbar')]//a[contains(.,'Create an Account')]" timeout="30"/>
16+
<element name="createAnAccount" type="button" selector="(//div[contains(@class,'actions-toolbar')]//a[contains(.,'Create an Account')])[last()]" timeout="30"/>
1717
</section>
1818
</sections>

app/code/Magento/Marketplace/view/adminhtml/templates/index.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
<h2 class="page-sub-title"><?= $block->escapeHtml(__('Partner search')) ?></h2>
3333
<p>
3434
<?= $block->escapeHtml(__(
35-
'Magento has a thriving ecosystem of technology partners to help merchants and brands deliver ' .
36-
'the best possible customer experiences. They are recognized as experts in eCommerce, ' .
35+
'Magento has a thriving ecosystem of technology partners to help merchants and brands deliver '
36+
. 'the best possible customer experiences. They are recognized as experts in eCommerce, ' .
3737
'search, email marketing, payments, tax, fraud, optimization and analytics, fulfillment, ' .
3838
'and more. Visit the Magento Partner Directory to see all of our trusted partners.'
3939
)); ?>
@@ -61,7 +61,7 @@
6161
)); ?>
6262
</p>
6363
<a class="action-secondary" target="_blank"
64-
href="https://marketplace.magento.com/">
64+
href="https://commercemarketplace.adobe.com/">
6565
<?= $block->escapeHtml(__('Visit Magento Marketplaces')) ?>
6666
</a>
6767
</div>

app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontGuestCheckingWithMultishipmentTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
</actionGroup>
4545
<actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCart"/>
4646
<click selector="{{MultishippingSection.checkoutWithMultipleAddresses}}" stepKey="proceedMultishipping"/>
47+
<waitForElementClickable selector="{{StorefrontCustomerSignInPopupFormSection.createAnAccount}}" stepKey="waitForCreateAccount"/>
4748
<click selector="{{StorefrontCustomerSignInPopupFormSection.createAnAccount}}" stepKey="clickCreateAccount"/>
4849
<seeElement selector="{{CheckoutShippingSection.region}}" stepKey="seeRegionSelector"/>
4950
</test>

app/code/Magento/UrlRewrite/Test/Mftf/Data/UrlRewriteData.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</entity>
2929
<entity name="customPermanentUrlRewrite" type="urlRewrite">
3030
<data key="request_path" unique="prefix">wishlist</data>
31-
<data key="target_path">https://marketplace.magento.com/</data>
31+
<data key="target_path">https://commercemarketplace.adobe.com/</data>
3232
<data key="redirect_type">301</data>
3333
<data key="redirect_type_label">Permanent (301)</data>
3434
<data key="store_id">1</data>
@@ -37,7 +37,7 @@
3737
</entity>
3838
<entity name="customTemporaryUrlRewrite" type="urlRewrite">
3939
<data key="request_path" unique="prefix">wishlist</data>
40-
<data key="target_path">https://marketplace.magento.com/</data>
40+
<data key="target_path">https://commercemarketplace.adobe.com/</data>
4141
<data key="redirect_type">302</data>
4242
<data key="redirect_type_label">Temporary (302)</data>
4343
<data key="store_id">1</data>

dev/tests/integration/testsuite/Magento/Newsletter/Model/Plugin/PluginTest.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
namespace Magento\Newsletter\Model\Plugin;
77

88
use Magento\TestFramework\Helper\Bootstrap;
9+
use Magento\TestFramework\Mail\Template\TransportBuilderMock;
910

1011
/**
12+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
13+
* phpcs:disable Magento2.Security.Superglobal
1114
* @magentoAppIsolation enabled
1215
*/
1316
class PluginTest extends \PHPUnit\Framework\TestCase
@@ -24,6 +27,11 @@ class PluginTest extends \PHPUnit\Framework\TestCase
2427
*/
2528
protected $customerRepository;
2629

30+
/**
31+
* @var TransportBuilderMock
32+
*/
33+
protected $transportBuilderMock;
34+
2735
protected function setUp(): void
2836
{
2937
$this->accountManagement = Bootstrap::getObjectManager()->get(
@@ -32,6 +40,9 @@ protected function setUp(): void
3240
$this->customerRepository = Bootstrap::getObjectManager()->get(
3341
\Magento\Customer\Api\CustomerRepositoryInterface::class
3442
);
43+
$this->transportBuilderMock = Bootstrap::getObjectManager()->get(
44+
TransportBuilderMock::class
45+
);
3546
}
3647

3748
protected function tearDown(): void
@@ -223,4 +234,67 @@ public function testCustomerWithTwoNewsLetterSubscriptions()
223234
$extensionAttributes = $customer->getExtensionAttributes();
224235
$this->assertTrue($extensionAttributes->getIsSubscribed());
225236
}
237+
238+
/**
239+
* @magentoAppArea adminhtml
240+
* @magentoDbIsolation enabled
241+
* @magentoConfigFixture current_store newsletter/general/active 1
242+
* @magentoDataFixture Magento/Customer/_files/customer_welcome_email_template.php
243+
*
244+
* @return void
245+
* @throws \Magento\Framework\Exception\LocalizedException
246+
*/
247+
public function testCreateAccountWithNewsLetterSubscription(): void
248+
{
249+
$objectManager = Bootstrap::getObjectManager();
250+
/** @var \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory */
251+
$customerFactory = $objectManager->get(\Magento\Customer\Api\Data\CustomerInterfaceFactory::class);
252+
$customerDataObject = $customerFactory->create()
253+
->setFirstname('John')
254+
->setLastname('Doe')
255+
->setEmail('[email protected]');
256+
$extensionAttributes = $customerDataObject->getExtensionAttributes();
257+
$extensionAttributes->setIsSubscribed(true);
258+
$customerDataObject->setExtensionAttributes($extensionAttributes);
259+
$this->accountManagement->createAccount($customerDataObject, '123123qW');
260+
$message = $this->transportBuilderMock->getSentMessage();
261+
262+
$this->assertNotNull($message);
263+
$this->assertEquals('Welcome to Main Website Store', $message->getSubject());
264+
$this->assertStringContainsString(
265+
'John',
266+
$message->getBody()->getParts()[0]->getRawContent()
267+
);
268+
$this->assertStringContainsString(
269+
270+
$message->getBody()->getParts()[0]->getRawContent()
271+
);
272+
273+
/** @var \Magento\Newsletter\Model\Subscriber $subscriber */
274+
$subscriber = $objectManager->create(\Magento\Newsletter\Model\Subscriber::class);
275+
$subscriber->loadByEmail('[email protected]');
276+
$this->assertTrue($subscriber->isSubscribed());
277+
278+
$this->transportBuilderMock->setTemplateIdentifier(
279+
'newsletter_subscription_confirm_email_template'
280+
)->setTemplateVars([
281+
'subscriber_data' => [
282+
'confirmation_link' => $subscriber->getConfirmationLink(),
283+
],
284+
])->setTemplateOptions([
285+
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
286+
'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID
287+
])
288+
->addTo('[email protected]')
289+
->getTransport();
290+
291+
$message = $this->transportBuilderMock->getSentMessage();
292+
293+
$this->assertNotNull($message);
294+
$this->assertStringContainsString(
295+
$subscriber->getConfirmationLink(),
296+
$message->getBody()->getParts()[0]->getRawContent()
297+
);
298+
$this->assertEquals('Newsletter subscription confirmation', $message->getSubject());
299+
}
226300
}

0 commit comments

Comments
 (0)