Use fstat to read the size of the resource in Stream
This commit is contained in:
parent
5cc259944e
commit
cbeadbda53
|
|
@ -68,7 +68,8 @@ class Stream implements StreamableInterface
|
|||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return null;
|
||||
$statistics = fstat($this->handle);
|
||||
return $statistics["size"] ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -108,10 +108,10 @@ class StreamTest extends \PHPUnit_Framework_TestCase
|
|||
* @covers WellRESTed\Stream\Stream::getSize
|
||||
* @uses WellRESTed\Stream\Stream
|
||||
*/
|
||||
public function testReturnsNullForSize()
|
||||
public function testReturnsSize()
|
||||
{
|
||||
$stream = new Stream($this->handle);
|
||||
$this->assertNull($stream->getSize());
|
||||
$this->assertEquals(strlen($this->content), $stream->getSize());
|
||||
}
|
||||
|
||||
/**
|
||||
Loading…
Reference in New Issue