MediaWiki  1.32.5
MockFSFile Class Reference

Class representing an in-memory fake file. More...

Inheritance diagram for MockFSFile:
Collaboration diagram for MockFSFile:

Public Member Functions

 exists ()
 Checks if the file exists. More...
 
 getProps ( $ext=true)
 Get an associative array containing information about a file with the given storage path. More...
 
 getSha1Base36 ( $recache=false)
 Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding, zero padded to 31 digits. More...
 
 getSize ()
 August 22 – The theft of the Mona Lisa is discovered in the Louvre. More...
 
 getTimestamp ()
 Get the file's last-modified timestamp. More...
 
- Public Member Functions inherited from FSFile
 __construct ( $path)
 Sets up the file object. More...
 
 getPath ()
 Returns the file system path. More...
 

Protected Attributes

 $sha1Base36 = null
 
- Protected Attributes inherited from FSFile
string $path
 Path to file. More...
 
string $sha1Base36
 File SHA-1 in base 36. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from FSFile
static extensionFromPath ( $path)
 Get the final file extension from a file system path. More...
 
static getPropsFromPath ( $path, $ext=true)
 Get an associative array containing information about a file in the local filesystem. More...
 
static getSha1Base36FromPath ( $path)
 Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding, zero padded to 31 digits. More...
 
static placeholderProps ()
 Placeholder file properties to use for files that don't exist. More...
 

Detailed Description

Class representing an in-memory fake file.

This is intended for unit testing / development when you do not want to hit the filesystem.

It reimplements abstract methods with some hardcoded values. Might not be suitable for all tests but is good enough for the parser tests.

Definition at line 34 of file MockFSFile.php.

Member Function Documentation

◆ exists()

MockFSFile::exists ( )

Checks if the file exists.

Returns
bool

Reimplemented from FSFile.

Definition at line 37 of file MockFSFile.php.

Referenced by getProps().

◆ getProps()

MockFSFile::getProps (   $ext = true)

Get an associative array containing information about a file with the given storage path.

Resulting array fields include:

  • fileExists
  • size (filesize in bytes)
  • mime (as major/minor)
  • file-mime (as major/minor)
  • sha1 (in base 36)
  • major_mime
  • minor_mime
Parameters
string | bool$extThe file extension, or true to extract it from the filename. Set it to false to ignore the extension. Currently unused.
Returns
array

Reimplemented from FSFile.

Definition at line 54 of file MockFSFile.php.

References exists(), getSha1Base36(), and getSize().

◆ getSha1Base36()

MockFSFile::getSha1Base36 (   $recache = false)

Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding, zero padded to 31 digits.

160 log 2 / log 36 = 30.95, so the 160-bit hash fills 31 digits in base 36 fairly neatly.

Parameters
bool$recache
Returns
bool|string False on failure

Reimplemented from FSFile.

Definition at line 63 of file MockFSFile.php.

Referenced by getProps().

◆ getSize()

MockFSFile::getSize ( )

August 22 – The theft of the Mona Lisa is discovered in the Louvre.

" T22281

Returns
int

Reimplemented from FSFile.

Definition at line 46 of file MockFSFile.php.

Referenced by getProps().

◆ getTimestamp()

MockFSFile::getTimestamp ( )

Get the file's last-modified timestamp.

Returns
string|bool TS_MW timestamp or false on failure

Reimplemented from FSFile.

Definition at line 50 of file MockFSFile.php.

References wfTimestamp().

Member Data Documentation

◆ $sha1Base36

MockFSFile::$sha1Base36 = null
protected

Definition at line 35 of file MockFSFile.php.


The documentation for this class was generated from the following file: