public function testGetData() { $asset = $this->getMock('Magento\\Framework\\View\\Asset\\File', [], [], '', false); $chain = $this->getMock('Magento\\Framework\\View\\Asset\\PreProcessor\\Chain', [], [], '', false); $context = $this->getMock('Magento\\Framework\\View\\Asset\\File\\FallbackContext', [], [], '', false); $originalContent = 'content$.mage.__("hello1")content'; $translatedContent = 'content"hello1"content'; $patterns = ['~\\$\\.mage\\.__\\([\'|\\"](.+?)[\'|\\"]\\)~']; $areaCode = 'adminhtml'; $area = $this->getMock('Magento\\Framework\\App\\Area', [], [], '', false); $chain->expects($this->once())->method('getAsset')->willReturn($asset); $asset->expects($this->once())->method('getContext')->willReturn($context); $context->expects($this->once())->method('getAreaCode')->willReturn($areaCode); $this->configMock->expects($this->once())->method('isEmbeddedStrategy')->willReturn(true); $chain->expects($this->once())->method('getContent')->willReturn($originalContent); $this->configMock->expects($this->once())->method('getPatterns')->willReturn($patterns); $this->areaListMock->expects($this->once())->method('getArea')->with($areaCode)->willReturn($area); $chain->expects($this->once())->method('setContent')->with($translatedContent); $this->model->process($chain); }
public function testGetData() { $chain = $this->getMock('Magento\\Framework\\View\\Asset\\PreProcessor\\Chain', [], [], '', false); $asset = $this->getMock('Magento\\Framework\\View\\Asset\\File', [], [], '', false); $context = $this->getMock('Magento\\Framework\\View\\Asset\\File\\FallbackContext', [], [], '', false); $fileName = 'js-translation.json'; $targetPath = 'path/js-translation.json'; $themePath = '*/*'; $dictionary = ['hello' => 'bonjour']; $areaCode = 'adminhtml'; $area = $this->getMock('Magento\\Framework\\App\\Area', [], [], '', false); $chain->expects($this->once())->method('getTargetAssetPath')->willReturn($targetPath); $this->configMock->expects($this->once())->method('getDictionaryFileName')->willReturn($fileName); $chain->expects($this->once())->method('getAsset')->willReturn($asset); $asset->expects($this->once())->method('getContext')->willReturn($context); $context->expects($this->once())->method('getThemePath')->willReturn($themePath); $context->expects($this->once())->method('getAreaCode')->willReturn($areaCode); $this->areaListMock->expects($this->once())->method('getArea')->with($areaCode)->willReturn($area); $this->dataProviderMock->expects($this->once())->method('getData')->with($themePath)->willReturn($dictionary); $chain->expects($this->once())->method('setContent')->with(json_encode($dictionary)); $chain->expects($this->once())->method('setContentType')->with('json'); $this->model->process($chain); }
public function testGetAllScopes() { $expectedBalances = array('primary', 'test_scope'); $this->areaListMock->expects($this->once())->method('getCodes')->will($this->returnValue(array('test_scope'))); $this->assertEquals($expectedBalances, $this->model->getAllScopes()); }