Skip to content

Commit 25842ee

Browse files
Merge remote-tracking branch '36623_v1/issue-36591' into comm_voted_v3
2 parents 0ce7599 + 8d4a679 commit 25842ee

File tree

10 files changed

+437
-76
lines changed

10 files changed

+437
-76
lines changed

app/code/Magento/CatalogGraphQl/DataProvider/Product/SearchCriteriaBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function __construct(
9898
public function build(array $args, bool $includeAggregation): SearchCriteriaInterface
9999
{
100100
$searchCriteria = $this->builder->build('products', $args);
101-
$isSearch = !empty($args['search']);
101+
$isSearch = isset($args['search']);
102102
$this->updateRangeFilters($searchCriteria);
103103
if ($includeAggregation) {
104104
$attributeData = $this->eavConfig->getAttribute(Product::ENTITY, 'price');
@@ -122,7 +122,7 @@ public function build(array $args, bool $includeAggregation): SearchCriteriaInte
122122
}
123123

124124
$this->addEntityIdSort($searchCriteria);
125-
$this->addVisibilityFilter($searchCriteria, $isSearch, !empty($args['filter']));
125+
$this->addVisibilityFilter($searchCriteria, $isSearch, !empty($args['filter']['category_id']));
126126

127127
$searchCriteria->setCurrentPage($args['currentPage']);
128128
$searchCriteria->setPageSize($args['pageSize']);

app/code/Magento/CatalogGraphQl/Test/Unit/DataProvider/Product/SearchCriteriaBuilderTest.php

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -97,51 +97,63 @@ public function testBuild(): void
9797
$filter = $this->createMock(Filter::class);
9898

9999
$searchCriteria = $this->getMockBuilder(SearchCriteriaInterface::class)
100-
->disableOriginalConstructor()
101-
->getMockForAbstractClass();
100+
->disableOriginalConstructor()
101+
->getMockForAbstractClass();
102102
$attributeInterface = $this->getMockBuilder(Attribute::class)
103-
->disableOriginalConstructor()
104-
->getMockForAbstractClass();
103+
->disableOriginalConstructor()
104+
->getMockForAbstractClass();
105105

106106
$attributeInterface->setData(['is_filterable' => 0]);
107107

108108
$this->builder->expects($this->any())
109-
->method('build')
110-
->with('products', $args)
111-
->willReturn($searchCriteria);
109+
->method('build')
110+
->with('products', $args)
111+
->willReturn($searchCriteria);
112112
$searchCriteria->expects($this->any())->method('getFilterGroups')->willReturn([]);
113113
$this->eavConfig->expects($this->any())
114-
->method('getAttribute')
115-
->with(Product::ENTITY, 'price')
116-
->willReturn($attributeInterface);
117-
118-
$this->sortOrderBuilder->expects($this->once())
119-
->method('setField')
120-
->with('_id')
121-
->willReturnSelf();
122-
$this->sortOrderBuilder->expects($this->once())
123-
->method('setDirection')
124-
->with('DESC')
125-
->willReturnSelf();
126-
$this->sortOrderBuilder->expects($this->any())
127-
->method('create')
128-
->willReturn([]);
129-
130-
$this->filterBuilder->expects($this->once())
131-
->method('setField')
132-
->with('visibility')
133-
->willReturnSelf();
134-
$this->filterBuilder->expects($this->once())
135-
->method('setValue')
136-
->with("")
137-
->willReturnSelf();
138-
$this->filterBuilder->expects($this->once())
139-
->method('setConditionType')
140-
->with('in')
141-
->willReturnSelf();
142-
143-
$this->filterBuilder->expects($this->once())->method('create')->willReturn($filter);
144-
114+
->method('getAttribute')
115+
->with(Product::ENTITY, 'price')
116+
->willReturn($attributeInterface);
117+
$sortOrderList = ['relevance','_id'];
118+
$sortIncrementIndex = 0;
119+
foreach ($sortOrderList as $sortList) {
120+
$this->sortOrderBuilder->expects($this->at($sortIncrementIndex++))
121+
->method('setField')
122+
->with($sortList)
123+
->willReturnSelf();
124+
$this->sortOrderBuilder->expects($this->at($sortIncrementIndex++))
125+
->method('setDirection')
126+
->with('DESC')
127+
->willReturnSelf();
128+
$this->sortOrderBuilder->expects($this->at($sortIncrementIndex++))
129+
->method('create')
130+
->willReturn([]);
131+
}
132+
$filterOrderList = [1=>'search_term', 2=>'visibility'];
133+
$filterIncrementIndex = 0;
134+
foreach ($filterOrderList as $index => $filterList) {
135+
$this->filterBuilder->expects($this->at($filterIncrementIndex++))
136+
->method('setField')
137+
->with($filterList)
138+
->willReturnSelf();
139+
$this->filterBuilder->expects($this->at($filterIncrementIndex++))
140+
->method('setValue')
141+
->with('')
142+
->willReturnSelf();
143+
if ($index==2) {
144+
$this->filterBuilder->expects($this->at($filterIncrementIndex++))
145+
->method('setConditionType')
146+
->with('in')
147+
->willReturnSelf();
148+
} else {
149+
$this->filterBuilder->expects($this->at($filterIncrementIndex++))
150+
->method('setConditionType')
151+
->with('')
152+
->willReturnSelf();
153+
}
154+
155+
$this->filterBuilder->expects($this->at($filterIncrementIndex++))->method('create')->willReturn($filter);
156+
}
145157
$this->filterGroupBuilder->expects($this->any())
146158
->method('addFilter')
147159
->with($filter)

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/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchTest.php

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,11 +2250,10 @@ public function testProductPartialNameFullTextSearchQuery(): void
22502250
}
22512251
QUERY;
22522252
$prod1 = $this->productRepository->get('simple1');
2253-
$prod2 = $this->productRepository->get('simple2');
22542253
$response = $this->graphQlQuery($query);
2255-
$this->assertEquals(2, $response['products']['total_count']);
2254+
$this->assertEquals(1, $response['products']['total_count']);
22562255

2257-
$filteredProducts = [$prod1, $prod2];
2256+
$filteredProducts = [$prod1];
22582257
$productItemsInResponse = array_map(null, $response['products']['items'], $filteredProducts);
22592258
foreach ($productItemsInResponse as $itemIndex => $itemArray) {
22602259
$this->assertNotEmpty($itemArray);
@@ -2337,11 +2336,10 @@ public function testProductPartialSkuFullTextSearchQuery(): void
23372336
}
23382337
QUERY;
23392338
$prod1 = $this->productRepository->get('prd1sku');
2340-
$prod2 = $this->productRepository->get('prd2-sku2');
23412339
$response = $this->graphQlQuery($query);
2342-
$this->assertEquals(2, $response['products']['total_count']);
2340+
$this->assertEquals(1, $response['products']['total_count']);
23432341

2344-
$filteredProducts = [$prod1, $prod2];
2342+
$filteredProducts = [$prod1];
23452343
$productItemsInResponse = array_map(null, $response['products']['items'], $filteredProducts);
23462344
foreach ($productItemsInResponse as $itemIndex => $itemArray) {
23472345
$this->assertNotEmpty($itemArray);
@@ -2364,14 +2362,13 @@ public function testProductPartialSkuFullTextSearchQuery(): void
23642362
}
23652363

23662364
/**
2367-
* Partial search on hyphenated sku filtered for price and sorted by price and sku
2365+
* Partial search on hyphenated sku having visibility as catalog
23682366
*
23692367
* @magentoApiDataFixture Magento/Catalog/_files/category.php
23702368
* @magentoApiDataFixture Magento/Catalog/_files/multiple_products_with_different_sku_and_name.php
23712369
*/
23722370
public function testProductPartialSkuHyphenatedFullTextSearchQuery(): void
23732371
{
2374-
$prod2 = $this->productRepository->get('prd2-sku2');
23752372
$textToSearch = 'sku2';
23762373
$query
23772374
= <<<QUERY
@@ -2426,28 +2423,7 @@ public function testProductPartialSkuHyphenatedFullTextSearchQuery(): void
24262423
QUERY;
24272424

24282425
$response = $this->graphQlQuery($query);
2429-
$this->assertEquals(1, $response['products']['total_count']);
2430-
2431-
$filteredProducts = [$prod2];
2432-
$productItemsInResponse = array_map(null, $response['products']['items'], $filteredProducts);
2433-
foreach ($productItemsInResponse as $itemIndex => $itemArray) {
2434-
$this->assertNotEmpty($itemArray);
2435-
$this->assertResponseFields(
2436-
$productItemsInResponse[$itemIndex][0],
2437-
[
2438-
'sku' => $filteredProducts[$itemIndex]->getSku(),
2439-
'name' => $filteredProducts[$itemIndex]->getName(),
2440-
'price' => [
2441-
'minimalPrice' => [
2442-
'amount' => [
2443-
'value' => $filteredProducts[$itemIndex]->getSpecialPrice(),
2444-
'currency' => 'USD'
2445-
]
2446-
]
2447-
]
2448-
]
2449-
);
2450-
}
2426+
$this->assertEquals(0, $response['products']['total_count']);
24512427
}
24522428

24532429
/**

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('customer@example.com');
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+
'customer@example.com',
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('customer@example.com');
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('customer@example.com')
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)