public function testFindMultipleFile() { $normalizer = new Normalizer($this->getCacheDir()); $locator = new Locator($normalizer); // locator MUST find multiple files in a directory mkdir($this->getCacheDir() . '/test'); touch($this->getCacheDir() . '/test/test.css'); touch($this->getCacheDir() . '/test/test2.css'); $sources = $locator->locate($this->getCacheDir() . '/test'); $this->assertCount(2, $sources); $this->assertEquals($this->getCacheDir() . '/test/test.css', $sources[0]->getRealPath()); $this->assertEquals($this->getCacheDir() . '/test/test2.css', $sources[1]->getRealPath()); $this->assertInstanceOf(Normalizer::class, $locator->getNormalizer()); }
/** * Filter only the sources supported by the current filter. * * @param SplFileInfo[] $sources * @param FilterInterface $filter * @return array * @throws Exception */ protected function filterSources(array $sources, FilterInterface $filter) { $filteredSources = []; // if the filter supports no extension, there is an error if (!is_array($filter->getSupportedExtensions()) || !count($filter->getSupportedExtensions())) { throw new Exception('No supported extensions found for the filter ' . $filter->getName()); } foreach ($sources as $source) { $isExtensionSupported = in_array($source->getExtension(), $filter->getSupportedExtensions()); $supportAllExtensions = in_array('*', $filter->getSupportedExtensions()); if ($isExtensionSupported || $supportAllExtensions) { $filteredSources[] = $this->locator->getNormalizer()->normalize($source); } } return $filteredSources; }