Skip to content

Commit 0a3cd60

Browse files
merge magento-commerce/2.4-develop into magento-tango/TANGO-PR-09-01-2020_24
2 parents 281b422 + b87f1df commit 0a3cd60

21 files changed

+701
-53
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminOpenConfigGeneralAnalyticsPageActionGroup">
12+
<annotations>
13+
<description>Open Config General Analytics Page.</description>
14+
</annotations>
15+
16+
<amOnPage url="{{AdminConfigGeneralAnalyticsPage.url}}" stepKey="amOnAdminConfig"/>
17+
<waitForPageLoad stepKey="waitPageLoad"/>
18+
</actionGroup>
19+
</actionGroups>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminAdvancedReportingPageUrlActionGroup">
12+
<annotations>
13+
<description>Assert admin advanced reporting page url.</description>
14+
</annotations>
15+
16+
<switchToNextTab stepKey="switchToNewTab"/>
17+
<waitForPageLoad stepKey="waitForAdvancedReportingPageLoad"/>
18+
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
19+
</actionGroup>
20+
</actionGroups>

app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
<amOnPage url="{{AdminDashboardPage.url}}" stepKey="amOnDashboardPage"/>
3333
<waitForPageLoad stepKey="waitForDashboardPageLoad"/>
3434
<click selector="{{AdminAdvancedReportingSection.goToAdvancedReporting}}" stepKey="clickGoToAdvancedReporting"/>
35-
<switchToNextTab stepKey="switchToNewTab"/>
36-
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
35+
<actionGroup ref="AssertAdminAdvancedReportingPageUrlActionGroup" stepKey="assertAdvancedReportingPageUrl"/>
3736
</test>
3837
</tests>

app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingNavigateMenuTest.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
<argument name="menuUiId" value="{{AdminMenuReports.dataUiId}}"/>
3030
<argument name="submenuUiId" value="{{AdminMenuReportsBusinessIntelligenceAdvancedReporting.dataUiId}}"/>
3131
</actionGroup>
32-
<switchToNextTab stepKey="switchToNewTab"/>
33-
<waitForPageLoad stepKey="waitForAdvancedReportingPageLoad"/>
34-
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
32+
<actionGroup ref="AssertAdminAdvancedReportingPageUrlActionGroup" stepKey="assertAdvancedReportingPageUrl"/>
3533
</test>
3634
</tests>

app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationBlankIndustryTest.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
<testCaseId value="MAGETWO-63981"/>
1818
<group value="analytics"/>
1919
</annotations>
20+
<before>
21+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
22+
</before>
2023
<after>
2124
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
2225
</after>
23-
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
24-
<amOnPage url="{{AdminConfigGeneralAnalyticsPage.url}}" stepKey="amOnAdminConfig"/>
26+
<actionGroup ref="AdminOpenConfigGeneralAnalyticsPageActionGroup" stepKey="amOnAdminConfig"/>
2527
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingService}}" userInput="Enable" stepKey="selectAdvancedReportingServiceEnabled"/>
2628
<see selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustryLabel}}" userInput="Industry" stepKey="seeAdvancedReportingIndustryLabel"/>
2729
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustry}}" userInput="--Please Select--" stepKey="selectAdvancedReportingIndustry"/>

app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationEnableDisableAnalyticsTest.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
<testCaseId value="MAGETWO-66465"/>
1818
<group value="analytics"/>
1919
</annotations>
20+
<before>
21+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
22+
</before>
2023
<after>
2124
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
2225
</after>
23-
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
24-
<amOnPage url="{{AdminConfigGeneralAnalyticsPage.url}}" stepKey="amOnAdminConfig"/>
26+
<actionGroup ref="AdminOpenConfigGeneralAnalyticsPageActionGroup" stepKey="amOnAdminConfig"/>
2527
<see selector="{{AdminConfigAdvancedReportingSection.advancedReportingServiceLabel}}" userInput="Advanced Reporting Service" stepKey="seeAdvancedReportingServiceLabelEnabled"/>
2628
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingService}}" userInput="Enable" stepKey="selectAdvancedReportingServiceEnabled"/>
2729
<see selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustryLabel}}" userInput="Industry" stepKey="seeAdvancedReportingIndustryLabel"/>

