diff --git a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/BackButton.php b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/BackButton.php
new file mode 100644
index 0000000000000..3804e6a6688b3
--- /dev/null
+++ b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/BackButton.php
@@ -0,0 +1,37 @@
+ __('Back'),
+ 'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()),
+ 'class' => 'back',
+ 'sort_order' => 10
+ ];
+ }
+
+ /**
+ * Get URL for back (reset) button
+ *
+ * @return string
+ */
+ public function getBackUrl()
+ {
+ return $this->getUrl('*/*/');
+ }
+}
diff --git a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/DeleteButton.php b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/DeleteButton.php
new file mode 100644
index 0000000000000..269697b343ecf
--- /dev/null
+++ b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/DeleteButton.php
@@ -0,0 +1,65 @@
+groupManagement = $groupManagement;
+ }
+
+ /**
+ * @return array
+ */
+ public function getButtonData()
+ {
+ $groupId = $this->getGroupId();
+ $canModify = $groupId && !$this->groupManagement->isReadonly($this->getGroupId());
+ $data = [];
+ if ($canModify) {
+ $data = [
+ 'label' => __('Delete Customer Group'),
+ 'class' => 'delete',
+ 'on_click' => 'deleteConfirm(\'' . __(
+ 'Are you sure you want to do this?'
+ ) . '\', \'' . $this->getDeleteUrl() . '\')',
+ 'sort_order' => 20,
+ ];
+ }
+
+ return $data;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDeleteUrl()
+ {
+ return $this->getUrl('*/*/delete', ['id' => $this->getGroupId()]);
+ }
+}
diff --git a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/GenericButton.php b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/GenericButton.php
new file mode 100644
index 0000000000000..0c94bde38fc34
--- /dev/null
+++ b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/GenericButton.php
@@ -0,0 +1,64 @@
+urlBuilder = $context->getUrlBuilder();
+ $this->registry = $registry;
+ }
+
+ /**
+ * Return the group Id.
+ *
+ * @return int|null
+ */
+ public function getGroupId()
+ {
+ return $this->registry->registry(RegistryConstants::CURRENT_GROUP_ID);
+ }
+
+ /**
+ * Generate url by route and parameters
+ *
+ * @param string $route
+ * @param array $params
+ * @return string
+ */
+ public function getUrl($route = '', $params = [])
+ {
+ return $this->urlBuilder->getUrl($route, $params);
+ }
+}
diff --git a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/ResetButton.php b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/ResetButton.php
new file mode 100644
index 0000000000000..fad72a6577603
--- /dev/null
+++ b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/ResetButton.php
@@ -0,0 +1,27 @@
+ __('Reset'),
+ 'class' => 'reset',
+ 'on_click' => 'location.reload();',
+ 'sort_order' => 30
+ ];
+ }
+}
diff --git a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/SaveAndContinueButton.php b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/SaveAndContinueButton.php
new file mode 100644
index 0000000000000..d062d3f5464ab
--- /dev/null
+++ b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/SaveAndContinueButton.php
@@ -0,0 +1,31 @@
+ __('Save and Continue Edit'),
+ 'class' => 'save',
+ 'data_attribute' => [
+ 'mage-init' => [
+ 'button' => ['event' => 'saveAndContinueEdit'],
+ ],
+ ],
+ 'sort_order' => 80,
+ ];
+ }
+}
diff --git a/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/SaveButton.php b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/SaveButton.php
new file mode 100644
index 0000000000000..d11302b93c499
--- /dev/null
+++ b/app/code/Magento/Customer/Block/Adminhtml/Group/Edit/SaveButton.php
@@ -0,0 +1,30 @@
+ __('Save Customer Group'),
+ 'class' => 'save primary',
+ 'data_attribute' => [
+ 'mage-init' => ['button' => ['event' => 'save']],
+ 'form-role' => 'save',
+ ],
+ 'sort_order' => 90,
+ ];
+ }
+}
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Group/NewAction.php b/app/code/Magento/Customer/Controller/Adminhtml/Group/NewAction.php
index 2c230cd0b3f7b..82650a37ac6a4 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/Group/NewAction.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Group/NewAction.php
@@ -49,9 +49,6 @@ public function execute()
);
}
- $resultPage->getLayout()->addBlock(\Magento\Customer\Block\Adminhtml\Group\Edit::class, 'group', 'content')
- ->setEditMode((bool)$groupId);
-
return $resultPage;
}
}
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Group/Save.php b/app/code/Magento/Customer/Controller/Adminhtml/Group/Save.php
index 936d9cdbc1704..f978044f69634 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/Group/Save.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Group/Save.php
@@ -69,16 +69,17 @@ protected function storeCustomerGroupDataToSession($customerGroupData)
*/
public function execute()
{
- $taxClass = (int)$this->getRequest()->getParam('tax_class');
+ $taxClass = (int)$this->getRequest()->getParam('tax_class_id');
/** @var \Magento\Customer\Api\Data\GroupInterface $customerGroup */
$customerGroup = null;
if ($taxClass) {
- $id = $this->getRequest()->getParam('id');
+ $id = $this->getRequest()->getParam('customer_group_id');
+ /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
try {
- $customerGroupCode = (string)$this->getRequest()->getParam('code');
- if ($id !== null) {
+ $customerGroupCode = (string)$this->getRequest()->getParam('customer_group_code');
+ if ($id !== null && $id !== '') {
$customerGroup = $this->groupRepository->getById((int)$id);
$customerGroupCode = $customerGroupCode ?: $customerGroup->getCode();
} else {
@@ -87,10 +88,14 @@ public function execute()
$customerGroup->setCode(!empty($customerGroupCode) ? $customerGroupCode : null);
$customerGroup->setTaxClassId($taxClass);
- $this->groupRepository->save($customerGroup);
+ $customerGroup = $this->groupRepository->save($customerGroup);
$this->messageManager->addSuccess(__('You saved the customer group.'));
- $resultRedirect->setPath('customer/group');
+ if ($this->getRequest()->getParam('back')) {
+ $resultRedirect->setPath('customer/group/edit', ['id' => $customerGroup->getId()]);
+ } else {
+ $resultRedirect->setPath('customer/group');
+ }
} catch (\Exception $e) {
$this->messageManager->addError($e->getMessage());
if ($customerGroup != null) {
diff --git a/app/code/Magento/Customer/Model/Group/DataProvider.php b/app/code/Magento/Customer/Model/Group/DataProvider.php
new file mode 100644
index 0000000000000..0a7fa94729cad
--- /dev/null
+++ b/app/code/Magento/Customer/Model/Group/DataProvider.php
@@ -0,0 +1,125 @@
+collection = $groupCollectionFactory->create();
+ $this->registry = $registry;
+ $this->groupRepository = $groupRepository;
+ $this->taxHelper = $taxHelper;
+ }
+
+ /**
+ * Get data
+ *
+ * @return array
+ */
+ public function getData()
+ {
+ if (isset($this->loadedData)) {
+ return $this->loadedData;
+ }
+ $items = $this->collection->getItems();
+ /** @var \Magento\Customer\Model\Group $customerGroup */
+ foreach ($items as $customerGroup) {
+ $this->loadedData[$customerGroup->getId()] = $customerGroup->getData();
+ }
+
+ return $this->loadedData;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getMeta()
+ {
+ $meta = parent::getMeta();
+
+ $meta['general']['children']['customer_group_code']['arguments']['data']['config'] = [
+ 'notice' => __('Maximum length must be less then %1 characters.', GroupManagement::GROUP_CODE_MAX_LENGTH),
+ 'validation' => [
+ 'max_text_length' => GroupManagement::GROUP_CODE_MAX_LENGTH,
+ ]
+ ];
+
+ $groupId = $this->registry->registry(RegistryConstants::CURRENT_GROUP_ID);
+
+ if ($groupId === null) {
+ $meta['general']['children']['tax_class_id']['arguments']['data']['config']['default'] =
+ $this->taxHelper->getDefaultCustomerTaxClass();
+ return $meta;
+ }
+
+ $customerGroup = $this->groupRepository->getById($groupId);
+
+ if ($customerGroup->getId() == GroupManagement::NOT_LOGGED_IN_ID) {
+ $meta['general']['children']['customer_group_code']['arguments']['data']['config']['disabled'] = true;
+ }
+
+ return $meta;
+ }
+}
diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/DeleteButtonTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/DeleteButtonTest.php
new file mode 100644
index 0000000000000..5a03cfb29e046
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/DeleteButtonTest.php
@@ -0,0 +1,124 @@
+urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class);
+ $this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
+ $this->groupManagement = $this->createMock(\Magento\Customer\Api\GroupManagementInterface::class);
+ $contextMock = $this->createMock(\Magento\Backend\Block\Widget\Context::class);
+
+ $contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($this->urlBuilderMock);
+
+ $this->model = (new ObjectManager($this))->getObject(
+ \Magento\Customer\Block\Adminhtml\Group\Edit\DeleteButton::class,
+ [
+ 'context' => $contextMock,
+ 'registry' => $this->registryMock,
+ 'groupManagement' => $this->groupManagement
+ ]
+ );
+ }
+
+ /**
+ * @return void
+ * @covers \Magento\Customer\Block\Adminhtml\Group\Edit\DeleteButton::getButtonData
+ */
+ public function testGetButtonData()
+ {
+ $groupId = 22;
+ $deleteUrl = 'http://example.com/customer/group/' . $groupId;
+ $this->registryMock->expects($this->any())
+ ->method('registry')
+ ->with(RegistryConstants::CURRENT_GROUP_ID)
+ ->willReturn($groupId);
+ $this->urlBuilderMock->expects($this->once())
+ ->method('getUrl')
+ ->with('*/*/delete', ['id' => $groupId])
+ ->willReturn($deleteUrl);
+
+ $this->groupManagement->expects($this->once())
+ ->method('isReadonly')
+ ->with($groupId)
+ ->willReturn(false);
+
+ $data = [
+ 'label' => __('Delete Customer Group'),
+ 'class' => 'delete',
+ 'on_click' => 'deleteConfirm(\'' . __(
+ 'Are you sure you want to do this?'
+ ) . '\', \'' . $deleteUrl . '\')',
+ 'sort_order' => 20,
+ ];
+
+ $this->assertEquals($data, $this->model->getButtonData());
+ }
+
+ /**
+ * @return void
+ * @covers \Magento\Customer\Block\Adminhtml\Group\Edit\DeleteButton::getButtonData
+ */
+ public function testGetButtonDataWithoutGroup()
+ {
+ $this->assertEquals([], $this->model->getButtonData());
+ }
+
+ /**
+ * @return void
+ * @covers \Magento\Customer\Block\Adminhtml\Group\Edit\DeleteButton::getButtonData
+ */
+ public function testGetButtonDataWithReadonlyGroup()
+ {
+ $groupId = 22;
+ $this->registryMock->expects($this->any())
+ ->method('registry')
+ ->with(RegistryConstants::CURRENT_GROUP_ID)
+ ->willReturn($groupId);
+
+ $this->groupManagement->expects($this->once())
+ ->method('isReadonly')
+ ->with($groupId)
+ ->willReturn(true);
+
+ $this->assertEquals([], $this->model->getButtonData());
+ }
+}
diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/GenericButtonTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/GenericButtonTest.php
new file mode 100644
index 0000000000000..5ec1fbc635a5d
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/GenericButtonTest.php
@@ -0,0 +1,96 @@
+urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class);
+ $this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
+ $contextMock = $this->createMock(\Magento\Backend\Block\Widget\Context::class);
+
+ $contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($this->urlBuilderMock);
+
+ $this->model = (new ObjectManager($this))->getObject(
+ \Magento\Customer\Block\Adminhtml\Group\Edit\GenericButton::class,
+ [
+ 'context' => $contextMock,
+ 'registry' => $this->registryMock
+ ]
+ );
+ }
+
+ /**
+ * @return void
+ * @covers \Magento\Customer\Block\Adminhtml\Group\Edit\GenericButton::getUrl
+ */
+ public function testGetUrl()
+ {
+ $url = "http://example.com/customer/group/";
+ $route = 'button';
+ $params = ['unit' => 'test'];
+
+ $this->urlBuilderMock->expects($this->once())
+ ->method('getUrl')
+ ->with($route, $params)
+ ->willReturn($url);
+
+ $this->assertEquals($url, $this->model->getUrl($route, $params));
+ }
+
+ /**
+ * @return void
+ * @covers \Magento\Customer\Block\Adminhtml\Group\Edit\GenericButton::getGroupId
+ */
+ public function testGetGroupId()
+ {
+ $groupId = 22;
+ $this->registryMock->expects($this->once())
+ ->method('registry')
+ ->with(RegistryConstants::CURRENT_GROUP_ID)
+ ->willReturn($groupId);
+
+ $this->assertEquals($groupId, $this->model->getGroupId());
+ }
+
+ /**
+ * @return void
+ * @covers \Magento\Customer\Block\Adminhtml\Group\Edit\GenericButton::getGroupId
+ */
+ public function testGetGroupIdWithoutGroup()
+ {
+ $this->assertNull($this->model->getGroupId());
+ }
+}
diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/ResetButtonTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/ResetButtonTest.php
new file mode 100644
index 0000000000000..8fc74156c0180
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/ResetButtonTest.php
@@ -0,0 +1,70 @@
+urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class);
+ $this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
+ $contextMock = $this->createMock(\Magento\Backend\Block\Widget\Context::class);
+
+ $contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($this->urlBuilderMock);
+
+ $this->model = (new ObjectManager($this))->getObject(
+ \Magento\Customer\Block\Adminhtml\Group\Edit\ResetButton::class,
+ [
+ 'context' => $contextMock,
+ 'registry' => $this->registryMock
+ ]
+ );
+ }
+
+ /**
+ * @return void
+ * @covers \Magento\Customer\Block\Adminhtml\Group\Edit\ResetButton::getButtonData
+ */
+ public function testGetButtonData()
+ {
+ $data = [
+ 'label' => __('Reset'),
+ 'class' => 'reset',
+ 'on_click' => 'location.reload();',
+ 'sort_order' => 30,
+ ];
+
+ $this->assertEquals($data, $this->model->getButtonData());
+ }
+}
diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/SaveAndContinueButtonTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/SaveAndContinueButtonTest.php
new file mode 100644
index 0000000000000..28fcbb8da99ab
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/SaveAndContinueButtonTest.php
@@ -0,0 +1,74 @@
+urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class);
+ $this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
+ $contextMock = $this->createMock(\Magento\Backend\Block\Widget\Context::class);
+
+ $contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($this->urlBuilderMock);
+
+ $this->model = (new ObjectManager($this))->getObject(
+ \Magento\Customer\Block\Adminhtml\Group\Edit\SaveAndContinueButton::class,
+ [
+ 'context' => $contextMock,
+ 'registry' => $this->registryMock
+ ]
+ );
+ }
+
+ /**
+ * @return void
+ * @covers \Magento\Customer\Block\Adminhtml\Group\Edit\SaveAndContinueButton::getButtonData
+ */
+ public function testGetButtonData()
+ {
+ $data = [
+ 'label' => __('Save and Continue Edit'),
+ 'class' => 'save',
+ 'data_attribute' => [
+ 'mage-init' => [
+ 'button' => ['event' => 'saveAndContinueEdit'],
+ ],
+ ],
+ 'sort_order' => 80,
+ ];
+
+ $this->assertEquals($data, $this->model->getButtonData());
+ }
+}
diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/SaveButtonTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/SaveButtonTest.php
new file mode 100644
index 0000000000000..b9706af678561
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Group/Edit/SaveButtonTest.php
@@ -0,0 +1,73 @@
+urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class);
+ $this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
+ $contextMock = $this->createMock(\Magento\Backend\Block\Widget\Context::class);
+
+ $contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($this->urlBuilderMock);
+
+ $this->model = (new ObjectManager($this))->getObject(
+ \Magento\Customer\Block\Adminhtml\Group\Edit\SaveButton::class,
+ [
+ 'context' => $contextMock,
+ 'registry' => $this->registryMock
+ ]
+ );
+ }
+
+ /**
+ * @return void
+ * @covers \Magento\Customer\Block\Adminhtml\Group\Edit\SaveButton::getButtonData
+ */
+ public function testGetButtonData()
+ {
+ $data = [
+ 'label' => __('Save Customer Group'),
+ 'class' => 'save primary',
+ 'data_attribute' => [
+ 'mage-init' => ['button' => ['event' => 'save']],
+ 'form-role' => 'save',
+ ],
+ 'sort_order' => 90,
+ ];
+
+ $this->assertEquals($data, $this->model->getButtonData());
+ }
+}
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Group/SaveTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Group/SaveTest.php
index 5f7064d5b124b..8bf27a0478276 100644
--- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Group/SaveTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Group/SaveTest.php
@@ -139,12 +139,13 @@ public function testExecuteWithTaxClassAndException()
$groupId = 0;
$code = 'NOT LOGGED IN';
- $this->request->expects($this->exactly(3))
+ $this->request->expects($this->exactly(4))
->method('getParam')
->withConsecutive(
- ['tax_class'],
- ['id'],
- ['code']
+ ['tax_class_id'],
+ ['customer_group_id'],
+ ['customer_group_code'],
+ ['back']
)
->willReturnOnConsecutiveCalls($taxClass, $groupId, null);
$this->resultRedirectFactory->expects($this->once())
@@ -165,7 +166,8 @@ public function testExecuteWithTaxClassAndException()
->with($taxClass);
$this->groupRepositoryMock->expects($this->once())
->method('save')
- ->with($this->group);
+ ->with($this->group)
+ ->willReturn($this->group);
$this->messageManager->expects($this->once())
->method('addSuccess')
->with(__('You saved the customer group.'));
@@ -194,7 +196,7 @@ public function testExecuteWithoutTaxClass()
{
$this->request->expects($this->once())
->method('getParam')
- ->with('tax_class')
+ ->with('tax_class_id')
->willReturn(null);
$this->forwardFactoryMock->expects($this->once())
->method('create')
diff --git a/app/code/Magento/Customer/Test/Unit/Model/Group/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Group/DataProviderTest.php
new file mode 100644
index 0000000000000..ef524749ca5d7
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Unit/Model/Group/DataProviderTest.php
@@ -0,0 +1,145 @@
+collectionFactoryMock = $this->createPartialMock(
+ \Magento\Customer\Model\ResourceModel\Group\CollectionFactory::class,
+ ['create']
+ );
+
+ $this->collectionMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Group\Collection::class);
+ $this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($this->collectionMock);
+ $this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
+ $this->groupRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\GroupRepositoryInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->taxHelperMock = $this->getMockBuilder(\Magento\Tax\Helper\Data::class)
+ ->setMethods(['getDefaultCustomerTaxClass'])
+ ->disableOriginalConstructor()
+ ->getMock();
+ }
+
+ /**
+ * @return void
+ * @covers \Magento\Customer\Model\Group\DataProvider::getData
+ */
+ public function testGetData()
+ {
+ $groupId = 22;
+ $groupData = ['customer_group_code' => 'Customer Group Code', 'tax_class_id' => 1];
+
+ $groupMock = $this->createPartialMock(\Magento\Customer\Model\Group::class, [
+ 'load',
+ 'getId',
+ 'getData'
+ ]);
+ $this->collectionMock->expects($this->once())->method('getItems')->willReturn([$groupMock]);
+
+ $groupMock->expects($this->atLeastOnce())->method('getId')->willReturn($groupId);
+ $groupMock->expects($this->once())->method('getData')->willReturn($groupData);
+
+ /** @var \Magento\Customer\Model\Group\DataProvider $dataProvider */
+ $dataProvider = (new ObjectManager($this))->getObject(
+ \Magento\Customer\Model\Group\DataProvider::class,
+ [
+ 'name' => 'test-name',
+ 'primaryFieldName' => 'primary-field-name',
+ 'requestFieldName' => 'request-field-name',
+ 'groupCollectionFactory' => $this->collectionFactoryMock,
+ 'registry' => $this->registryMock,
+ 'groupRepository' => $this->groupRepositoryMock,
+ 'taxHelper' => $this->taxHelperMock,
+ ]
+ );
+
+ $this->assertEquals([$groupId => $groupData], $dataProvider->getData());
+ // Load from object-cache the second time
+ $this->assertEquals([$groupId => $groupData], $dataProvider->getData());
+ }
+
+ /**
+ * @return void
+ * @covers \Magento\Customer\Model\Group\DataProvider::getMeta
+ */
+ public function testGetMetaForNotLoggedInGroup()
+ {
+ /** @var \Magento\Customer\Model\Group\DataProvider $dataProvider */
+ $dataProvider = (new ObjectManager($this))->getObject(
+ \Magento\Customer\Model\Group\DataProvider::class,
+ [
+ 'name' => 'test-name',
+ 'primaryFieldName' => 'primary-field-name',
+ 'requestFieldName' => 'request-field-name',
+ 'groupCollectionFactory' => $this->collectionFactoryMock,
+ 'registry' => $this->registryMock,
+ 'groupRepository' => $this->groupRepositoryMock,
+ 'taxHelper' => $this->taxHelperMock,
+ ]
+ );
+
+ $this->registryMock->expects($this->any())
+ ->method('registry')
+ ->willReturn('0');
+
+ $customerGroupMock = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $customerGroupMock->expects($this->any())
+ ->method('getId')
+ ->willReturn(\Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID);
+ $customerGroupMock->expects($this->any())->method('getCode')->willReturn('NOT LOGGED IN');
+
+ $this->groupRepositoryMock->expects($this->any())->method('getById')->willReturn($customerGroupMock);
+
+ $meta = $dataProvider->getMeta();
+ $this->assertNotEmpty($meta);
+ $this->assertTrue(
+ $meta['general']['children']['customer_group_code']['arguments']['data']['config']['disabled']
+ );
+ }
+}
diff --git a/app/code/Magento/Customer/view/adminhtml/layout/customer_group_edit.xml b/app/code/Magento/Customer/view/adminhtml/layout/customer_group_edit.xml
new file mode 100644
index 0000000000000..ba3c7cb12c6c7
--- /dev/null
+++ b/app/code/Magento/Customer/view/adminhtml/layout/customer_group_edit.xml
@@ -0,0 +1,11 @@
+
+
+