Skip to content

Commit 9e94082

Browse files
authored
Merge pull request #3333 from magento-borg/BugFixPR
[2.3.0-regression] Bug Fixes
2 parents f0fcaa0 + 92d5ad6 commit 9e94082

File tree

10 files changed

+121
-53
lines changed

10 files changed

+121
-53
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
<conditionalClick selector="{{ProductDescriptionWYSIWYGToolbarSection.WysiwygArrow}}" dependentSelector="{{ProductDescriptionWYSIWYGToolbarSection.checkIfWysiwygArrowExpand}}" stepKey="clickWysiwygArrowIfClosed" visible="true"/>
5151
<waitForText userInput="{{ImageFolder.name}}" stepKey="waitForNewFolder1" />
5252
<click userInput="{{ImageFolder.name}}" stepKey="clickOnCreatedFolder1" />
53-
<waitForLoadingMaskToDisappear stepKey="waitForLoading4" />
53+
<waitForLoadingMaskToDisappear stepKey="waitForLoading4" timeout="45"/>
5454
<attachFile selector="{{ProductDescriptionWYSIWYGToolbarSection.BrowseUploadImage}}" userInput="{{ImageUpload1.value}}" stepKey="uploadImage1"/>
55-
<waitForLoadingMaskToDisappear stepKey="waitForFileUpload1" />
55+
<waitForLoadingMaskToDisappear stepKey="waitForFileUpload1" timeout="30"/>
5656
<waitForElementVisible selector="{{ProductDescriptionWYSIWYGToolbarSection.image(ImageUpload1.value)}}" stepKey="waitForUploadImage1" />
5757
<seeElement selector="{{ProductDescriptionWYSIWYGToolbarSection.imageSelected(ImageUpload1.value)}}" stepKey="seeImageSelected1" />
5858
<see selector="{{ProductDescriptionWYSIWYGToolbarSection.DeleteSelectedBtn}}" userInput="Delete Selected" stepKey="seeDeleteBtn1"/>
@@ -63,7 +63,7 @@
6363
<dontSeeElement selector="{{ProductDescriptionWYSIWYGToolbarSection.image(ImageUpload1.value)}}" stepKey="dontSeeImage1" />
6464
<dontSeeElement selector="{{ProductDescriptionWYSIWYGToolbarSection.InsertFile}}" stepKey="dontSeeAddSelectedBtn2" />
6565
<attachFile selector="{{ProductDescriptionWYSIWYGToolbarSection.BrowseUploadImage}}" userInput="{{ImageUpload1.value}}" stepKey="uploadImage2"/>
66-
<waitForLoadingMaskToDisappear stepKey="waitForFileUpload2" />
66+
<waitForLoadingMaskToDisappear stepKey="waitForFileUpload2" timeout="45"/>
6767
<waitForElementVisible selector="{{ProductDescriptionWYSIWYGToolbarSection.image(ImageUpload1.value)}}" stepKey="waitForUploadImage2" />
6868
<click selector="{{ProductDescriptionWYSIWYGToolbarSection.InsertFile}}" stepKey="clickInsertBtn1" />
6969
<waitForElementVisible selector="{{ProductDescriptionWYSIWYGToolbarSection.ImageDescription}}" stepKey="waitForImageDescriptionButton1" />
@@ -75,10 +75,12 @@
7575
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.Browse}}" stepKey="clickBrowse2" />
7676
<waitForElementVisible selector="{{ProductDescriptionWYSIWYGToolbarSection.CancelBtn}}" stepKey="waitForCancelButton2"/>
7777
<see selector="{{ProductShortDescriptionWYSIWYGToolbarSection.CancelBtn}}" userInput="Cancel" stepKey="seeCancelBtn2" />
78+
<waitForLoadingMaskToDisappear stepKey="waitForLoading13" timeout="30"/>
7879
<see selector="{{ProductShortDescriptionWYSIWYGToolbarSection.CreateFolder}}" userInput="Create Folder" stepKey="seeCreateFolderBtn2" />
80+
<waitForLoadingMaskToDisappear stepKey="waitForLoading14" timeout="40"/>
7981
<dontSeeElement selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertFile}}" stepKey="dontSeeAddSelectedBtn3" />
8082
<attachFile selector="{{ProductShortDescriptionWYSIWYGToolbarSection.BrowseUploadImage}}" userInput="{{ImageUpload3.value}}" stepKey="uploadImage3"/>
81-
<waitForLoadingMaskToDisappear stepKey="waitForFileUpload3" />
83+
<waitForLoadingMaskToDisappear stepKey="waitForFileUpload3" timeout="45"/>
8284
<waitForElementVisible selector="{{ProductShortDescriptionWYSIWYGToolbarSection.image(ImageUpload3.value)}}" stepKey="waitForUploadImage3" />
8385
<waitForElement selector="{{ProductShortDescriptionWYSIWYGToolbarSection.DeleteSelectedBtn}}" stepKey="waitForDeletebtn" />
8486
<see selector="{{ProductShortDescriptionWYSIWYGToolbarSection.DeleteSelectedBtn}}" userInput="Delete Selected" stepKey="seeDeleteBtn2"/>
@@ -87,7 +89,7 @@
8789
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmDelete2" />
8890
<dontSeeElement selector="{{ProductDescriptionWYSIWYGToolbarSection.InsertFile}}" stepKey="dontSeeAddSelectedBtn4" />
8991
<attachFile selector="{{ProductShortDescriptionWYSIWYGToolbarSection.BrowseUploadImage}}" userInput="{{ImageUpload3.value}}" stepKey="uploadImage4"/>
90-
<waitForLoadingMaskToDisappear stepKey="waitForFileUpload4" />
92+
<waitForLoadingMaskToDisappear stepKey="waitForFileUpload4" timeout="45"/>
9193
<waitForElementVisible selector="{{ProductShortDescriptionWYSIWYGToolbarSection.image(ImageUpload3.value)}}" stepKey="waitForUploadImage4" />
9294
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertFile}}" stepKey="clickInsertBtn" />
9395
<waitForLoadingMaskToDisappear stepKey="waitForLoading11" />

