Skip to content

Commit

Permalink
Merge pull request #86 from l0gicgate/AddStreamGetMetadataTest
Browse files Browse the repository at this point in the history
Add test coverage for Stream::getMetadata
  • Loading branch information
l0gicgate committed May 3, 2019
2 parents 6fb2748 + 30956c3 commit 8ce2c78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function __construct($stream)
public function getMetadata($key = null)
{
if (!$this->stream) {
return $this->meta;
return null;
}

$this->meta = stream_get_meta_data($this->stream);
Expand Down
9 changes: 9 additions & 0 deletions tests/StreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ public function testAttachAgain()
$attachMethod->invoke($stream, $this->pipeFh);
}

public function testGetMetaDataReturnsNullIfStreamIsDetached()
{
$resource = fopen('php://temp', 'rw+');
$stream = new Stream($resource);
$stream->detach();

$this->assertNull($stream->getMetadata());
}

private function openPipeStream()
{
$this->pipeFh = popen('echo 12', 'r');
Expand Down

0 comments on commit 8ce2c78

Please sign in to comment.