Skip to content

Commit 67ee036

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop-com-pr12' into 2.4-develop-com-pr12
2 parents 3eb9a2d + 89b6c2a commit 67ee036

File tree

30 files changed

+2524
-150
lines changed

30 files changed

+2524
-150
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
namespace Magento\Bundle\Controller\Adminhtml\Bundle\Product\Edit;
9+
10+
use Magento\Catalog\Controller\Adminhtml\Product\MassDeleteTest as CatalogMassDeleteTest;
11+
12+
/**
13+
* Test for mass bundle product deleting.
14+
*
15+
* @see \Magento\Bundle\Controller\Adminhtml\Bundle\Product\Edit\MassDelete
16+
* @magentoAppArea adminhtml
17+
* @magentoDbIsolation enabled
18+
*/
19+
class MassDeleteTest extends CatalogMassDeleteTest
20+
{
21+
/**
22+
* @magentoDataFixture Magento/Bundle/_files/bundle_product_checkbox_required_option.php
23+
*
24+
* @return void
25+
*/
26+
public function testDeleteBundleProductViaMassAction(): void
27+
{
28+
$product = $this->productRepository->get('bundle-product-checkbox-required-option');
29+
$this->dispatchMassDeleteAction([$product->getId()]);
30+
$this->assertSuccessfulDeleteProducts(1);
31+
}
32+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+
namespace Magento\Catalog\Controller\Adminhtml\Product;
9+
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Framework\App\Request\Http as HttpRequest;
12+
use Magento\Framework\Message\MessageInterface;
13+
use Magento\TestFramework\TestCase\AbstractBackendController;
14+
15+
/**
16+
* Test for mass product deleting.
17+
*
18+
* @see \Magento\Catalog\Controller\Adminhtml\Product\MassDelete
19+
* @magentoAppArea adminhtml
20+
* @magentoDbIsolation enabled
21+
*/
22+
class MassDeleteTest extends AbstractBackendController
23+
{
24+
/** @var ProductRepositoryInterface */
25+
protected $productRepository;
26+
27+
/**
28+
* @inheritdoc
29+
*/
30+
protected function setUp(): void
31+
{
32+
parent::setUp();
33+
34+
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
35+
$this->productRepository->cleanCache();
36+
}
37+
38+
/**
39+
* @magentoDataFixture Magento/Catalog/_files/multiple_products.php
40+
*
41+
* @return void
42+
*/
43+
public function testDeleteSimpleProductViaMassAction(): void
44+
{
45+
$productIds = [10, 11, 12];
46+
$this->dispatchMassDeleteAction($productIds);
47+
$this->assertSuccessfulDeleteProducts(count($productIds));
48+
}
49+
50+
/**
51+
* @return void
52+
*/
53+
public function testDeleteNotExistingProductViaMassAction(): void
54+
{
55+
$this->dispatchMassDeleteAction([989]);
56+
$this->assertSessionMessages($this->isEmpty(), MessageInterface::TYPE_ERROR);
57+
$this->assertRedirect($this->stringContains('backend/catalog/product/index'));
58+
}
59+
60+
/**
61+
* @return void
62+
*/
63+
public function testMassDeleteWithoutProductIds(): void
64+
{
65+
$this->markTestSkipped('Test is blocked by issue MC-34495');
66+
$this->dispatchMassDeleteAction();
67+
$this->assertSessionMessages(
68+
$this->equalTo('An item needs to be selected. Select and try again.'),
69+
MessageInterface::TYPE_ERROR
70+
);
71+
$this->assertRedirect($this->stringContains('backend/catalog/product/index'));
72+
}
73+
74+
/**
75+
* Assert successful delete products.
76+
*
77+
* @param int $productCount
78+
* @return void
79+
*/
80+
protected function assertSuccessfulDeleteProducts(int $productCount): void
81+
{
82+
$this->assertSessionMessages(
83+
$this->equalTo([(string)__('A total of %1 record(s) have been deleted.', $productCount)]),
84+
MessageInterface::TYPE_SUCCESS
85+
);
86+
$this->assertRedirect($this->stringContains('backend/catalog/product/index'));
87+
}
88+
89+
/**
90+
* Dispatch mass delete action.
91+
*
92+
* @param array $productIds
93+
* @return void
94+
*/
95+
protected function dispatchMassDeleteAction(array $productIds = []): void
96+
{
97+
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
98+
$this->getRequest()->setParams(['selected' => $productIds, 'namespace' => 'product_listing']);
99+
$this->dispatch('backend/catalog/product/massDelete/');
100+
}
101+
}

0 commit comments

Comments
 (0)