app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public function __construct(
6666
}
6767

6868
/**
69+
* Initialize categories
70+
*
6971
* @return $this
7072
*/
7173
protected function initCategories()
@@ -104,7 +106,6 @@ protected function initCategories()
104106
*
105107
* @param string $name
106108
* @param int $parentId
107-
*
108109
* @return int
109110
*/
110111
protected function createCategory($name, $parentId)
@@ -120,21 +121,15 @@ protected function createCategory($name, $parentId)
120121
$category->setIsActive(true);
121122
$category->setIncludeInMenu(true);
122123
$category->setAttributeSetId($category->getDefaultAttributeSetId());
123-
try {
124-
$category->save();
125-
$this->categoriesCache[$category->getId()] = $category;
126-
} catch (\Exception $e) {
127-
$this->addFailedCategory($category, $e);
128-
}
129-
124+
$category->save();
125+
$this->categoriesCache[$category->getId()] = $category;
130126
return $category->getId();
131127
}
132128

133129
/**
134130
* Returns ID of category by string path creating nonexistent ones.
135131
*
136132
* @param string $categoryPath
137-
*
138133
* @return int
139134
*/
140135
protected function upsertCategory($categoryPath)
@@ -165,7 +160,6 @@ protected function upsertCategory($categoryPath)
165160
*
166161
* @param string $categoriesString
167162
* @param string $categoriesSeparator
168-
*
169163
* @return array
170164
*/
171165
public function upsertCategories($categoriesString, $categoriesSeparator)

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,49 @@ class CategoryProcessorTest extends \PHPUnit\Framework\TestCase
3434
*/
3535
protected $product;
3636

