class RealisticDummyContentDummyEnvironment in Realistic Dummy Content 8.2
Same name and namespace in other branches
- 7.2 api/src/includes/RealisticDummyContentDummyEnvironment.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentDummyEnvironment
The dummy environment.
During normal execution, we want to do things like interact with the file- system and such. However during testing we want to abstract that away. This class represents the dummy environment which can be used during unit tests.
Hierarchy
- class \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentEnvironment
- class \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentDummyEnvironment
Expanded class hierarchy of RealisticDummyContentDummyEnvironment
File
- api/
src/ includes/ RealisticDummyContentDummyEnvironment.php, line 12
Namespace
Drupal\realistic_dummy_content_api\includesView source
class RealisticDummyContentDummyEnvironment extends RealisticDummyContentEnvironment {
private $files;
/**
* {@inheritdoc}
*/
public function createFile($path, $data) {
if (!is_array($this->files)) {
$this->files = array();
}
$this->files[$path] = $data;
}
/**
* {@inheritdoc}
*/
public function fileGetContents($filename) {
if (isset($this->files[$filename])) {
return $this->files[$filename];
}
trigger_error('file_get_contents(): failed to open stream');
return NULL;
}
/**
* {@inheritdoc}
*/
public function fileSaveData($data, $destination = NULL) {
if (!$destination) {
throw new \Exception('the dummy file system is not designed to use null destination');
}
$parsed = parse_url($destination);
$return_array = array(
'fid' => 1,
'uri' => $destination,
'filename' => $parsed['host'],
);
return (object) $return_array;
}
/**
* {@inheritdoc}
*/
public function fileSave(stdClass $file) {
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RealisticDummyContentDummyEnvironment:: |
private | property | ||
RealisticDummyContentDummyEnvironment:: |
public | function | ||
RealisticDummyContentDummyEnvironment:: |
public | function |
Get the contents of a file. Overrides RealisticDummyContentEnvironment:: |
|
RealisticDummyContentDummyEnvironment:: |
public | function |
Saves a file. Overrides RealisticDummyContentEnvironment:: |
|
RealisticDummyContentDummyEnvironment:: |
public | function |
Save the file data to the real or test environment. Overrides RealisticDummyContentEnvironment:: |
|
RealisticDummyContentEnvironment:: |
private static | property | Private variable containing the environment to use. | |
RealisticDummyContentEnvironment:: |
public static | function | Adds a file to an array of file group parts. | |
RealisticDummyContentEnvironment:: |
public static | function | Returns the attribute of a filename if one exists. | |
RealisticDummyContentEnvironment:: |
public static | function | Returns the name radical of a filename. | |
RealisticDummyContentEnvironment:: |
public static | function | Get the current environment. | |
RealisticDummyContentEnvironment:: |
public static | function | Returns all files with a given extension for a given filepath. | |
RealisticDummyContentEnvironment:: |
public static | function | Returns the trimmed contents of a Drpual file object, or NULL if empty. | |
RealisticDummyContentEnvironment:: |
public static | function | Retrieves the parts constituting a filename. | |
RealisticDummyContentEnvironment:: |
abstract public | function | Internal function used to get the contents of a file. | 1 |
RealisticDummyContentEnvironment:: |
abstract public | function | Implements $this->fileSave(). | 1 |
RealisticDummyContentEnvironment:: |
abstract public | function | Implements $this->fileSaveData(). | 1 |
RealisticDummyContentEnvironment:: |
public static | function | Given a list of candidate files, sort them by names and parts. | |
RealisticDummyContentEnvironment:: |
public static | function | Returns the part of a string before the extension, in lowercase. | |
RealisticDummyContentEnvironment:: |
public static | function | Returns part of a filename. | |
RealisticDummyContentEnvironment:: |
public static | function | Set the current environment. | |
RealisticDummyContentEnvironment:: |
public static | function | Given a list of candidate files, sort them by names and parts. | |
RealisticDummyContentEnvironment:: |
public static | function | Wrapper around drupal_strtolower(if it exists) or strtolower. | |
RealisticDummyContentEnvironment:: |
public static | function | Checks if a filename is valid. |