Changeset 52009 for trunk/tests/phpunit/includes/mock-fs.php
- Timestamp:
- 11/04/2021 01:15:33 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/mock-fs.php
r47122 r52009 14 14 public $method = 'MockFS'; 15 15 16 function __construct() {}17 18 function connect() {16 public function __construct() {} 17 18 public function connect() { 19 19 return true; 20 20 } 21 21 22 22 // Copy of core's function, but accepts a path. 23 function abspath( $path = false ) {23 public function abspath( $path = false ) { 24 24 if ( ! $path ) { 25 25 $path = ABSPATH; … … 41 41 * Can also be passed the initial filesystem to be setup which is passed to self::setfs() 42 42 */ 43 function init( $paths = '', $home_dir = '/' ) {43 public function init( $paths = '', $home_dir = '/' ) { 44 44 $this->fs = new MockFS_Directory_Node( '/' ); 45 45 $this->fs_map = array( … … 54 54 * "Bulk Loads" a filesystem into the internal virtual filesystem 55 55 */ 56 function setfs( $paths ) {56 public function setfs( $paths ) { 57 57 if ( ! is_array( $paths ) ) { 58 58 $paths = explode( "\n", $paths ); … … 94 94 // Here starteth the WP_Filesystem functions. 95 95 96 function mkdir( $path, /* Optional args are ignored */ $chmod = false, $chown = false, $chgrp = false ) {96 public function mkdir( $path, /* Optional args are ignored */ $chmod = false, $chown = false, $chgrp = false ) { 97 97 $path = trailingslashit( $path ); 98 98 … … 115 115 } 116 116 117 function put_contents( $path, $contents = '', $mode = null ) {117 public function put_contents( $path, $contents = '', $mode = null ) { 118 118 if ( ! $this->is_dir( dirname( $path ) ) ) { 119 119 $this->mkdir( dirname( $path ) ); … … 127 127 } 128 128 129 function get_contents( $file ) {129 public function get_contents( $file ) { 130 130 if ( ! $this->is_file( $file ) ) { 131 131 return false; … … 134 134 } 135 135 136 function cwd() {136 public function cwd() { 137 137 return $this->cwd->path; 138 138 } 139 139 140 function chdir( $path ) {140 public function chdir( $path ) { 141 141 if ( ! isset( $this->fs_map[ $path ] ) ) { 142 142 return false; … … 147 147 } 148 148 149 function exists( $path ) {149 public function exists( $path ) { 150 150 return isset( $this->fs_map[ $path ] ) || isset( $this->fs_map[ trailingslashit( $path ) ] ); 151 151 } 152 152 153 function is_file( $file ) {153 public function is_file( $file ) { 154 154 return isset( $this->fs_map[ $file ] ) && $this->fs_map[ $file ]->is_file(); 155 155 } 156 156 157 function is_dir( $path ) {157 public function is_dir( $path ) { 158 158 $path = trailingslashit( $path ); 159 159 … … 161 161 } 162 162 163 function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {163 public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) { 164 164 165 165 if ( empty( $path ) || '.' === $path ) { … … 215 215 public $path; // The full path to the entry. 216 216 217 function __construct( $path ) {217 public function __construct( $path ) { 218 218 $this->path = $path; 219 219 $this->name = basename( $path ); 220 220 } 221 221 222 function is_file() {222 public function is_file() { 223 223 return 'f' === $this->type; 224 224 } 225 225 226 function is_dir() {226 public function is_dir() { 227 227 return 'd' === $this->type; 228 228 } … … 238 238 public $contents = ''; // The contents of the file. 239 239 240 function __construct( $path, $contents = '' ) {240 public function __construct( $path, $contents = '' ) { 241 241 parent::__construct( $path ); 242 242 $this->contents = $contents;
Note: See TracChangeset
for help on using the changeset viewer.