Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: Roeland Jago Douma <[email protected]>
  • Loading branch information
rullzer committed Feb 14, 2019
1 parent 3c98a75 commit 3a28b61
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/CallbackWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ class CallbackWrapperTest extends WrapperTest {
* @param callable $write
* @param callable $close
* @param callable $readDir
* @param callable $preClose
* @return resource
*/
protected function wrapSource($source, $read = null, $write = null, $close = null, $readDir = null) {
return \Icewind\Streams\CallbackWrapper::wrap($source, $read, $write, $close, $readDir);
protected function wrapSource($source, $read = null, $write = null, $close = null, $readDir = null, $preClose = null) {
return \Icewind\Streams\CallbackWrapper::wrap($source, $read, $write, $close, $readDir, $preClose);
}

/**
Expand Down Expand Up @@ -83,4 +84,21 @@ public function testReadDirCallback() {
readdir($wrapped);
$this->assertTrue($called);
}

public function testPreCloseCallback() {
$called = false;

$source = fopen('php://temp', 'r+');
fwrite($source, 'foobar');
rewind($source);

$callBack = function ($stream) use (&$called, $source) {
$called = true;
$this->assertSame($stream, $source);
};

$wrapped = $this->wrapSource($source, null, null, null, null, $callBack);
fclose($wrapped);
$this->assertTrue($called);
}
}

0 comments on commit 3a28b61

Please sign in to comment.