public function testDisplay()
 {
     $this->markTestSkipped('Remove it when task(MAGETWO-33495) will be fixed');
     $this->_response->expects($this->atLeastOnce())->method('sendHeaders');
     $this->_request->expects($this->atLeastOnce())->method('getHeader');
     $stat = (include __DIR__ . '/_files/timers.php');
     $this->_output->display($stat);
     $actualHeaders = $this->_response->getHeaders();
     $this->assertNotEmpty($actualHeaders);
     $actualProtocol = false;
     $actualProfilerData = false;
     foreach ($actualHeaders as $oneHeader) {
         $headerName = $oneHeader->getFieldName();
         $headerValue = $oneHeader->getFieldValue();
         if (!$actualProtocol && $headerName == 'X-Wf-Protocol-1') {
             $actualProtocol = $headerValue;
         }
         if (!$actualProfilerData && $headerName == 'X-Wf-1-1-1-1') {
             $actualProfilerData = $headerValue;
         }
     }
     $this->assertNotEmpty($actualProtocol, 'Cannot get protocol header');
     $this->assertNotEmpty($actualProfilerData, 'Cannot get profiler header');
     $this->assertContains('Protocol/JsonStream', $actualProtocol);
     $this->assertRegExp('/"Type":"TABLE","Label":"Code Profiler \\(Memory usage: real - \\d+, emalloc - \\d+\\)"/', $actualProfilerData);
     $this->assertContains('[' . '["Timer Id","Time","Avg","Cnt","Emalloc","RealMem"],' . '["root","0.080000","0.080000","1","1,000","50,000"],' . '[". init","0.040000","0.040000","1","200","2,500"],' . '[". . init_store","0.020000","0.010000","2","100","2,000"],' . '["system","0.030000","0.015000","2","400","20,000"]' . ']', $actualProfilerData);
 }
 /**
  * Execute method.
  */
 public function execute()
 {
     $attribute = $this->getRequest()->getParam('attribute');
     $conditionName = $this->getRequest()->getParam('condition');
     $valueName = $this->getRequest()->getParam('value');
     if ($attribute && $conditionName && $valueName) {
         $type = $this->ruleType->getInputType($attribute);
         $conditionOptions = $this->ruleCondition->getInputTypeOptions($type);
         $response['condition'] = $this->_getOptionHtml('conditions', $conditionName, $conditionOptions);
         $elmType = $this->ruleValue->getValueElementType($attribute);
         if ($elmType == 'select') {
             $valueOptions = $this->ruleValue->getValueSelectOptions($attribute);
             $response['cvalue'] = $this->_getOptionHtml('cvalue', $valueName, $valueOptions);
         } elseif ($elmType == 'text') {
             $html = "<input style='width:160px' title='cvalue' class='' id='' name={$valueName} />";
             $response['cvalue'] = $html;
         }
         $this->http->getHeaders()->clearHeaders();
         $this->http->setHeader('Content-Type', 'application/json')->setBody($this->jsonEncoder->encode($response));
     }
 }
 /**
  * Execute method.
  *
  * @return $this
  */
 public function execute()
 {
     $id = $this->getRequest()->getParam('ruleid');
     $attribute = $this->getRequest()->getParam('attribute');
     $arrayKey = $this->getRequest()->getParam('arraykey');
     $conditionName = $this->getRequest()->getParam('condition');
     $valueName = $this->getRequest()->getParam('value');
     if ($arrayKey && $id && $attribute && $conditionName && $valueName) {
         $rule = $this->rulesFactory->create()->load($id);
         //rule not found
         if (!$rule->getId()) {
             $this->http->getHeaders()->clearHeaders();
             return $this->http->setHeader('Content-Type', 'application/json')->setBody('Rule not found!');
         }
         $conditions = $rule->getCondition();
         $condition = $conditions[$arrayKey];
         $selectedConditions = $condition['conditions'];
         $selectedValues = $condition['cvalue'];
         $type = $this->ruleType->getInputType($attribute);
         $conditionOptions = $this->ruleCondition->getInputTypeOptions($type);
         $response['condition'] = str_replace('value="' . $selectedConditions . '"', 'value="' . $selectedConditions . '"' . 'selected="selected"', $this->getOptionHtml('conditions', $conditionName, $conditionOptions));
         $elmType = $this->ruleValue->getValueElementType($attribute);
         if ($elmType == 'select' or $selectedConditions == 'null') {
             $isEmpty = false;
             if ($selectedConditions == 'null') {
                 $isEmpty = true;
             }
             $valueOptions = $this->ruleValue->getValueSelectOptions($attribute, $isEmpty);
             $response['cvalue'] = str_replace('value="' . $selectedValues . '"', 'value="' . $selectedValues . '"' . 'selected="selected"', $this->getOptionHtml('cvalue', $valueName, $valueOptions));
         } elseif ($elmType == 'text') {
             $html = "<input style='width:160px' title='cvalue' name='{$valueName}' value='{$selectedValues}'/>";
             $response['cvalue'] = $html;
         }
         $this->http->getHeaders()->clearHeaders();
         $this->http->setHeader('Content-Type', 'application/json')->setBody($this->jsonEncoder->encode($response));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getHeaders()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getHeaders');
     if (!$pluginInfo) {
         return parent::getHeaders();
     } else {
         return $this->___callPlugins('getHeaders', func_get_args(), $pluginInfo);
     }
 }