getFilesRecursivelyWithSpecifiedExtension() public static method

Returns all files from the given directory that have the given extension.
public static getFilesRecursivelyWithSpecifiedExtension ( string $dir, string $extension ) : array
$dir string
$extension string
return array
示例#1
0
 /**
  * @test
  */
 public function shouldGetFilesRecursivelyByExtension()
 {
     //given
     $dirPath = Path::joinWithTemp('test', 'tests_find_files', 'new_dir', 'second_new_dir');
     mkdir($dirPath, 0777, true);
     $file1 = Path::joinWithTemp('test', 'tests_find_files', 'file1a.phtml');
     touch($file1);
     $file2 = Path::joinWithTemp('test', 'tests_find_files', 'new_dir', 'file2a.phtml');
     touch($file2);
     $file3 = Path::joinWithTemp('test', 'tests_find_files', 'new_dir', 'second_new_dir', 'file3a.phtml');
     touch($file3);
     //when
     $files = Files::getFilesRecursivelyWithSpecifiedExtension(Path::joinWithTemp('test', 'tests_find_files'), 'phtml');
     //then
     DeleteDirectory::recursive($dirPath);
     Assert::thatArray($files)->hasSize(3)->contains($file1, $file2, $file3);
 }