/** * 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; }
/** * @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); }