/** * Include RequireJs inline translation configuration as an asset on the page * @return void */ private function addInlineTranslationConfig() { if ($this->inline->isAllowed()) { $after = RequireJsConfig::REQUIRE_JS_FILE_NAME; $tConfig = $this->fileManager->createTranslateConfigAsset(); $assetCollection = $this->pageConfig->getAssetCollection(); $assetCollection->insert($tConfig->getFilePath(), $tConfig, $after); } }
public function testGetAdditionalHtmlAttribute() { $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\Translate\\Inline')->will($this->returnValue($this->translateMock)); $this->objectManagerMock->expects($this->never())->method('get'); $this->translateMock->expects($this->exactly(2))->method('getAdditionalHtmlAttribute')->with($this->logicalOr('some_value', null))->will($this->returnArgument(0)); $model = new Proxy($this->objectManagerMock, 'Magento\\Framework\\Translate\\Inline', false); $this->assertEquals('some_value', $model->getAdditionalHtmlAttribute('some_value')); $this->assertNull($model->getAdditionalHtmlAttribute()); }
/** * @param string $originalText * @param string $expectedText * @dataProvider processResponseBodyDataProvider */ public function testProcessResponseBody($originalText, $expectedText) { $actualText = $originalText; $this->_model->processResponseBody($actualText, false); $this->markTestIncomplete('Bug MAGE-2494'); $expected = new \DOMDocument(); $expected->preserveWhiteSpace = false; $expected->loadHTML($expectedText); $actual = new \DOMDocument(); $actual->preserveWhiteSpace = false; $actual->loadHTML($actualText); $this->assertEquals($expected, $actual); }
/** * @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); }