Example #1
0
 /**
  * @dataProvider isPaymentEnabledDataProvider
  */
 public function testIsPaymentEnabled($groupConfig, $expected)
 {
     $this->_element->setGroup($groupConfig);
     $this->_backendConfig->expects($this->any())->method('getConfigDataValue')->will($this->returnValueMap([[self::CONFIG_PATH_ACTIVE, null, null, '1'], [self::CONFIG_PATH_NOT_ACTIVE, null, null, '0']]));
     $html = $this->_model->render($this->_element);
     $this->assertContains($expected, $html);
 }
 /**
  * Sets scope for backend config
  *
  * @param string $sectionId
  * @return bool
  */
 protected function isSectionAllowed($sectionId)
 {
     $website = $this->getRequest()->getParam('website');
     $store = $this->getRequest()->getParam('store');
     if ($store) {
         $this->_backendConfig->setStore($store);
     } elseif ($website) {
         $this->_backendConfig->setWebsite($website);
     }
     return parent::isSectionAllowed($sectionId);
 }
Example #3
0
 /**
  * Get selected merchant country code in system configuration
  *
  * @return string
  */
 public function getConfigurationCountryCode()
 {
     $countryCode = $this->_request->getParam(\Magento\Paypal\Model\Config\StructurePlugin::REQUEST_PARAM_COUNTRY);
     if ($countryCode === null || preg_match('/^[a-zA-Z]{2}$/', $countryCode) == 0) {
         $countryCode = $this->_backendConfig->getConfigDataValue(\Magento\Paypal\Block\Adminhtml\System\Config\Field\Country::FIELD_CONFIG_PATH);
     }
     if (empty($countryCode)) {
         $countryCode = $this->directoryHelper->getDefaultCountry();
     }
     return $countryCode;
 }
 /**
  * Sets scope for backend config
  *
  * @param string $sectionId The section being viewed/edited/saved
  *
  * @return bool
  */
 protected function isSectionAllowed($sectionId)
 {
     $container = $this->getRequest()->getParam('container');
     $store = $this->getRequest()->getParam('store');
     if ($store) {
         $this->backendConfig->setStore($store);
     } elseif ($container) {
         $this->backendConfig->setContainer($container);
     }
     return $this->sectionChecker->isSectionAllowed($sectionId);
 }
Example #5
0
 /**
  * Check whether current payment method is enabled
  *
  * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  * @return bool
  */
 protected function _isPaymentEnabled($element)
 {
     $groupConfig = $element->getGroup();
     $activityPaths = isset($groupConfig['activity_path']) ? $groupConfig['activity_path'] : [];
     if (!is_array($activityPaths)) {
         $activityPaths = [$activityPaths];
     }
     $isPaymentEnabled = false;
     foreach ($activityPaths as $activityPath) {
         $isPaymentEnabled = $isPaymentEnabled || (bool) (string) $this->_backendConfig->getConfigDataValue($activityPath);
     }
     return $isPaymentEnabled;
 }
Example #6
0
 /**
  * Initialize config group fields
  *
  * @param \Magento\Framework\Data\Form\Element\Fieldset $fieldset
  * @param \Magento\Config\Model\Config\Structure\Element\Group $group
  * @param \Magento\Config\Model\Config\Structure\Element\Section $section
  * @param string $fieldPrefix
  * @param string $labelPrefix
  * @return $this
  */
 public function initFields(\Magento\Framework\Data\Form\Element\Fieldset $fieldset, \Magento\Config\Model\Config\Structure\Element\Group $group, \Magento\Config\Model\Config\Structure\Element\Section $section, $fieldPrefix = '', $labelPrefix = '')
 {
     if (!$this->_configDataObject) {
         $this->_initObjects();
     }
     // Extends for config data
     $extraConfigGroups = [];
     /** @var $element \Magento\Config\Model\Config\Structure\Element\Field */
     foreach ($group->getChildren() as $element) {
         if ($element instanceof \Magento\Config\Model\Config\Structure\Element\Group) {
             $this->_initGroup($element, $section, $fieldset);
         } else {
             $path = $element->getConfigPath() ?: $element->getPath($fieldPrefix);
             if ($element->getSectionId() != $section->getId()) {
                 $groupPath = $element->getGroupPath();
                 if (!isset($extraConfigGroups[$groupPath])) {
                     $this->_configData = $this->_configDataObject->extendConfig($groupPath, false, $this->_configData);
                     $extraConfigGroups[$groupPath] = true;
                 }
             }
             $this->_initElement($element, $fieldset, $path, $fieldPrefix, $labelPrefix);
         }
     }
     return $this;
 }
