function it_returns_an_array_of_translation_resources_paths(FinderFactoryInterface $finderFactory, Finder $finder)
 {
     $finderFactory->create()->willReturn($finder);
     $finder->in('/theme')->shouldBeCalled()->willReturn($finder);
     $finder->ignoreUnreadableDirs()->shouldBeCalled()->willReturn($finder);
     $finder->getIterator()->willReturn(new \ArrayIterator(['/theme/messages.en.yml', '/theme/translations/messages.en.yml', '/theme/translations/messages.en.yml.jpg', '/theme/translations/messages.yml', '/theme/AcmeBundle/translations/messages.pl_PL.yml']));
     $this->findTranslationFiles('/theme')->shouldReturn(['/theme/translations/messages.en.yml', '/theme/AcmeBundle/translations/messages.pl_PL.yml']);
 }
 function it_throws_an_exception_if_there_is_there_are_not_any_files_that_matches_the_given_name(FinderFactoryInterface $finderFactory, Finder $finder)
 {
     $finderFactory->create()->willReturn($finder);
     $finder->name('readme.md')->shouldBeCalled()->willReturn($finder);
     $finder->in('/search/path/')->shouldBeCalled()->willReturn($finder);
     $finder->ignoreUnreadableDirs()->shouldBeCalled()->willReturn($finder);
     $finder->files()->shouldBeCalled()->willReturn($finder);
     $finder->getIterator()->willReturn(new \ArrayIterator());
     $this->shouldThrow(\InvalidArgumentException::class)->during('locateFilesNamed', ['readme.md']);
 }
예제 #3
0
 /**
  * @param string $name
  *
  * @return \Generator
  */
 private function doLocateFilesNamed($name)
 {
     $this->assertNameIsNotEmpty($name);
     $finder = $this->finderFactory->create();
     $finder->files()->name($name)->ignoreUnreadableDirs()->in($this->paths);
     $this->assertThatAtLeastOneFileWasFound($finder, $name);
     /** @var SplFileInfo $file */
     foreach ($finder as $file) {
         (yield $file->getPathname());
     }
 }
예제 #4
0
 /**
  * @param string $name
  *
  * @return \Generator
  */
 private function doLocateFilesNamed($name)
 {
     $this->assertNameIsNotEmpty($name);
     $found = false;
     foreach ($this->paths as $path) {
         try {
             $finder = $this->finderFactory->create();
             $finder->files()->name($name)->ignoreUnreadableDirs()->in($path);
             /** @var SplFileInfo $file */
             foreach ($finder as $file) {
                 $found = true;
                 (yield $file->getPathname());
             }
         } catch (\InvalidArgumentException $exception) {
         }
     }
     if (false === $found) {
         throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (searched in the following directories: %s).', $name, implode(', ', $this->paths)));
     }
 }
 /**
  * @param string $path
  *
  * @return array
  */
 private function getFiles($path)
 {
     $finder = $this->finderFactory->create();
     $finder->ignoreUnreadableDirs()->in($path);
     return $finder;
 }
예제 #6
0
 /**
  * @param ThemeInterface $theme
  *
  * @return array
  */
 private function getThemeFiles(ThemeInterface $theme)
 {
     $finder = $this->finderFactory->create();
     $finder->ignoreUnreadableDirs()->in($theme->getPath());
     return $finder;
 }