/** * Verify that the Delete button does not exist for the default group. * @magentoAppIsolation enabled */ public function testDeleteButtonNotExistInDefaultGroup() { $groupId = $this->customerGroupService->getDefaultGroup(0)->getId(); $this->registry->register(RegistryConstants::CURRENT_GROUP_ID, $groupId); $this->getRequest()->setParam('id', $groupId); /** @var $block Edit */ $block = $this->layout->createBlock('Magento\\Customer\\Block\\Adminhtml\\Group\\Edit', 'block'); $buttonsHtml = $block->getButtonsHtml(); $this->assertNotContains('delete', $buttonsHtml); }
/** * Set current attribute to entry (for specified product) * * @param Product $product * @param Entry $entry * @return Entry */ public function convertAttribute($product, $entry) { $product->setWebsiteId($this->_storeManager->getStore($product->getStoreId())->getWebsiteId()); $defaultCustomerGroup = $this->_customerGroupService->getDefaultGroup($product->getStoreId()); $product->setCustomerGroupId($defaultCustomerGroup->getId()); /** @var \Magento\Store\Model\Store $store */ $store = $this->_storeManager->getStore($product->getStoreId()); $isSalePriceAllowed = $this->_config->getTargetCountry($product->getStoreId()) == 'US'; // get tax settings $priceDisplayType = $this->_taxData->getPriceDisplayType($product->getStoreId()); $inclTax = $priceDisplayType == Config::DISPLAY_TYPE_INCLUDING_TAX; $finalPrice = $this->_getFinalPrice($product, $store, $inclTax, $isSalePriceAllowed); // calculate price attribute value $price = $this->_getPrice($product, $store, $priceDisplayType, $inclTax, $isSalePriceAllowed); if ($isSalePriceAllowed) { // set sale_price and effective dates for it if ($price && $price - $finalPrice > 0.0001) { $this->_setAttributePrice($entry, $product, $price); $this->_setAttributePrice($entry, $product, $finalPrice, 'sale_price'); $this->_setEffectiveDate($product, $entry); } else { $this->_setAttributePrice($entry, $product, $finalPrice); $entry->removeContentAttribute('sale_price_effective_date'); $entry->removeContentAttribute('sale_price'); } // calculate taxes $tax = $this->getGroupAttributeTax(); if (!$inclTax && !is_null($tax)) { $tax->convertAttribute($product, $entry); } } else { $this->_setAttributePrice($entry, $product, $price); } return $entry; }
/** * Test retrieving a valid group form. */ public function testGetForm() { $this->registry->register(RegistryConstants::CURRENT_GROUP_ID, $this->customerGroupService->getDefaultGroup(0)->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('1', $idElement->getValue()); $this->assertEquals('3', $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('General', $groupCodeElement->getValue()); }