예제 #1
0
파일: Inline.php 프로젝트: aiesh/magento2
 /**
  * Retrieve Inline Parser instance
  *
  * @return \Magento\Framework\Translate\Inline\ParserInterface
  */
 public function getParser()
 {
     if (!$this->_parser) {
         $this->_parser = $this->parserFactory->create(['translateInline' => $this]);
     }
     return $this->_parser;
 }
예제 #2
0
 /**
  * @param $scope
  * @param $body
  * @param $expected
  * @dataProvider processResponseBodyGetInlineScriptDataProvider
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function testProcessResponseBodyGetInlineScript($scope, $body, $expected)
 {
     $isJson = true;
     $this->prepareIsAllowed(true, true, true, $scope);
     $jsonCall = is_array($body) ? 2 * (count($body) + 1) : 2;
     $this->parserMock->expects($this->exactly($jsonCall))->method('setIsJson')->will($this->returnValueMap([[$isJson, $this->returnSelf()], [!$isJson, $this->returnSelf()]]));
     $this->parserMock->expects($this->exactly(1))->method('processResponseBodyString')->with(is_array($body) ? reset($body) : $body);
     $this->parserMock->expects($this->exactly(2))->method('getContent')->will($this->returnValue(is_array($body) ? reset($body) : $body));
     $model = new Inline($this->scopeResolverMock, $this->urlMock, $this->layoutMock, $this->configMock, $this->parserMock, $this->stateMock, '', '', $scope);
     $model->processResponseBody($body, $isJson);
     $this->assertEquals($body, $expected);
 }