php - FilesystemIterator with vfsStream -


i using (learning) vfsstream test file system operations on directory tree 23,000 items in it.

here's trying in phpunit test:

    public function testmockfs() {         $buffer = (array) json_decode(file_get_contents(__dir__ . '/resources/structure.json'));         $root = vfsstream::setup('/',null,$buffer);          $it = new filesystemiterator($root);         foreach ($it $fileinfo) {             echo $fileinfo->getfilename() . "\n";     }  } 

note: know doesn't test anything. right now, trying iteration working, , want print directory structure screen before start writing tests.

structure.json dump production contains complete reproduction of filesystem (without filecontent, irrelevant we're working on).

vfsstream::setup() appears work fine. no errors.

how iterate vfssystem using filesystemiterator? feel either 1) $root should return directory vfs filesystemiterator can work with, or b) should passing "vfs::/" argument, filesystemiterator doesn't know "vfs::" things are.

i'm sure i'm making harder has be. in advance.

i figured out. have use vfsstream::url('/path/to/directory/you/want');

public function testmockfs() {     $buffer = (array) json_decode(file_get_contents(__dir__ . '/resources/structure.json'));     $root = vfsstream::setup('/',null,$buffer);      $it = new filesystemiterator(vfsstream::url('/'));     foreach ($it $fileinfo) {         echo $fileinfo->getfilename() . "\n"; } 

}


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -