class vfsStreamWrapperRecordingProxy in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/proxy/vfsStreamWrapperRecordingProxy.php \org\bovigo\vfs\vfsStreamWrapperRecordingProxy
Stream wrapper to mock file system requests.
@since 0.10.0
Hierarchy
- class \org\bovigo\vfs\vfsStreamWrapper
- class \org\bovigo\vfs\vfsStreamWrapperRecordingProxy
Expanded class hierarchy of vfsStreamWrapperRecordingProxy
File
- vendor/
mikey179/ vfsStream/ src/ test/ php/ org/ bovigo/ vfs/ proxy/ vfsStreamWrapperRecordingProxy.php, line 16
Namespace
org\bovigo\vfsView source
class vfsStreamWrapperRecordingProxy extends vfsStreamWrapper {
/**
* list of called methods for a stream
*
* @var array
*/
protected static $calledMethods = array();
/**
* currently opened path
*
* @var string
*/
protected $path;
/**
* records method call for given path
*
* @param string $method
* @param string $path
*/
protected static function recordMethodCall($method, $path) {
if (isset(self::$calledMethods[$path]) === false) {
self::$calledMethods[$path] = array();
}
self::$calledMethods[$path][] = $method;
}
/**
* returns recorded method calls for given path
*
* @param string $path
* @return array<string>
*/
public static function getMethodCalls($path) {
if (isset(self::$calledMethods[$path]) === true) {
return self::$calledMethods[$path];
}
return array();
}
/**
* helper method for setting up vfsStream with the proxy
*
* @param string $rootDirName optional name of root directory
* @param int $permissions optional file permissions of root directory
* @return vfsStreamDirectory
* @throws vfsStreamException
*/
public static function setup($rootDirName = 'root', $permissions = null) {
self::$root = vfsStream::newDirectory($rootDirName, $permissions);
if (true === self::$registered) {
return self::$root;
}
if (@stream_wrapper_register(vfsStream::SCHEME, __CLASS__) === false) {
throw new vfsStreamException('A handler has already been registered for the ' . vfsStream::SCHEME . ' protocol.');
}
self::$registered = true;
return self::$root;
}
/**
* open the stream
*
* @param string $path the path to open
* @param string $mode mode for opening
* @param string $options options for opening
* @param string $opened_path full path that was actually opened
* @return bool
*/
public function stream_open($path, $mode, $options, $opened_path) {
$this->path = $path;
self::recordMethodCall('stream_open', $this->path);
return parent::stream_open($path, $mode, $options, $opened_path);
}
/**
* closes the stream
*/
public function stream_close() {
self::recordMethodCall('stream_close', $this->path);
return parent::stream_close();
}
/**
* read the stream up to $count bytes
*
* @param int $count amount of bytes to read
* @return string
*/
public function stream_read($count) {
self::recordMethodCall('stream_read', $this->path);
return parent::stream_read($count);
}
/**
* writes data into the stream
*
* @param string $data
* @return int amount of bytes written
*/
public function stream_write($data) {
self::recordMethodCall('stream_write', $this->path);
return parent::stream_write($data);
}
/**
* checks whether stream is at end of file
*
* @return bool
*/
public function stream_eof() {
self::recordMethodCall('stream_eof', $this->path);
return parent::stream_eof();
}
/**
* returns the current position of the stream
*
* @return int
*/
public function stream_tell() {
self::recordMethodCall('stream_tell', $this->path);
return parent::stream_tell();
}
/**
* seeks to the given offset
*
* @param int $offset
* @param int $whence
* @return bool
*/
public function stream_seek($offset, $whence) {
self::recordMethodCall('stream_seek', $this->path);
return parent::stream_seek($offset, $whence);
}
/**
* flushes unstored data into storage
*
* @return bool
*/
public function stream_flush() {
self::recordMethodCall('stream_flush', $this->path);
return parent::stream_flush();
}
/**
* returns status of stream
*
* @return array
*/
public function stream_stat() {
self::recordMethodCall('stream_stat', $this->path);
return parent::stream_stat();
}
/**
* retrieve the underlaying resource
*
* @param int $cast_as
* @return bool
*/
public function stream_cast($cast_as) {
self::recordMethodCall('stream_cast', $this->path);
return parent::stream_cast($cast_as);
}
/**
* set lock status for stream
*
* @param int $operation
* @return bool
*/
public function stream_lock($operation) {
self::recordMethodCall('stream_link', $this->path);
return parent::stream_lock($operation);
}
/**
* remove the data under the given path
*
* @param string $path
* @return bool
*/
public function unlink($path) {
self::recordMethodCall('unlink', $path);
return parent::unlink($path);
}
/**
* rename from one path to another
*
* @param string $path_from
* @param string $path_to
* @return bool
*/
public function rename($path_from, $path_to) {
self::recordMethodCall('rename', $path_from);
return parent::rename($path_from, $path_to);
}
/**
* creates a new directory
*
* @param string $path
* @param int $mode
* @param int $options
* @return bool
*/
public function mkdir($path, $mode, $options) {
self::recordMethodCall('mkdir', $path);
return parent::mkdir($path, $mode, $options);
}
/**
* removes a directory
*
* @param string $path
* @param int $options
* @return bool
*/
public function rmdir($path, $options) {
self::recordMethodCall('rmdir', $path);
return parent::rmdir($path, $options);
}
/**
* opens a directory
*
* @param string $path
* @param int $options
* @return bool
*/
public function dir_opendir($path, $options) {
$this->path = $path;
self::recordMethodCall('dir_opendir', $this->path);
return parent::dir_opendir($path, $options);
}
/**
* reads directory contents
*
* @return string
*/
public function dir_readdir() {
self::recordMethodCall('dir_readdir', $this->path);
return parent::dir_readdir();
}
/**
* reset directory iteration
*
* @return bool
*/
public function dir_rewinddir() {
self::recordMethodCall('dir_rewinddir', $this->path);
return parent::dir_rewinddir();
}
/**
* closes directory
*
* @return bool
*/
public function dir_closedir() {
self::recordMethodCall('dir_closedir', $this->path);
return parent::dir_closedir();
}
/**
* returns status of url
*
* @param string $path path of url to return status for
* @param int $flags flags set by the stream API
* @return array
*/
public function url_stat($path, $flags) {
self::recordMethodCall('url_stat', $path);
return parent::url_stat($path, $flags);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
vfsStreamWrapper:: |
protected | property | shortcut to file container | |
vfsStreamWrapper:: |
protected | property | shortcut to directory container | |
vfsStreamWrapper:: |
protected | property | shortcut to directory container iterator | |
vfsStreamWrapper:: |
protected | property | file mode: read only, write only, all | |
vfsStreamWrapper:: |
private static | property | disk space quota | |
vfsStreamWrapper:: |
protected static | property | switch whether class has already been registered as stream wrapper or not | |
vfsStreamWrapper:: |
protected static | property | root content | |
vfsStreamWrapper:: |
constant | file mode: read and write | ||
vfsStreamWrapper:: |
constant | set file pointer to end, append new data | ||
vfsStreamWrapper:: |
protected | function | calculates the file mode | |
vfsStreamWrapper:: |
private | function | creates a file at given path | |
vfsStreamWrapper:: |
private | function | executes given permission change when necessary rights allow such a change | |
vfsStreamWrapper:: |
protected | function | removes a path | |
vfsStreamWrapper:: |
protected | function | returns content for given path | |
vfsStreamWrapper:: |
protected | function | returns content for given path but only when it is of given type | |
vfsStreamWrapper:: |
public static | function | returns the root content | |
vfsStreamWrapper:: |
private | function | helper method to detect whether given path is in root path | |
vfsStreamWrapper:: |
constant | open file for reading | ||
vfsStreamWrapper:: |
constant | file mode: read only | ||
vfsStreamWrapper:: |
public static | function | method to register the stream wrapper | |
vfsStreamWrapper:: |
protected | function | helper method to resolve a path from /foo/bar/. to /foo/bar | |
vfsStreamWrapper:: |
public static | function | sets quota for disk space | |
vfsStreamWrapper:: |
public static | function | sets the root content | |
vfsStreamWrapper:: |
protected | function | splits path into its dirname and the basename | |
vfsStreamWrapper:: |
public | function | sets metadata like owner, user or permissions | |
vfsStreamWrapper:: |
public | function | sets options on the stream | |
vfsStreamWrapper:: |
public | function | truncates a file to a given length | |
vfsStreamWrapper:: |
constant | truncate file | ||
vfsStreamWrapper:: |
public static | function | Unregisters a previously registered URL wrapper for the vfs scheme. | 1 |
vfsStreamWrapper:: |
constant | set file pointer to start, overwrite existing data | ||
vfsStreamWrapper:: |
constant | file mode: write only | ||
vfsStreamWrapper:: |
constant | set file pointer to start, overwrite existing data; or create file if does not exist | ||
vfsStreamWrapperRecordingProxy:: |
protected static | property | list of called methods for a stream | |
vfsStreamWrapperRecordingProxy:: |
protected | property | currently opened path | |
vfsStreamWrapperRecordingProxy:: |
public | function |
closes directory Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
opens a directory Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
reads directory contents Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
reset directory iteration Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public static | function | returns recorded method calls for given path | |
vfsStreamWrapperRecordingProxy:: |
public | function |
creates a new directory Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
protected static | function | records method call for given path | |
vfsStreamWrapperRecordingProxy:: |
public | function |
rename from one path to another Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
removes a directory Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public static | function | helper method for setting up vfsStream with the proxy | |
vfsStreamWrapperRecordingProxy:: |
public | function |
retrieve the underlaying resource Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
closes the stream Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
checks whether stream is at end of file Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
flushes unstored data into storage Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
set lock status for stream Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
open the stream Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
read the stream up to $count bytes Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
seeks to the given offset Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
returns status of stream Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
returns the current position of the stream Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
writes data into the stream Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
remove the data under the given path Overrides vfsStreamWrapper:: |
|
vfsStreamWrapperRecordingProxy:: |
public | function |
returns status of url Overrides vfsStreamWrapper:: |