Skip to content

Commit fd4a421

Browse files
committed
MC-39636: Create automated test for: "Try to save the category without filling the required fields."
1 parent 1c3837c commit fd4a421

File tree

1 file changed

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

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
use Magento\Catalog\Api\Data\CategoryInterface;
1212
use Magento\Catalog\Model\Category;
1313
use Magento\Cms\Api\GetBlockByIdentifierInterface;
14+
use Magento\Framework\App\Request\Http as HttpRequest;
1415
use Magento\Framework\Exception\NoSuchEntityException;
16+
use Magento\Framework\Message\MessageInterface;
1517
use Magento\Store\Model\StoreManagerInterface;
1618

1719
/**
@@ -87,4 +89,21 @@ public function testCreateCategoryWithCmsBlock(): void
8789
$category = $this->categoryRepository->get($this->createdCategoryId);
8890
$this->assertEquals($blockId, $category->getLandingPage());
8991
}
92+
93+
/**
94+
* @return void
95+
*/
96+
public function testTryToCreateCategoryWithEmptyValues(): void
97+
{
98+
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
99+
$this->getRequest()->setPostValue([
100+
CategoryInterface::KEY_NAME => 'test',
101+
CategoryInterface::KEY_IS_ACTIVE => 1,
102+
'use_config' => [],
103+
'return_session_messages_only' => false,
104+
]);
105+
$this->dispatch('backend/catalog/category/save');
106+
$message = 'The "Available Product Listing Sort By" attribute is required. Enter and try again.';
107+
$this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_ERROR);
108+
}
90109
}

0 commit comments

Comments
 (0)