getHome() public static method

Returns a home directory of current user.
public static getHome ( ) : string
return string
Beispiel #1
0
 public function testGetHome()
 {
     // Test for OS Default.
     isTrue(is_writable(Sys::getHome()));
     $oldServer = $_SERVER;
     unset($_SERVER);
     // Test for UNIX.
     $_SERVER['HOME'] = '/home/unknown';
     is($_SERVER['HOME'], Sys::getHome(), 'Could not get the user\'s home directory in UNIX.');
     unset($_SERVER);
     // Test for Windows.
     $expected = 'X:\\Users\\ThisUser';
     $_SERVER['HOMEDRIVE'] = 'X:';
     $_SERVER['HOMEPATH'] = '\\Users\\ThisUser';
     is($expected, Sys::getHome(), 'Could not get the user\'s home directory in Windows.');
     // In case the tests are not being run in isolation.
     $_SERVER = $oldServer;
 }