/** * Parses the system context for a home directory. * * @return null|string Returns the path to the home directory or `null` * if none was found. */ private static function parseHomeDirectory() { try { $homeDir = System::parseHomeDirectory(); System::denyWebAccess($homeDir); return $homeDir; } catch (InvalidConfigException $e) { // Context variable was not found -> no home directory // This happens often on web servers where the home directory is // not set manually return null; } }
/** * @expectedException \Puli\Manager\Api\FileNotFoundException * @expectedExceptionMessage APPDATA */ public function testFailIfWindowsHomeDirectoryNotFound() { putenv('APPDATA=' . __DIR__ . '/foobar'); System::parseHomeDirectory(); }