Skip to content

Commit 097e255

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

File tree

1 file changed

+60
-0
lines changed
  • dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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\Category;
9+
10+
use Magento\TestFramework\TestCase\AbstractBackendController;
11+
12+
/**
13+
* Tests for catalog category Add controller
14+
*
15+
* @see \Magento\Catalog\Controller\Adminhtml\Category\Add
16+
*
17+
* @magentoAppArea adminhtml
18+
*/
19+
class AddTest extends AbstractBackendController
20+
{
21+
/**
22+
* @var int
23+
*/
24+
const DEFAULT_ROOT_CATEGORY = 2;
25+
26+
/**
27+
* @inheritdoc
28+
*/
29+
protected function setUp(): void
30+
{
31+
parent::setUp();
32+
33+
$this->getRequest()->setParams([]);
34+
}
35+
36+
37+
/**
38+
* @magentoDbIsolation enabled
39+
*
40+
* @return void
41+
*/
42+
public function testExecuteWithoutParams(): void
43+
{
44+
$this->dispatch('backend/catalog/category/add');
45+
$this->assertRedirect($this->stringContains('catalog/category/index'));
46+
}
47+
48+
/**
49+
* @magentoDbIsolation enabled
50+
*
51+
* @return void
52+
*/
53+
public function testExecuteAsAjax(): void
54+
{
55+
$this->getRequest()->setQueryValue('isAjax', true);
56+
$this->getRequest()->setParam('parent', self::DEFAULT_ROOT_CATEGORY);
57+
$this->dispatch('backend/catalog/category/add');
58+
$this->assertJson($this->getResponse()->getBody());
59+
}
60+
}

0 commit comments

Comments
 (0)