mirror of
https://github.com/adlawson/php-vfs.git
synced 2024-11-23 04:52:07 +00:00
Add file_get_contents
acceptance tests
Also includes tests for `file_put_contents`.
This commit is contained in:
parent
c937b5a286
commit
6854d33591
@ -5,9 +5,9 @@
|
||||
|
||||
<!-- Test suites -->
|
||||
<testsuites>
|
||||
<!-- <testsuite name="acceptance">
|
||||
<testsuite name="acceptance">
|
||||
<directory suffix="AcceptanceTest.php">test/acceptance</directory>
|
||||
</testsuite> -->
|
||||
</testsuite>
|
||||
<testsuite name="functional">
|
||||
<directory suffix="FunctionalTest.php">test/functional</directory>
|
||||
</testsuite>
|
||||
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace Vfs\Stream\StreamWrapper;
|
||||
|
||||
use Vfs\Test\AcceptanceTestCase;
|
||||
|
||||
class FileGetContentsAcceptanceTest extends AcceptanceTestCase
|
||||
{
|
||||
protected $tree = [
|
||||
'foo' => [
|
||||
'bar' => 'baz'
|
||||
]
|
||||
];
|
||||
|
||||
public function testGetFile()
|
||||
{
|
||||
$this->assertEquals($this->tree['foo']['bar'], file_get_contents("$this->scheme://foo/bar"));
|
||||
}
|
||||
|
||||
public function testPutFile()
|
||||
{
|
||||
file_put_contents("$this->scheme://foo/bar", 'bar');
|
||||
|
||||
$this->assertEquals('bar', $this->fs->get('/foo/bar')->getContent());
|
||||
}
|
||||
|
||||
public function testPutExistingFile()
|
||||
{
|
||||
file_put_contents("$this->scheme://foo/bar", '_updated');
|
||||
|
||||
$this->assertEquals('_updated', $this->fs->get('/foo/bar')->getContent());
|
||||
}
|
||||
|
||||
public function testPutAppendExistingFile()
|
||||
{
|
||||
file_put_contents("$this->scheme://foo/bar", '_updated', FILE_APPEND);
|
||||
|
||||
$this->assertEquals($this->tree['foo']['bar'] . '_updated', $this->fs->get('/foo/bar')->getContent());
|
||||
}
|
||||
}
|
46
test/src/AcceptanceTestCase.php
Normal file
46
test/src/AcceptanceTestCase.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of VFS
|
||||
*
|
||||
* Copyright (c) 2014 Andrew Lawson <http://adlawson.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Vfs\Test;
|
||||
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
use Vfs\FileSystemBuilder;
|
||||
use Vfs\FileSystemInterface;
|
||||
|
||||
class AcceptanceTestCase extends TestCase
|
||||
{
|
||||
protected $fs;
|
||||
protected $tree = [];
|
||||
protected $scheme = 'vfs';
|
||||
protected $wrapperClass = 'Vfs\Stream\StreamWrapper';
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->fs = $this->buildFileSystem($this->wrapperClass);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
if (in_array($this->scheme, stream_get_wrappers())) {
|
||||
$this->fs->unmount();
|
||||
}
|
||||
}
|
||||
|
||||
protected function buildFileSystem()
|
||||
{
|
||||
$builder = new FileSystemBuilder($this->scheme);
|
||||
$builder->setStreamWrapper($this->wrapperClass);
|
||||
$builder->setTree($this->tree);
|
||||
|
||||
$fs = $builder->build();
|
||||
$fs->mount();
|
||||
|
||||
return $fs;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user