Ejemplo n.º 1
0
 /**
  * @param string $area
  * @param bool $forceReload
  * @param array $cachedData
  * @dataProvider dataProviderForTestLoadData
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function testLoadData($area, $forceReload, $cachedData)
 {
     $this->expectsSetConfig('themeId');
     $this->cache->expects($this->exactly($forceReload ? 0 : 1))->method('load')->will($this->returnValue(serialize($cachedData)));
     if (!$forceReload && $cachedData !== false) {
         $this->translate->loadData($area, $forceReload);
         $this->assertEquals($cachedData, $this->translate->getData());
         return;
     }
     $this->directory->expects($this->any())->method('isExist')->will($this->returnValue(true));
     // _loadModuleTranslation()
     $this->moduleList->expects($this->once())->method('getNames')->will($this->returnValue(['name']));
     $moduleData = ['module original' => 'module translated', 'module theme' => 'module-theme original translated', 'module pack' => 'module-pack original translated', 'module db' => 'module-db original translated'];
     $this->modulesReader->expects($this->any())->method('getModuleDir')->will($this->returnValue('/app/module'));
     $themeData = ['theme original' => 'theme translated', 'module theme' => 'theme translated overwrite', 'module pack' => 'theme-pack translated overwrite', 'module db' => 'theme-db translated overwrite'];
     $this->csvParser->expects($this->any())->method('getDataPairs')->will($this->returnValueMap([['/app/module/en_US.csv', 0, 1, $moduleData], ['/app/module/en_GB.csv', 0, 1, $moduleData], ['/theme.csv', 0, 1, $themeData]]));
     // _loadThemeTranslation()
     $this->viewFileSystem->expects($this->any())->method('getLocaleFileName')->will($this->returnValue('/theme.csv'));
     // _loadPackTranslation
     $packData = ['pack original' => 'pack translated', 'module pack' => 'pack translated overwrite', 'module db' => 'pack-db translated overwrite'];
     $this->packDictionary->expects($this->once())->method('getDictionary')->will($this->returnValue($packData));
     // _loadDbTranslation()
     $dbData = ['db original' => 'db translated', 'module db' => 'db translated overwrite'];
     $this->resource->expects($this->any())->method('getTranslationArray')->will($this->returnValue($dbData));
     $this->cache->expects($this->exactly(1))->method('save');
     $this->translate->loadData($area, $forceReload);
     $expected = ['module original' => 'module translated', 'module theme' => 'theme translated overwrite', 'module pack' => 'pack translated overwrite', 'module db' => 'db translated overwrite', 'theme original' => 'theme translated', 'pack original' => 'pack translated', 'db original' => 'db translated'];
     $this->assertEquals($expected, $this->translate->getData());
 }
Ejemplo n.º 2
0
 public function testWrite()
 {
     $options = ['report_filename' => 'some_filename'];
     $configMock = $this->getMock('Magento\\Setup\\Module\\Dependency\\Report\\Data\\ConfigInterface');
     $preparedData = ['foo', 'baz', 'bar'];
     $this->writer->expects($this->once())->method('prepareData')->with($configMock)->will($this->returnValue($preparedData));
     $this->csvMock->expects($this->once())->method('saveData')->with($options['report_filename'], $preparedData);
     $this->writer->write($options, $configMock);
 }