app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationIndustryTest.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
<testCaseId value="MAGETWO-63898"/>
1919
<group value="analytics"/>
2020
</annotations>
21-
22-
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
23-
<amOnPage url="{{AdminConfigGeneralAnalyticsPage.url}}" stepKey="amOnAdminConfig"/>
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
23+
</before>
24+
<after>
25+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
26+
</after>
27+
<actionGroup ref="AdminOpenConfigGeneralAnalyticsPageActionGroup" stepKey="amOnAdminConfig"/>
2428
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingService}}" userInput="Enable" stepKey="selectAdvancedReportingServiceEnabled"/>
2529
<see selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustryLabel}}" userInput="Industry" stepKey="seeAdvancedReportingIndustryLabel"/>
2630
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustry}}" userInput="Apps and Games" stepKey="selectAdvancedReportingIndustry"/>

app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationTimeToSendDataTest.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
<testCaseId value="MAGETWO-66464"/>
1919
<group value="analytics"/>
2020
</annotations>
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
23+
</before>
2124
<after>
2225
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
2326
</after>
24-
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
25-
<amOnPage url="{{AdminConfigGeneralAnalyticsPage.url}}" stepKey="amOnAdminConfig"/>
27+
<actionGroup ref="AdminOpenConfigGeneralAnalyticsPageActionGroup" stepKey="amOnAdminConfig"/>
2628
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingService}}" userInput="Enable" stepKey="selectAdvancedReportingServiceEnabled"/>
2729
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustry}}" userInput="Apps and Games" stepKey="selectAdvancedReportingIndustry"/>
2830
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingHour}}" userInput="23" stepKey="selectAdvancedReportingHour"/>

app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
<argument name="categoryName" value="$$categoryN.name$$, $$categoryM.name$$"/>
5959
</actionGroup>
6060

61-
<wait stepKey="waitBeforeRunCronIndex" time="30"/>
61+
<wait stepKey="waitBeforeRunCronIndex" time="60"/>
6262
<magentoCLI stepKey="runCronIndex" command="cron:run --group=index"/>
63-
<wait stepKey="waitAfterRunCronIndex" time="60"/>
63+
<wait stepKey="waitAfterRunCronIndex" time="120"/>
6464
</before>
6565
<after>
6666
<!-- Change "Category Products" and "Product Categories" indexers to "Update on Save" mode -->
@@ -108,6 +108,8 @@
108108
<argument name="categoryName" value="$$categoryK.name$$"/>
109109
</actionGroup>
110110

111+
<wait stepKey="waitAfterAssignCategoryK" time="60"/>
112+
111113
<!-- Unassign category M from Product B -->
112114
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="amOnEditCategoryPageB">
113115
<argument name="productId" value="$$productB.id$$"/>
@@ -147,8 +149,9 @@
147149
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductInCategoryN"/>
148150

149151
<!-- Run cron -->
150-
<wait stepKey="waitBeforeRunMagentoCron" time="30"/>
152+
<wait stepKey="waitBeforeRunMagentoCron" time="60"/>
151153
<magentoCLI stepKey="runMagentoCron" command="cron:run --group=index"/>
154+
152155
<wait stepKey="waitAfterRunMagentoCron" time="90"/>
153156

154157
<!-- Open categories K, L, M, N on Storefront in order to make sure that new assigments are applied -->
@@ -213,8 +216,9 @@
213216
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="productCOnCategoryN"/>
214217

215218
<!-- Run Cron once to reindex product changes -->
216-
<wait stepKey="waitBeforeRunCronIndexAfterProductAssignToCategory" time="30"/>
219+
<wait stepKey="waitBeforeRunCronIndexAfterProductAssignToCategory" time="60"/>
217220
<magentoCLI stepKey="runCronIndexAfterProductAssignToCategory" command="cron:run --group=index"/>
221+
218222
<wait stepKey="waitAfterRunCronIndexAfterProductAssignToCategory" time="90"/>
219223

220224
<!-- Open categories K, L, M, N on Storefront in order to make sure that new assigments are applied -->

