Changeset 47122 for trunk/tests/phpunit/includes/mock-fs.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/mock-fs.php
r46586 r47122 6 6 private $fs = null; 7 7 8 // Holds a array of /path/to/file.php and /path/to/dir/ map to an object in $fs above 9 // a fast more efficient way of determining if a path exists, and access to that node8 // Holds a array of /path/to/file.php and /path/to/dir/ map to an object in $fs above. 9 // A fast, more efficient way of determining if a path exists, and access to that node. 10 10 private $fs_map = array(); 11 11 … … 27 27 $folder = $this->find_folder( $path ); 28 28 29 // Perhaps the FTP folder is rooted at the WordPress installation, Check for wp-includes folder in root, Could have some false positives, but rare. 29 // Perhaps the FTP folder is rooted at the WordPress installation. 30 // Check for wp-includes folder in root, could have some false positives, but rare. 30 31 if ( ! $folder && $this->is_dir( '/wp-includes' ) ) { 31 32 $folder = '/'; … … 34 35 } 35 36 36 // Mock FS 37 // Mock FS-specific functions: 37 38 38 39 /** … … 45 46 '/' => $this->fs, 46 47 ); 47 $this->cache = array(); // Used by find_folder() and friends 48 $this->cache = array(); // Used by find_folder() and friends. 48 49 $this->cwd = isset( $this->fs_map[ $home_dir ] ) ? $this->fs_map[ $home_dir ] : '/'; 49 50 $this->setfs( $paths ); … … 61 62 62 63 foreach ( $paths as $path ) { 63 // Allow for comments 64 // Allow for comments. 64 65 if ( '#' === $path[0] ) { 65 66 continue; 66 67 } 67 68 68 // Directories 69 // Directories. 69 70 if ( '/' === $path[ strlen( $path ) - 1 ] ) { 70 71 $this->mkdir( $path ); 71 } else { // Files (with dummy content for now) 72 } else { // Files (with dummy content for now). 72 73 $this->put_contents( $path, 'This is a test file' ); 73 74 } … … 210 211 211 212 class MockFS_Node { 212 public $name; // The "name" of the entry, does not include a slash (exception, root) 213 public $type; // The type of the entry 'f' for file, 'd' for Directory213 public $name; // The "name" of the entry, does not include a slash (exception, root). 214 public $type; // The type of the entry 'f' for file, 'd' for directory. 214 215 public $path; // The full path to the entry. 215 216 … … 230 231 class MockFS_Directory_Node extends MockFS_Node { 231 232 public $type = 'd'; 232 public $children = array(); // The child nodes of this directory 233 public $children = array(); // The child nodes of this directory. 233 234 } 234 235 235 236 class MockFS_File_Node extends MockFS_Node { 236 237 public $type = 'f'; 237 public $contents = ''; // The contents of the file 238 public $contents = ''; // The contents of the file. 238 239 239 240 function __construct( $path, $contents = '' ) {
Note: See TracChangeset
for help on using the changeset viewer.