Skip to content

Commit 4c200a5

Browse files
committed
MC-41093: [CE/EE] Fatal error during saving Simple Product by admin
1 parent e237a9b commit 4c200a5

File tree

2 files changed

+28
-55
lines changed

2 files changed

+28
-55
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/DeleteCategoryTest.php

Lines changed: 0 additions & 55 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
use Magento\TestFramework\TestCase\AbstractBackendController;
2323
use Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager;
2424
use Magento\Catalog\Model\Product\Type;
25+
use Magento\Catalog\Api\ProductRepositoryInterface;
26+
use Magento\Catalog\Model\Category;
2527

2628
/**
2729
* Test class for Product adminhtml actions
@@ -46,6 +48,11 @@ class ProductTest extends AbstractBackendController
4648
*/
4749
private $resourceModel;
4850

51+
/**
52+
* @var ProductRepositoryInterface
53+
*/
54+
private $productRepository;
55+
4956
/**
5057
* @inheritDoc
5158
*/
@@ -62,6 +69,7 @@ protected function setUp(): void
6269
$this->aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
6370
$this->repositoryFactory = Bootstrap::getObjectManager()->get(ProductRepositoryFactory::class);
6471
$this->resourceModel = Bootstrap::getObjectManager()->get(ProductResource::class);
72+
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
6573
}
6674

6775
/**
@@ -677,4 +685,24 @@ public function testSaveActionWithInvalidUrlKey(array $postData)
677685
);
678686
$this->assertRedirect($this->stringContains('/backend/catalog/product/new'));
679687
}
688+
689+
/**
690+
* @magentoDataFixture Magento/Catalog/_files/category_product.php
691+
* @magentoDbIsolation disabled
692+
* @magentoAppArea adminhtml
693+
*/
694+
public function testSaveProductWithDeletedCategory(): void
695+
{
696+
$category = $this->_objectManager->get(Category::class);
697+
$category->load(333);
698+
$category->delete();
699+
$product = $this->productRepository->get('simple333');
700+
$this->productRepository->save($product);
701+
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
702+
$this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId());
703+
$this->assertSessionMessages(
704+
$this->equalTo([(string)__('You saved the product.')]),
705+
MessageInterface::TYPE_SUCCESS
706+
);
707+
}
680708
}

0 commit comments

Comments
 (0)