示例#1
0
 /**
  * @param bool $isExperimentsEnabled
  * @param bool $isAnalyticsAvailable
  * @param bool $result
  * @dataProvider dataProviderForTestGoogleExperimentIsActive
  */
 public function testGoogleExperimentIsActive($isExperimentsEnabled, $isAnalyticsAvailable, $result)
 {
     $store = 1;
     $this->_scopeConfigMock->expects($this->once())->method('isSetFlag')->with(\Magento\GoogleOptimizer\Helper\Data::XML_PATH_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store)->will($this->returnValue($isExperimentsEnabled));
     $this->_googleAnalyticsHelperMock->expects($this->any())->method('isGoogleAnalyticsAvailable')->with($store)->will($this->returnValue($isAnalyticsAvailable));
     $this->assertEquals($result, $this->_helper->isGoogleExperimentActive($store));
 }
示例#2
0
 /**
  * @param \Magento\Cms\Model\Page\DataProvider $subject
  * @param array $result
  * @return mixed
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterPrepareMeta(\Magento\Cms\Model\Page\DataProvider $subject, $result)
 {
     $result['page_view_optimization']['arguments']['data']['disabled'] = !$this->helper->isGoogleExperimentActive();
     $result['page_view_optimization']['arguments']['data']['config']['componentType'] = \Magento\Ui\Component\Form\Fieldset::NAME;
     $result['page_view_optimization']['arguments']['data']['config']['label'] = __('Page View Optimization');
     return $result;
 }
 /**
  * Return script code
  *
  * @return string
  */
 protected function _getScriptCode()
 {
     $result = '';
     if ($this->_helper->isGoogleExperimentActive() && $this->_getGoogleExperiment()) {
         $result = $this->_getGoogleExperiment()->getData('experiment_script');
     }
     return $result;
 }
示例#4
0
 /**
  * @param NewCategoryDataProvider $subject
  * @param array $result
  * @return mixed
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterGetMeta(NewCategoryDataProvider $subject, $result)
 {
     $isDisabled = !$this->helper->isGoogleExperimentActive();
     $experimentScriptFieldConfig = ['arguments' => ['data' => ['config' => ['componentDisabled' => $isDisabled]]]];
     $codeIdFieldConfig = ['arguments' => ['data' => ['config' => ['componentDisabled' => $isDisabled]]]];
     $result['data']['children']['experiment_script'] = $experimentScriptFieldConfig;
     $result['data']['children']['code_id'] = $codeIdFieldConfig;
     return $result;
 }
 /**
  * Adds Google Experiment tab to the category edit page
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if ($this->_helper->isGoogleExperimentActive()) {
         $block = $this->_layout->createBlock('Magento\\GoogleOptimizer\\Block\\Adminhtml\\Catalog\\Category\\Edit\\Tab\\Googleoptimizer', 'google-experiment-form');
         /** @var $tabs \Magento\Catalog\Block\Adminhtml\Category\Tabs */
         $tabs = $observer->getEvent()->getTabs();
         $tabs->addTab('google-experiment-tab', ['label' => __('Category View Optimization'), 'content' => $block->toHtml()]);
     }
 }
 public function testAfterGetMetaNegative()
 {
     $this->helper->expects($this->any())->method('isGoogleExperimentActive')->willReturn(false);
     $result = $this->plugin->afterGetMeta($this->subject, []);
     $children = $result['data']['children'];
     $this->assertArrayHasKey('experiment_script', $children);
     $this->assertTrue($children['experiment_script']['arguments']['data']['config']['componentDisabled']);
     $this->assertArrayHasKey('code_id', $children);
     $this->assertTrue($children['code_id']['arguments']['data']['config']['componentDisabled']);
 }
 /**
  * Adds Google Experiment fields to category creation form on product edit page
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if ($this->dataHelper->isGoogleExperimentActive()) {
         $block = $observer->getEvent()->getBlock();
         if ($block->getForm() && $block->getForm()->getId() == 'new_category_form') {
             $fieldset = $block->getForm()->getElement('new_category_form_fieldset');
             $fieldset->addField('experiment_script', 'textarea', ['name' => 'google_experiment[experiment_script]', 'label' => __('Experiment Code'), 'value' => '', 'class' => 'textarea googleoptimizer', 'required' => false, 'note' => __('Experiment code should be added to the original page only.')]);
             $fieldset->addField('code_id', 'hidden', ['name' => 'google_experiment[code_id]', 'value' => '', 'required' => false]);
         }
     }
 }
 /**
  * Check is Google Experiment enabled
  *
  * @return bool
  */
 protected function _isGoogleExperimentActive()
 {
     return $this->_helper->isGoogleExperimentActive();
 }
 /**
  * @param \Magento\Catalog\Model\Category\DataProvider $subject
  * @param array $result
  * @return array
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterPrepareMeta(\Magento\Catalog\Model\Category\DataProvider $subject, $result)
 {
     $result['category_view_optimization']['arguments']['data']['disabled'] = !$this->_helper->isGoogleExperimentActive();
     $result['category_view_optimization']['arguments']['data']['config']['componentType'] = \Magento\Ui\Component\Form\Fieldset::NAME;
     return $result;
 }
示例#10
0
 /**
  * Can show tab in tabs
  *
  * @return bool
  */
 public function canShowTab()
 {
     return $this->_helperData->isGoogleExperimentActive();
 }
 /**
  * @param bool $flag
  * @return void
  */
 protected function canShowPanel($flag)
 {
     $storeId = 1;
     $this->productMock->expects($this->any())->method('getStoreId')->willReturn($storeId);
     $this->dataHelperMock->expects($this->once())->method('isGoogleExperimentActive')->with($storeId)->willReturn($flag);
 }
示例#12
0
 /**
  * @param \Magento\Catalog\Model\Category\DataProvider $subject
  * @param array $result
  * @return array
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterPrepareMeta(\Magento\Catalog\Model\Category\DataProvider $subject, $result)
 {
     $result['category_view_optimization']['componentDisabled'] = !$this->_helper->isGoogleExperimentActive();
     return $result;
 }
示例#13
0
 /**
  * Can show panel
  *
  * @return bool
  */
 protected function canShowPanel()
 {
     $storeId = $this->locator->getProduct()->getStoreId();
     return $this->dataHelper->isGoogleExperimentActive($storeId);
 }