From 3143bbb0289d82b0da5a6bccdb779802323d670f Mon Sep 17 00:00:00 2001
From: magento-engcom-team <mikola.malevanec@transoftgroup.com>
Date: Mon, 4 Dec 2017 13:16:08 +0200
Subject: [PATCH] 12110: Missing cascade into attribute set deletion.

---
 .../Model/AttributeSetRepository/RemoveProducts.php       | 7 +++----
 .../Model/AttributeSetRepository/RemoveProductsTest.php   | 8 ++------
 .../Model/AttributeSetRepository/RemoveProductsTest.php   | 2 +-
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/app/code/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProducts.php b/app/code/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProducts.php
index bc6de17f90c..342b703ded0 100644
--- a/app/code/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProducts.php
+++ b/app/code/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProducts.php
@@ -37,21 +37,20 @@ class RemoveProducts
      * Delete related to specific attribute set products, if attribute set was removed successfully.
      *
      * @param AttributeSetRepositoryInterface $subject
-     * @param \Closure $proceed
+     * @param bool $result
      * @param AttributeSetInterface $attributeSet
      * @return bool
      *
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
-    public function aroundDelete(
+    public function afterDelete(
         AttributeSetRepositoryInterface $subject,
-        \Closure $proceed,
+        bool $result,
         AttributeSetInterface $attributeSet
     ) {
         /** @var Collection $productCollection */
         $productCollection = $this->collectionFactory->create();
         $productCollection->addFieldToFilter('attribute_set_id', ['eq' => $attributeSet->getId()]);
-        $result = $proceed($attributeSet);
         $productCollection->delete();
 
         return $result;
diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
index a8eb757646e..712aeba59df 100644
--- a/app/code/Magento/Catalog/Test/Unit/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
@@ -50,7 +50,7 @@ class RemoveProductsTest extends TestCase
     /**
      * Test plugin will delete all related products for given attribute set.
      */
-    public function testAroundDelete()
+    public function testAfterDelete()
     {
         $attributeSetId = '1';
 
@@ -73,10 +73,6 @@ class RemoveProductsTest extends TestCase
             ->disableOriginalConstructor()
             ->getMockForAbstractClass();
 
-        $proceed = function () {
-            return true;
-        };
-
         /** @var AttributeSetInterface|\PHPUnit_Framework_MockObject_MockObject $attributeSet */
         $attributeSet = $this->getMockBuilder(AttributeSetInterface::class)
             ->setMethods(['getId'])
@@ -86,6 +82,6 @@ class RemoveProductsTest extends TestCase
             ->method('getId')
             ->willReturn($attributeSetId);
 
-        $this->testSubject->aroundDelete($attributeSetRepository, $proceed, $attributeSet);
+        self::assertTrue($this->testSubject->afterDelete($attributeSetRepository, true, $attributeSet));
     }
 }
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
index 2896716a01a..4e8eaf70824 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Plugin/Model/AttributeSetRepository/RemoveProductsTest.php
@@ -36,7 +36,7 @@ class RemoveProductsTest extends TestCase
      *
      * @magentoDataFixture Magento/Catalog/_files/attribute_set_with_product.php
      */
-    public function testAroundDelete()
+    public function testAfterDelete()
     {
         $attributeSet = Bootstrap::getObjectManager()->get(Set::class);
         $attributeSet->load('empty_attribute_set', 'attribute_set_name');
-- 
GitLab