/** * @magentoDataFixture Magento/Customer/_files/customer_group.php */ public function testSaveActionNewGroupWithoutGroupCode() { $groupId = $this->findGroupIdWithCode(self::CUSTOMER_GROUP_CODE); $originalCode = $this->groupRepository->getById($groupId)->getCode(); $this->getRequest()->setParam('tax_class', self::TAX_CLASS_ID); $this->dispatch('backend/customer/group/save'); $this->assertSessionMessages($this->equalTo(['code is a required field.']), MessageInterface::TYPE_ERROR); $this->assertSessionMessages($this->isEmpty(), MessageInterface::TYPE_SUCCESS); $this->assertEquals($originalCode, $this->groupRepository->getById($groupId)->getCode()); $this->assertRedirect($this->stringStartsWith(self::BASE_CONTROLLER_URL . 'edit/')); $this->assertEquals('', $this->session->getCustomerGroupData()['customer_group_code']); $this->assertEquals(self::TAX_CLASS_ID, $this->session->getCustomerGroupData()['tax_class_id']); }
/** * @magentoDataFixture Magento/Customer/_files/customer_group.php */ public function testSaveActionNewGroupWithoutGroupCode() { /** @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService */ $groupService = Bootstrap::getObjectManager()->get('Magento\\Customer\\Service\\V1\\CustomerGroupServiceInterface'); $groupId = $this->findGroupIdWithCode(self::CUSTOMER_GROUP_CODE); $originalCode = $groupService->getGroup($groupId)->getCode(); $this->getRequest()->setParam('tax_class', self::TAX_CLASS_ID); $this->dispatch('backend/customer/group/save'); $this->assertSessionMessages($this->equalTo(['Invalid value of "" provided for the code field.']), MessageInterface::TYPE_ERROR); $this->assertSessionMessages($this->isEmpty(), MessageInterface::TYPE_SUCCESS); $this->assertEquals($originalCode, $groupService->getGroup($groupId)->getCode()); $this->assertRedirect($this->stringStartsWith(self::BASE_CONTROLLER_URL . 'edit/')); $this->assertEquals('', $this->session->getCustomerGroupData()['customer_group_code']); $this->assertEquals(self::TAX_CLASS_ID, $this->session->getCustomerGroupData()['tax_class_id']); }