Skip to content

Commit b2e3c30

Browse files
committed
MC-39638: Create automated test for: "Try to add the category without parent category"
1 parent 097e255 commit b2e3c30

File tree

1 file changed

+6
-9
lines changed
  • dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category

1 file changed

+6
-9
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/AddTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Controller\Adminhtml\Category;
99

10+
use Magento\Catalog\Helper\DefaultCategory;
1011
use Magento\TestFramework\TestCase\AbstractBackendController;
1112

1213
/**
@@ -15,13 +16,14 @@
1516
* @see \Magento\Catalog\Controller\Adminhtml\Category\Add
1617
*
1718
* @magentoAppArea adminhtml
19+
* @magentoDbIsolation enabled
1820
*/
1921
class AddTest extends AbstractBackendController
2022
{
2123
/**
22-
* @var int
24+
* @var DefaultCategory
2325
*/
24-
const DEFAULT_ROOT_CATEGORY = 2;
26+
private $defaultCategoryHelper;
2527

2628
/**
2729
* @inheritdoc
@@ -30,13 +32,10 @@ protected function setUp(): void
3032
{
3133
parent::setUp();
3234

33-
$this->getRequest()->setParams([]);
35+
$this->defaultCategoryHelper = $this->_objectManager->get(DefaultCategory::class);
3436
}
3537

36-
3738
/**
38-
* @magentoDbIsolation enabled
39-
*
4039
* @return void
4140
*/
4241
public function testExecuteWithoutParams(): void
@@ -46,14 +45,12 @@ public function testExecuteWithoutParams(): void
4645
}
4746

4847
/**
49-
* @magentoDbIsolation enabled
50-
*
5148
* @return void
5249
*/
5350
public function testExecuteAsAjax(): void
5451
{
5552
$this->getRequest()->setQueryValue('isAjax', true);
56-
$this->getRequest()->setParam('parent', self::DEFAULT_ROOT_CATEGORY);
53+
$this->getRequest()->setParam('parent', $this->defaultCategoryHelper->getId());
5754
$this->dispatch('backend/catalog/category/add');
5855
$this->assertJson($this->getResponse()->getBody());
5956
}

0 commit comments

Comments
 (0)