Beispiel #1
0
 /**
  * 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 testCreateTranslateConfigAsset()
 {
     $path = 'relative path';
     $expectedPath = $path . '/' . FileManager::TRANSLATION_CONFIG_FILE_NAME;
     $fileMock = $this->getMock('\\Magento\\Framework\\View\\Asset\\File', [], [], '', false);
     $contextMock = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\ContextInterface', [], '', true, true, true, ['getPath']);
     $this->assetRepoMock->expects($this->once())->method('getStaticViewFileContext')->willReturn($contextMock);
     $contextMock->expects($this->once())->method('getPath')->willReturn($path);
     $this->assetRepoMock->expects($this->once())->method('createArbitrary')->with($expectedPath, '')->willReturn($fileMock);
     $this->assertSame($fileMock, $this->model->createTranslateConfigAsset());
 }