add PathWrapper to get a virtual path for an existing file

This commit is contained in:
Robin Appelman 2016-10-26 22:08:04 +02:00
commit 5981b1b39c
4 changed files with 55 additions and 5 deletions

24
tests/PathWrapper.php Normal file
View file

@ -0,0 +1,24 @@
<?php
/**
* Copyright (c) 2016 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\Streams\Tests;
class PathWrapper extends \PHPUnit_Framework_TestCase {
private function getDataStream($data) {
$stream = fopen('php://temp', 'w+');
fwrite($stream, $data);
rewind($stream);
return $stream;
}
public function testFileGetContents() {
$data = 'foobar';
$stream = $this->getDataStream($data);
$path = \Icewind\Streams\PathWrapper::getPath($stream);
$this->assertEquals($data, file_get_contents($path));
}
}