app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminCustomerFindWishlistItemActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
</arguments>
1515
<fillField userInput="{{productName}}" selector="{{AdminCustomerWishlistSection.productName}}" stepKey="fillProductNameField"/>
1616
<click selector="{{AdminCustomerWishlistSection.searchButton}}" stepKey="clickSearchButton"/>
17-
<waitForPageLoad stepKey="waitForGridLoading"/>
17+
<waitForAjaxLoad time="60" stepKey="waitForLoading"/>
1818
</actionGroup>
1919
</actionGroups>

app/code/Magento/Developer/Console/Command/GeneratePatchCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
133133
}
134134
$type = $input->getOption(self::INPUT_KEY_PATCH_TYPE);
135135
$modulePath = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName);
136+
if (null === $modulePath) {
137+
throw new \InvalidArgumentException(sprintf('Cannot find a registered module with name "%s"', $moduleName));
138+
}
136139
$preparedModuleName = str_replace('_', '\\', $moduleName);
137140
$preparedType = ucfirst($type);
138141
$patchInterface = sprintf('%sPatchInterface', $preparedType);
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Developer\Test\Unit\Console\Command;
8+
9+
use Magento\Developer\Console\Command\GeneratePatchCommand;
10+
use Magento\Framework\Component\ComponentRegistrar;
11+
use Magento\Framework\Filesystem\Directory\Read;
12+
use Magento\Framework\Filesystem\Directory\ReadFactory;
13+
use Magento\Framework\Filesystem\Directory\Write;
14+
use Magento\Framework\Filesystem\Directory\WriteFactory;
15+
use Magento\Framework\Filesystem\DirectoryList;
16+
use PHPUnit\Framework\MockObject\MockObject;
17+
use PHPUnit\Framework\TestCase;
18+
use Symfony\Component\Console\Tester\CommandTester;
19+
20+
class GeneratePatchCommandTest extends TestCase
21+
{
22+
/**
23+
* @var ComponentRegistrar|MockObject
24+
*/
25+
private $componentRegistrarMock;
26+
27+
/**
28+
* @var DirectoryList|MockObject
29+
*/
30+
private $directoryListMock;
31+
32+
/**
33+
* @var ReadFactory|MockObject
34+
*/
35+
private $readFactoryMock;
36+
37+
/**
38+
* @var WriteFactory|MockObject
39+
*/
40+
private $writeFactoryMock;
41+
42+
/**
43+
* @var GeneratePatchCommand|MockObject
44+
*/
45+
private $command;
46+
47+
protected function setUp(): void
48+
{
49+
$this->componentRegistrarMock = $this->createMock(ComponentRegistrar::class);
50+
$this->directoryListMock = $this->createMock(DirectoryList::class);
51+
$this->readFactoryMock = $this->createMock(ReadFactory::class);
52+
$this->writeFactoryMock = $this->createMock(WriteFactory::class);
53+
54+
$this->command = new GeneratePatchCommand(
55+
$this->componentRegistrarMock,
56+
$this->directoryListMock,
57+
$this->readFactoryMock,
58+
$this->writeFactoryMock
59+
);
60+
}
61+
62+
public function testExecute()
63+
{
64+
$this->componentRegistrarMock->expects($this->once())
65+
->method('getPath')
66+
->with('module', 'Vendor_Module')
67+
->willReturn('/long/path/to/Vendor/Module');
68+
69+
$read = $this->createMock(Read::class);
70+
$read->expects($this->at(0))
71+
->method('readFile')
72+
->with('patch_template.php.dist')
73+
->willReturn('something');
74+
$this->readFactoryMock->method('create')->willReturn($read);
75+
76+
$write = $this->createMock(Write::class);
77+
$write->expects($this->once())->method('writeFile');
78+
$this->writeFactoryMock->method('create')->willReturn($write);
79+
80+
$this->directoryListMock->expects($this->once())->method('getRoot')->willReturn('/some/path');
81+
82+
$commandTester = new CommandTester($this->command);
83+
$commandTester->execute(
84+
[
85+
GeneratePatchCommand::MODULE_NAME => 'Vendor_Module',
86+
GeneratePatchCommand::INPUT_KEY_PATCH_NAME => 'SomePatch'
87+
]
88+
);
89+
$this->assertStringContainsString('successfully generated', $commandTester->getDisplay());
90+
}
91+
92+
public function testWrongParameter()
93+
{
94+
$this->expectExceptionMessage('Not enough arguments');
95+
$this->expectException(\RuntimeException::class);
96+
97+
$commandTester = new CommandTester($this->command);
98+
$commandTester->execute([]);
99+
}
100+
101+
public function testBadModule()
102+
{
103+
$this->componentRegistrarMock->expects($this->once())
104+
->method('getPath')
105+
->with('module', 'Fake_Module')
106+
->willReturn(null);
107+
108+
$this->expectExceptionMessage('Cannot find a registered module with name "Fake_Module"');
109+
$this->expectException(\InvalidArgumentException::class);
110+
111+
$commandTester = new CommandTester($this->command);
112+
$commandTester->execute(
113+
[
114+
GeneratePatchCommand::MODULE_NAME => 'Fake_Module',
115+
GeneratePatchCommand::INPUT_KEY_PATCH_NAME => 'SomePatch'
116+
]
117+
);
118+
}
119+
}

