コード例 #1
0
ファイル: FormTest.php プロジェクト: aiesh/magento2
 /**
  * @magentoDataFixture Magento/Customer/_files/customer_group.php
  */
 public function testGetFormExistInCustomGroup()
 {
     $builder = Bootstrap::getObjectManager()->create('Magento\\Framework\\Service\\V1\\Data\\FilterBuilder');
     /** @var \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder $searchCriteria */
     $searchCriteria = Bootstrap::getObjectManager()->create('Magento\\Framework\\Service\\V1\\Data\\SearchCriteriaBuilder')->addFilter([$builder->setField('code')->setValue('custom_group')->create()])->create();
     /** @var CustomerGroup $customerGroup */
     $customerGroup = $this->customerGroupService->searchGroups($searchCriteria)->getItems()[0];
     $this->registry->register(RegistryConstants::CURRENT_GROUP_ID, $customerGroup->getId());
     /** @var $block Form */
     $block = $this->layout->createBlock('Magento\\Customer\\Block\\Adminhtml\\Group\\Edit\\Form', 'block');
     $form = $block->getForm();
     $this->assertEquals('edit_form', $form->getId());
     $this->assertEquals('post', $form->getMethod());
     $baseFieldSet = $form->getElement('base_fieldset');
     $this->assertNotNull($baseFieldSet);
     $groupCodeElement = $form->getElement('customer_group_code');
     $this->assertNotNull($groupCodeElement);
     $taxClassIdElement = $form->getElement('tax_class_id');
     $this->assertNotNull($taxClassIdElement);
     $idElement = $form->getElement('id');
     $this->assertNotNull($idElement);
     $this->assertEquals($customerGroup->getId(), $idElement->getValue());
     $this->assertEquals($customerGroup->getTaxClassId(), $taxClassIdElement->getValue());
     /** @var \Magento\Tax\Model\TaxClass\Source\Customer $taxClassCustomer */
     $taxClassCustomer = Bootstrap::getObjectManager()->get('Magento\\Tax\\Model\\TaxClass\\Source\\Customer');
     $this->assertEquals($taxClassCustomer->toOptionArray(false), $taxClassIdElement->getData('values'));
     $this->assertEquals($customerGroup->getCode(), $groupCodeElement->getValue());
 }
コード例 #2
0
ファイル: EditTest.php プロジェクト: aiesh/magento2
 /**
  * @magentoDataFixture Magento/Customer/_files/customer_group.php
  */
 public function testDeleteButtonExistInCustomGroup()
 {
     $builder = Bootstrap::getObjectManager()->create('\\Magento\\Framework\\Service\\V1\\Data\\FilterBuilder');
     /** @var \Magento\Framework\Service\V1\Data\SearchCriteriaBuilder $searchCriteria */
     $searchCriteria = Bootstrap::getObjectManager()->create('Magento\\Framework\\Service\\V1\\Data\\SearchCriteriaBuilder')->addFilter([$builder->setField('code')->setValue('custom_group')->create()])->create();
     /** @var CustomerGroup $customerGroup */
     $customerGroup = $this->customerGroupService->searchGroups($searchCriteria)->getItems()[0];
     $this->getRequest()->setParam('id', $customerGroup->getId());
     $this->registry->register(RegistryConstants::CURRENT_GROUP_ID, $customerGroup->getId());
     /** @var $block Edit */
     $block = $this->layout->createBlock('Magento\\Customer\\Block\\Adminhtml\\Group\\Edit', 'block');
     $buttonsHtml = $block->getButtonsHtml();
     $this->assertContains('delete', $buttonsHtml);
 }