2014-09-06 13:24:45 +00:00
|
|
|
<?php
|
|
|
|
namespace Vfs\Stream\StreamWrapper;
|
|
|
|
|
|
|
|
use Vfs\Test\AcceptanceTestCase;
|
|
|
|
|
|
|
|
class FileGetContentsAcceptanceTest extends AcceptanceTestCase
|
|
|
|
{
|
|
|
|
protected $tree = [
|
|
|
|
'foo' => [
|
|
|
|
'bar' => 'baz'
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
2014-09-06 13:43:43 +00:00
|
|
|
public function testGetDirectory()
|
|
|
|
{
|
2014-09-06 23:44:12 +00:00
|
|
|
$this->assertEquals('', file_get_contents("$this->scheme:///foo"));
|
2014-09-06 13:43:43 +00:00
|
|
|
}
|
|
|
|
|
2014-09-06 13:24:45 +00:00
|
|
|
public function testGetFile()
|
|
|
|
{
|
2014-09-06 23:44:12 +00:00
|
|
|
$this->assertEquals($this->tree['foo']['bar'], file_get_contents("$this->scheme:///foo/bar"));
|
2014-09-06 13:24:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testPutFile()
|
|
|
|
{
|
2014-09-06 23:44:12 +00:00
|
|
|
file_put_contents("$this->scheme:///foo/bar", 'bar');
|
2014-09-06 13:24:45 +00:00
|
|
|
|
|
|
|
$this->assertEquals('bar', $this->fs->get('/foo/bar')->getContent());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testPutExistingFile()
|
|
|
|
{
|
2014-09-06 23:44:12 +00:00
|
|
|
file_put_contents("$this->scheme:///foo/bar", '_updated');
|
2014-09-06 13:24:45 +00:00
|
|
|
|
|
|
|
$this->assertEquals('_updated', $this->fs->get('/foo/bar')->getContent());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testPutAppendExistingFile()
|
|
|
|
{
|
2014-09-06 23:44:12 +00:00
|
|
|
file_put_contents("$this->scheme:///foo/bar", '_updated', FILE_APPEND);
|
2014-09-06 13:24:45 +00:00
|
|
|
|
|
|
|
$this->assertEquals($this->tree['foo']['bar'] . '_updated', $this->fs->get('/foo/bar')->getContent());
|
|
|
|
}
|
|
|
|
}
|