You are here

class RealisticDummyContentDummyEnvironment in Realistic Dummy Content 7

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

Expanded class hierarchy of RealisticDummyContentDummyEnvironment

File

api/includes/RealisticDummyContentDummyEnvironment.inc, line 16
Define RealisticDummyContentLiveEnvironment autoload class.

View source
class RealisticDummyContentDummyEnvironment extends RealisticDummyContentEnvironment {
  private $files;
  function createFile($path, $data) {
    if (!is_array($this->files)) {
      $this->files = array();
    }
    $this->files[$path] = $data;
  }

  /**
   * {@inheritdoc}
   */
  function _file_get_contents_($filename) {
    if (isset($this->files[$filename])) {
      return $this->files[$filename];
    }
    trigger_error('file_get_contents(): failed to open stream');
    return NULL;
  }
  function _file_save_data_($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;
  }
  function _file_save_(stdClass $file) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RealisticDummyContentDummyEnvironment::$files private property
RealisticDummyContentDummyEnvironment::createFile function
RealisticDummyContentDummyEnvironment::_file_get_contents_ function Internal function used to get the contents of a file. Overrides RealisticDummyContentEnvironment::_file_get_contents_
RealisticDummyContentDummyEnvironment::_file_save_ function Overrides RealisticDummyContentEnvironment::_file_save_
RealisticDummyContentDummyEnvironment::_file_save_data_ function Overrides RealisticDummyContentEnvironment::_file_save_data_
RealisticDummyContentEnvironment::$env private static property
RealisticDummyContentEnvironment::addFileToArray static function
RealisticDummyContentEnvironment::AttributeName static function Returns the attribute of a filename if one exists
RealisticDummyContentEnvironment::FilenameRadical static function Returns the name radical of a filename.
RealisticDummyContentEnvironment::file_get_contents function Get the contents of a file.
RealisticDummyContentEnvironment::file_save function
RealisticDummyContentEnvironment::file_save_data function Save the file data to the real or test environment.
RealisticDummyContentEnvironment::Get static function Get the current environment.
RealisticDummyContentEnvironment::GetAllFileGroups static function Returns all files with a given extension for a given filepath.
RealisticDummyContentEnvironment::GetFileContents static function Returns the trimmed contents of a Drpual file object, or NULL if empty.
RealisticDummyContentEnvironment::getFileParts static function
RealisticDummyContentEnvironment::LowercaseRadicalNoExtension static function Returns the part of a string before the extension, in lowercase
RealisticDummyContentEnvironment::Replace static function Returns part of a filename
RealisticDummyContentEnvironment::Set static function Set the current environment
RealisticDummyContentEnvironment::SortCandidateFiles static function Given a list of candidate files, sort them by names and parts.
RealisticDummyContentEnvironment::SortCandidateFiles_ static function Given a list of candidate files, sort them by names and parts.
RealisticDummyContentEnvironment::validCandidateFilename static function