Skip to content

Commit

Permalink
Merge forwardport of #11049 to 2.3-develop branch
Browse files Browse the repository at this point in the history
Applied pull request patch https://github.com/magento/magento2/pull/11049.patch (created by @avdb) based on commit(s):
  1. c3ea1f5
  2. 0c0393d
  3. 8660485

Fixed GitHub Issues in 2.3-develop branch:
  - #10697: Product Import: Additional data: Invalid URL key (reported by @Alex-James17)
  • Loading branch information
magento-engcom-team authored Feb 7, 2018
2 parents 0fc86d8 + dbe5fc7 commit f11994a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,12 @@ protected function createCategory($name, $parentId)
$category->setIsActive(true);
$category->setIncludeInMenu(true);
$category->setAttributeSetId($category->getDefaultAttributeSetId());
$category->save();
$this->categoriesCache[$category->getId()] = $category;
try {
$category->save();
$this->categoriesCache[$category->getId()] = $category;
} catch (\Exception $e) {
$this->addFailedCategory($category, $e);
}

return $category->getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ protected function setUp()
. self::CHILD_CATEGORY_ID
));

$childCategory->method('save')->willThrowException(new \Exception());

$parentCategory = $this->getMockBuilder(\Magento\Catalog\Model\Category::class)
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -105,6 +107,17 @@ public function testUpsertCategories()
$this->assertArrayHasKey(self::CHILD_CATEGORY_ID, array_flip($categoryIds));
}

/**
* Tests case when newly created category save throws exception.
*/
public function testCreateCategoryException()
{
$method = new \ReflectionMethod(CategoryProcessor::class, 'createCategory');
$method->setAccessible(true);
$method->invoke($this->categoryProcessor, self::CHILD_CATEGORY_NAME, self::PARENT_CATEGORY_ID);
$this->assertNotEmpty($this->categoryProcessor->getFailedCategories());
}

public function testClearFailedCategories()
{
$dummyFailedCategory = [
Expand Down

0 comments on commit f11994a

Please sign in to comment.