/**
  * @return \RegexIterator
  */
 protected function _getFiles()
 {
     $filesCollector = new FilesCollector();
     $componentRegistrar = new ComponentRegistrar();
     $paths = array_merge($componentRegistrar->getPaths(ComponentRegistrar::MODULE), $componentRegistrar->getPaths(ComponentRegistrar::LIBRARY));
     return $filesCollector->getFiles($paths, '/\\.(php|phtml)$/');
 }
 /**
  * @param array $options
  * @param array $phpFiles
  * @param array $jsFiles
  * @param array $phpMap
  * @param array $jsMap
  * @paran array $phraseFactoryMap
  * @param array $expectedResult
  * @dataProvider addPhraseDataProvider
  */
 public function testAddPhrase($options, $phpFiles, $jsFiles, $phpMap, $jsMap, $phraseFactoryMap, $expectedResult)
 {
     // 1. Create mocks
     $phpAdapter = new AdapterStub();
     $jsAdapter = new AdapterStub();
     // 2. Set mocks
     $this->parser->addAdapter('php', $phpAdapter);
     $this->parser->addAdapter('js', $jsAdapter);
     //3. Set fixtures
     $phpAdapter->setValueMap($phpMap);
     $jsAdapter->setValueMap($jsMap);
     $this->factory->expects($this->any())->method('createPhrase')->with()->willReturnMap($phraseFactoryMap);
     //4. Set expectations
     $this->filesCollector->expects($this->any())->method('getFiles')->will($this->returnValueMap([[$options[0]['paths'], '', $phpFiles], [$options[1]['paths'], '', $jsFiles]]));
     $result = $this->parser->parse($options);
     $this->assertEquals($expectedResult, $result);
 }
Beispiel #3
0
 /**
  * @return \RegexIterator
  */
 protected function _getFiles()
 {
     $filesCollector = new \Magento\Setup\Module\I18n\FilesCollector();
     return $filesCollector->getFiles([\Magento\Framework\App\Utility\Files::init()->getPathToSource()], '/\\.(php|phtml)$/');
 }
 public function testGetFilesWithMask()
 {
     $expectedResult = [$this->_testDir . 'file.js'];
     $this->assertEquals($expectedResult, $this->_filesCollector->getFiles([$this->_testDir], '/\\.js$/'));
 }
 /**
  * Get files for parsing
  *
  * @param array $options
  * @return array
  */
 protected function _getFiles($options)
 {
     $fileMask = isset($options['fileMask']) ? $options['fileMask'] : '';
     return $this->_filesCollector->getFiles($options['paths'], $fileMask);
 }