/**
  * @return void
  */
 public function testGetData()
 {
     $themePath = 'blank';
     $areaCode = 'adminhtml';
     $filePaths = [['path1'], ['path2'], ['path3'], ['path4']];
     $jsFilesMap = [['base', $themePath, '*', '*', [$filePaths[0]]], [$areaCode, $themePath, '*', '*', [$filePaths[1]]]];
     $staticFilesMap = [['base', $themePath, '*', '*', [$filePaths[2]]], [$areaCode, $themePath, '*', '*', [$filePaths[3]]]];
     $expectedResult = ['hello1' => 'hello1translated', 'hello2' => 'hello2translated', 'hello3' => 'hello3translated', 'hello4' => 'hello4translated'];
     $contentsMap = ['content1$.mage.__("hello1")content1', 'content2$.mage.__("hello2")content2', 'content2$.mage.__("hello3")content3', 'content2$.mage.__("hello4")content4'];
     $translateMap = [[['hello1'], [], 'hello1translated'], [['hello2'], [], 'hello2translated'], [['hello3'], [], 'hello3translated'], [['hello4'], [], 'hello4translated']];
     $patterns = ['~\\$\\.mage\\.__\\(([\'"])(.+?)\\1\\)~'];
     $this->appStateMock->expects($this->once())->method('getAreaCode')->willReturn($areaCode);
     $this->filesUtilityMock->expects($this->any())->method('getJsFiles')->willReturnMap($jsFilesMap);
     $this->filesUtilityMock->expects($this->any())->method('getStaticHtmlFiles')->willReturnMap($staticFilesMap);
     foreach ($contentsMap as $index => $content) {
         $this->fileReadMock->expects($this->at($index))->method('readAll')->willReturn($content);
     }
     $this->configMock->expects($this->any())->method('getPatterns')->willReturn($patterns);
     $this->translateMock->expects($this->any())->method('render')->willReturnMap($translateMap);
     $this->assertEquals($expectedResult, $this->model->getData($themePath));
 }
Example #2
0
 protected function _setupUrlMocks($size = self::FILE_SIZE, $url = self::URL, $additionalStatData = [])
 {
     $this->_handleMock->expects($this->any())->method('stat')->will($this->returnValue(array_merge(['size' => $size, 'type' => self::MIME_TYPE], $additionalStatData)));
     $this->fileReadFactory->expects($this->once())->method('create')->will($this->returnValue($this->_handleMock));
     $this->_helper->setResource($url, DownloadHelper::LINK_TYPE_URL);
 }
Example #3
0
 protected function _setupUrlMocks($size = self::FILE_SIZE, $url = self::URL, $additionalStatData = array())
 {
     $this->_handleMock->expects($this->any())->method('stat')->will($this->returnValue(array_merge(array('size' => $size, 'type' => self::MIME_TYPE), $additionalStatData)));
     $this->_filesystemMock->expects($this->once())->method('getRemoteResource')->with($url)->will($this->returnValue($this->_handleMock));
     $this->_helper->setResource($url, DownloadHelper::LINK_TYPE_URL);
 }