/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Directory\Helper\Data $directoryHelper * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder * @param \Magento\Framework\App\Cache\Type\Config $configCacheType * @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollectionFactory * @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory * @param \Magento\Braintree\Helper\Data $braintreeHelper * @param \Magento\Braintree\Model\System\Config\Source\Country $countrySource * @param \Magento\Braintree\Model\Config\Cc $config * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Directory\Helper\Data $directoryHelper, \Magento\Framework\Json\EncoderInterface $jsonEncoder, \Magento\Framework\App\Cache\Type\Config $configCacheType, \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollectionFactory, \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory, \Magento\Braintree\Helper\Data $braintreeHelper, \Magento\Braintree\Model\System\Config\Source\Country $countrySource, \Magento\Braintree\Model\Config\Cc $config, array $data = []) { $this->braintreeHelper = $braintreeHelper; $this->countrySource = $countrySource; $this->config = $config; parent::__construct($context, $directoryHelper, $jsonEncoder, $configCacheType, $regionCollectionFactory, $countryCollectionFactory, $data); }
/** * @param string $storeCode * @param int $defaultCountry * @param string $destinations * @param array $expectedDestinations * @param array $options * @param string $resultHtml * @dataProvider dataProviderGetCountryHtmlSelect */ public function testGetCountryHtmlSelect($storeCode, $defaultCountry, $destinations, $expectedDestinations, $options, $resultHtml) { $this->helperData->expects($this->once())->method('getDefaultCountry')->willReturn($defaultCountry); $this->store->expects($this->once())->method('getCode')->willReturn($storeCode); $this->cacheTypeConfig->expects($this->once())->method('load')->with('DIRECTORY_COUNTRY_SELECT_STORE_' . $storeCode)->willReturn(false); $this->cacheTypeConfig->expects($this->once())->method('save')->with(serialize($options), 'DIRECTORY_COUNTRY_SELECT_STORE_' . $storeCode)->willReturnSelf(); $this->scopeConfig->expects($this->once())->method('getValue')->with('general/country/destinations', ScopeInterface::SCOPE_STORE)->willReturn($destinations); $this->countryCollection->expects($this->once())->method('loadByStore')->willReturnSelf(); $this->countryCollection->expects($this->any())->method('setForegroundCountries')->with($expectedDestinations)->willReturnSelf(); $this->countryCollection->expects($this->once())->method('toOptionArray')->willReturn($options); $elementHtmlSelect = $this->mockElementHtmlSelect($defaultCountry, $options, $resultHtml); $this->layout->expects($this->once())->method('createBlock')->willReturn($elementHtmlSelect); $this->assertEquals($resultHtml, $this->model->getCountryHtmlSelect()); }
/** * Retrieve customer country identifier * * @return int */ public function getCountryId() { $countryId = $this->getFormData()->getCountryId(); if ($countryId) { return $countryId; } return parent::getCountryId(); }
/** * Return the country Id. * * @return int|null|string */ public function getCountryId() { if ($countryId = $this->getAddress()->getCountryId()) { return $countryId; } return parent::getCountryId(); }
/** * Check if multiple countries for shipping is allowed * * @return bool */ public function isMultipleCountriesAllowed() { $collection = $this->_directoryBlock->getCountryCollection(); return $collection->count() > 1 ? true : false; }