app/code/Magento/Downloadable/Observer/SetLinkStatusObserver.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
6161
'payment_pending' => \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING_PAYMENT,
6262
'payment_review' => \Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PAYMENT_REVIEW,
6363
];
64+
$expiredOrderItemIds = [];
6465

6566
$downloadableItemsStatuses = [];
6667
$orderItemStatusToEnable = $this->_scopeConfig->getValue(
@@ -114,6 +115,10 @@ public function execute(\Magento\Framework\Event\Observer $observer)
114115
if (in_array($item->getStatusId(), $availableStatuses)) {
115116
$downloadableItemsStatuses[$item->getId()] = $linkStatuses['avail'];
116117
}
118+
119+
if ($item->getQtyOrdered() - $item->getQtyRefunded() == 0) {
120+
$expiredOrderItemIds[] = $item->getId();
121+
}
117122
}
118123
}
119124
}
@@ -141,10 +146,22 @@ public function execute(\Magento\Framework\Event\Observer $observer)
141146
}
142147
}
143148

149+
if ($expiredOrderItemIds) {
150+
$linkPurchased = $this->_createItemsCollection()->addFieldToFilter(
151+
'order_item_id',
152+
['in' => $expiredOrderItemIds]
153+
);
154+
foreach ($linkPurchased as $link) {
155+
$link->setStatus(\Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_EXPIRED)->save();
156+
}
157+
}
158+
144159
return $this;
145160
}
146161

147162
/**
163+
* Returns purchased item collection
164+
*
148165
* @return \Magento\Downloadable\Model\ResourceModel\Link\Purchased\Item\Collection
149166
*/
150167
protected function _createItemsCollection()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontNotAssertDownloadableProductLinkInCustomerAccountActionGroup">
12+
<annotations>
13+
<description>Goes to the Storefront Customer Dashboard page. Clicks on 'My Downloadable Products'. Validates that the provided Downloadable Product is present and Downloadable link not exist.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="product"/>
17+
</arguments>
18+
19+
<amOnPage url="{{StorefrontCustomerDashboardPage.url}}" stepKey="goToMyAccountPage"/>
20+
<click selector="{{StorefrontCustomerSidebarSection.sidebarTab('My Downloadable Products')}}" stepKey="clickDownloadableProducts"/>
21+
<waitForPageLoad stepKey="waitForDownloadableProductsPageLoad"/>
22+
<seeElement selector="{{StorefrontCustomerDownloadableProductsSection.productName(product.name)}}" stepKey="seeStorefrontDownloadableProductsProductName"/>
23+
<dontSeeElement selector="{{StorefrontCustomerDownloadableProductsSection.downloadableLink}}" stepKey="dontSeeStorefrontMyDownloadableProductsLink"/>
24+
25+
</actionGroup>
26+
</actionGroups>

app/code/Magento/Downloadable/Test/Mftf/Section/StorefrontCustomerDownloadableProductsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="StorefrontCustomerDownloadableProductsSection">
1212
<element name="productName" type="text" selector="//table[@id='my-downloadable-products-table']//strong[contains(@class, 'product-name') and normalize-space(.)='{{productName}}']" parameterized="true"/>
13+
<element name="downloadableLink" type="button" selector="//table[@id='my-downloadable-products-table']//a[contains(@class, 'download')]"/>
1314
</section>
1415
</sections>

0 commit comments

Comments
 (0)