mirror of
https://codeberg.org/icewind/streams.git
synced 2026-06-03 16:44:07 +02:00
Add directory support to wrappers
This commit is contained in:
parent
448dfc577c
commit
53cfe7f4f1
5 changed files with 121 additions and 28 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue