public function testGetDefaultRateRequest() { $customerDataSet = $this->_customerAccountService->getCustomer(self::FIXTURE_CUSTOMER_ID); $address = $this->_addressService->getAddress(self::FIXTURE_ADDRESS_ID); $rateRequest = $this->_model->getRateRequest(null, null, null, null, $customerDataSet->getId()); $this->assertNotNull($rateRequest); $this->assertEquals($address->getCountryId(), $rateRequest->getCountryId()); $this->assertEquals($address->getRegion()->getRegionId(), $rateRequest->getRegionId()); $this->assertEquals($address->getPostcode(), $rateRequest->getPostcode()); $customerTaxClassId = $this->_groupService->getGroup($customerDataSet->getGroupId())->getTaxClassId(); $this->assertEquals($customerTaxClassId, $rateRequest->getCustomerClassId()); }
/** * 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; }
/** * @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()); }
/** * @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); }