37+
/**
38+
* @var \Magento\Catalog\Model\Category
39+
*/
40+
private $childCategory;
41+
42+
/**
43+
* \Magento\Catalog\Model\Category
44+
*/
45+
private $parentCategory;
46+
3747
protected function setUp()
3848
{
3949
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
4050
$this->objectManagerHelper = new ObjectManagerHelper($this);
4151

42-
$childCategory = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
52+
$this->childCategory = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
4353
->disableOriginalConstructor()
4454
->getMock();
45-
$childCategory->method('getId')->will($this->returnValue(self::CHILD_CATEGORY_ID));
46-
$childCategory->method('getName')->will($this->returnValue(self::CHILD_CATEGORY_NAME));
47-
$childCategory->method('getPath')->will($this->returnValue(
55+
$this->childCategory->method('getId')->will($this->returnValue(self::CHILD_CATEGORY_ID));
56+
$this->childCategory->method('getName')->will($this->returnValue(self::CHILD_CATEGORY_NAME));
57+
$this->childCategory->method('getPath')->will($this->returnValue(
4858
self::PARENT_CATEGORY_ID . CategoryProcessor::DELIMITER_CATEGORY
4959
. self::CHILD_CATEGORY_ID
5060
));
5161

52-
$childCategory->method('save')->willThrowException(new \Exception());
53-
54-
$parentCategory = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
62+
$this->parentCategory = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
5563
->disableOriginalConstructor()
5664
->getMock();
57-
$parentCategory->method('getId')->will($this->returnValue(self::PARENT_CATEGORY_ID));
58-
$parentCategory->method('getName')->will($this->returnValue('Parent'));
59-
$parentCategory->method('getPath')->will($this->returnValue(self::PARENT_CATEGORY_ID));
65+
$this->parentCategory->method('getId')->will($this->returnValue(self::PARENT_CATEGORY_ID));
66+
$this->parentCategory->method('getName')->will($this->returnValue('Parent'));
67+
$this->parentCategory->method('getPath')->will($this->returnValue(self::PARENT_CATEGORY_ID));
6068

6169
$categoryCollection =
6270
$this->objectManagerHelper->getCollectionMock(
6371
\Magento\Catalog\Model\ResourceModel\Category\Collection::class,
6472
[
65-
self::PARENT_CATEGORY_ID => $parentCategory,
66-
self::CHILD_CATEGORY_ID => $childCategory,
73+
self::PARENT_CATEGORY_ID => $this->parentCategory,
74+
self::CHILD_CATEGORY_ID => $this->childCategory,
6775
]
6876
);
6977
$map = [
70-
[self::PARENT_CATEGORY_ID, $parentCategory],
71-
[self::CHILD_CATEGORY_ID, $childCategory],
78+
[self::PARENT_CATEGORY_ID, $this->parentCategory],
79+
[self::CHILD_CATEGORY_ID, $this->childCategory],
7280
];
7381
$categoryCollection->expects($this->any())
7482
->method('getItemById')
@@ -91,7 +99,7 @@ protected function setUp()
9199

92100
$categoryFactory = $this->createPartialMock(\Magento\Catalog\Model\CategoryFactory::class, ['create']);
93101

94-
$categoryFactory->method('create')->will($this->returnValue($childCategory));
102+
$categoryFactory->method('create')->will($this->returnValue($this->childCategory));
95103

96104
$this->categoryProcessor =
97105
new \Magento\CatalogImportExport\Model\Import\Product\CategoryProcessor(
@@ -110,11 +118,13 @@ public function testUpsertCategories()
110118
/**
111119
* Tests case when newly created category save throws exception.
112120
*/
113-
public function testCreateCategoryException()
121+
public function testUpsertCategoriesWithAlreadyExistsException()
114122
{
115-
$method = new \ReflectionMethod(CategoryProcessor::class, 'createCategory');
116-
$method->setAccessible(true);
117-
$method->invoke($this->categoryProcessor, self::CHILD_CATEGORY_NAME, self::PARENT_CATEGORY_ID);
123+
$exception = new \Magento\Framework\Exception\AlreadyExistsException();
124+
$categoriesSeparator = '/';
125+
$categoryName = 'Exception Category';
126+
$this->childCategory->method('save')->willThrowException($exception);
127+
$this->categoryProcessor->upsertCategories($categoryName, $categoriesSeparator);
118128
$this->assertNotEmpty($this->categoryProcessor->getFailedCategories());
119129
}
120130

app/code/Magento/UrlRewrite/Model/Exception/UrlAlreadyExistsException.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
use Magento\Framework\Phrase;
99

1010
/**
11+
* Specific exception for URL key already exists
12+
*
1113
* @api
1214
* @since 100.2.0
1315
*/
14-
class UrlAlreadyExistsException extends \Magento\Framework\Exception\LocalizedException
16+
class UrlAlreadyExistsException extends \Magento\Framework\Exception\AlreadyExistsException
1517
{
1618
/**
1719
* @var array
@@ -34,6 +36,8 @@ public function __construct(Phrase $phrase = null, \Exception $cause = null, $co
3436
}
3537

3638
/**
39+
* Get URLs
40+
*
3741
* @return array
3842
* @since 100.2.0
3943
*/

dev/tests/integration/testsuite/Magento/Catalog/_files/category_duplicates.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
)->setParentId(
1616
2
1717
)->setPath(
18-
'1/2'
18+
'1/2/444'
1919
)->setLevel(
2020
'2'
2121
)->setDefaultSortBy(
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Framework\Exception\NoSuchEntityException;
9+
10+
/** @var \Magento\Framework\ObjectManagerInterface $objectManager */
11+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
12+
13+
/** @var \Magento\Framework\Registry $registry */
14+
$registry = $objectManager->get(\Magento\Framework\Registry::class);
15+
16+
$registry->unregister('isSecureArea');
17+
$registry->register('isSecureArea', true);
18+
19+
/** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $collection */
20+
$categoryCollection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
21+
$categoryCollection
22+
->addAttributeToFilter('level', 2)
23+
->load()
24+
->delete();
25+
26+
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
27+
$productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
28+
try {
29+
$product = $productRepository->get('simple3', false, null, true);
30+
$productRepository->delete($product);
31+
} catch (NoSuchEntityException $e) {
32+
}
33+
34+
$registry->unregister('isSecureArea');
35+
$registry->register('isSecureArea', false);

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,12 +1292,10 @@ public function categoryTestDataProvider()
12921292
* @magentoAppArea adminhtml
12931293
* @magentoDbIsolation disabled
12941294
* @magentoAppIsolation enabled
1295-
* @magentoDataFixture Magento/Catalog/_files/category_duplicates.php
1295+
* @magentoDataFixture Magento/CatalogImportExport/_files/update_category_duplicates.php
12961296
*/
12971297
public function testProductDuplicateCategories()
12981298
{
1299-
$this->markTestSkipped('Due to MAGETWO-48956');
1300-
13011299
$csvFixture = 'products_duplicate_category.csv';
13021300
// import data from CSV file
13031301
$pathToFile = __DIR__ . '/_files/' . $csvFixture;
@@ -1322,19 +1320,6 @@ public function testProductDuplicateCategories()
13221320

13231321
$this->assertTrue($errors->getErrorsCount() === 0);
13241322

1325-
/** @var \Magento\Catalog\Model\Category $category */
1326-
$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
1327-
\Magento\Catalog\Model\Category::class
1328-
);
1329-
1330-
$category->load(444);
1331-
1332-
$this->assertTrue($category !== null);
1333-
1334-
$category->setName(
1335-
'Category 2-updated'
1336-
)->save();
1337-
13381323
$this->_model->importData();
13391324

13401325
$errorProcessor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
require dirname(dirname(__DIR__)) . '/Catalog/_files/category_duplicates.php';
9+
10+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
11+
12+
/** @var \Magento\Catalog\Model\Category $category */
13+
$categoryModel = $objectManager->create(\Magento\Catalog\Model\Category::class);
14+
$categoryModel->setStoreId(\Magento\Store\Model\Store::DEFAULT_STORE_ID);
15+
16+
$categoryModel->load(444)
17+
->setName('Category 2-updated')
18+
->save();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
require dirname(dirname(__DIR__)) . '/Catalog/_files/category_duplicates_rollback.php';
9+
10+
//Delete products created in CSV import
11+
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
12+
$productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
13+
$csvProductSkus = ['simple1', 'simple2', 'simple3'];
14+
foreach ($csvProductSkus as $sku) {
15+
try {
16+
$product = $productRepository->get($sku, false, null, true);
17+
$productRepository->delete($product);
18+
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
19+
}
20+
}

lib/web/css/source/lib/_forms.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@
288288
.lib-form-element-input(@_type: select);
289289
}
290290

291-
select[multiple="multiple"] {
291+
select[multiple] {
292292
.lib-css(height, auto);
293293
background-image: none;
294294
}

0 commit comments

Comments
 (0)