Add directory support to wrappers

This commit is contained in:
Robin Appelman 2014-08-27 15:36:58 +02:00
commit 53cfe7f4f1
5 changed files with 121 additions and 28 deletions

View file

@ -14,10 +14,11 @@ class CallbackWrapper extends Wrapper {
* @param callable $read
* @param callable $write
* @param callable $close
* @param callable $readDir
* @return resource
*/
protected function wrapSource($source, $read = null, $write = null, $close = null) {
return \Icewind\Streams\CallbackWrapper::wrap($source, $read, $write, $close);
protected function wrapSource($source, $read = null, $write = null, $close = null, $readDir = null) {
return \Icewind\Streams\CallbackWrapper::wrap($source, $read, $write, $close, $readDir);
}
/**
@ -69,4 +70,17 @@ class CallbackWrapper extends Wrapper {
fclose($wrapped);
$this->assertTrue($called);
}
public function testReadDirCallback() {
$called = false;
$callBack = function () use (&$called) {
$called = true;
};
$source = opendir(sys_get_temp_dir());
$wrapped = $this->wrapSource($source, null, null, null, $callBack);
readdir($wrapped);
$this->assertTrue($called);
}
}