Example #7
0
 /**
  * @param string $path
  * @param string $expectedException
  *
  * @dataProvider setDataByPathWrongDepthDataProvider
  */
 public function testSetDataByPathWrongDepth($path, $expectedException)
 {
     $expectedException = 'Allowed depth of configuration is 3 (<section>/<group>/<field>). ' . $expectedException;
     $this->setExpectedException('\\UnexpectedValueException', $expectedException);
     $value = 'value';
     $this->_model->setDataByPath($path, $value);
 }
 public function tearDown()
 {
     if (!empty($this->currentCustomerId)) {
         foreach ($this->currentCustomerId as $customerId) {
             $serviceInfo = ['rest' => ['resourcePath' => self::RESOURCE_PATH . '/' . $customerId, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE], 'soap' => ['service' => CustomerRepositoryTest::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, 'operation' => CustomerRepositoryTest::SERVICE_NAME . 'DeleteById']];
             $response = $this->_webApiCall($serviceInfo, ['customerId' => $customerId]);
             $this->assertTrue($response);
         }
     }
     $this->config->setDataByPath(SecurityConfig::XML_PATH_FRONTED_AREA . SecurityConfig::XML_PATH_LIMIT_PASSWORD_RESET_REQUESTS_METHOD, $this->configValue);
     $this->config->save();
     unset($this->accountManagement);
 }
 public function aroundSave(\Magento\Config\Model\Config $config, \Closure $proceed)
 {
     $ret = $proceed();
     $sectionId = $config->getSection();
     if ($sectionId == 'mandrill' && !$config->getConfigDataValue('mandrill/general/active')) {
         $modules = $this->_loader->load();
         if (isset($modules['Ebizmarts_AbandonedCart'])) {
             $this->_writer->save(\Ebizmarts\AbandonedCart\Model\Config::ACTIVE, 0, $config->getScope(), $config->getScopeId());
         }
         if (isset($modules['Ebizmarts_AutoResponder'])) {
             $this->_writer->save(\Ebizmarts\AutoResponder\Model\Config::ACTIVE, 0, $config->getScope(), $config->getScopeId());
         }
     }
     return $ret;
 }
Example #10
0
 /**
  * Prepare backend config for test
  *
  * @param string|null|false $config
  */
 private function _configurationCountryCodePrepareConfig($config)
 {
     $this->_backendConfig->expects($this->once())->method('getConfigDataValue')->with(\Magento\Paypal\Block\Adminhtml\System\Config\Field\Country::FIELD_CONFIG_PATH)->will($this->returnValue($config));
 }
Example #11
0
 /**
  * Prepare backend config for test
  *
  * @param string|null|false $config
  */
 private function configurationCountryCodePrepareConfig($config)
 {
     $this->scopeDefiner->expects($this->once())->method('getScope')->willReturn(self::SCOPE);
     $this->backendConfig->expects($this->once())->method('setData')->with(self::SCOPE, self::SCOPE_ID);
     $this->backendConfig->expects($this->once())->method('getConfigDataValue')->with(\Magento\Paypal\Block\Adminhtml\System\Config\Field\Country::FIELD_CONFIG_PATH)->willReturn($config);
 }
Example #12
0
 /**
  * Class constructor
  *
  * @param ReinitableConfigInterface $config             Configuration interface
  * @param ManagerInterface          $eventManager       Event Manager
  * @param Structure                 $configStructure    Configuration Structure
  * @param TransactionFactory        $transactionFactory Transaction Factory
  * @param Loader                    $configLoader       Configuration Loader
  * @param ValueFactory              $configValueFactory Configuration Value Factory
  * @param StoreManagerInterface     $storeManager       Store Manager
  * @param Containers                $containersSource   The Containers source model
  * @param array                     $data               The data
  */
 public function __construct(ReinitableConfigInterface $config, ManagerInterface $eventManager, Structure $configStructure, TransactionFactory $transactionFactory, Loader $configLoader, ValueFactory $configValueFactory, StoreManagerInterface $storeManager, Containers $containersSource, array $data = [])
 {
     $this->containersSource = $containersSource;
     $this->fullConfig = true;
     parent::__construct($config, $eventManager, $configStructure, $transactionFactory, $configLoader, $configValueFactory, $storeManager, $data);
 }