updated dependencies
This commit is contained in:
1
vendor/dnoegel/php-xdg-base-dir/.gitignore
vendored
1
vendor/dnoegel/php-xdg-base-dir/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/vendor/
|
||||
17
vendor/dnoegel/php-xdg-base-dir/README.md
vendored
17
vendor/dnoegel/php-xdg-base-dir/README.md
vendored
@@ -1,6 +1,9 @@
|
||||
# XDG Base Directory
|
||||
|
||||
[](https://packagist.org/packages/dnoegel/php-xdg-base-dir)
|
||||
[](https://packagist.org/packages/dnoegel/php-xdg-base-dir)
|
||||
[](LICENSE.md)
|
||||
[](https://travis-ci.org/dnoegel/php-xdg-base-dir)
|
||||
|
||||
Implementation of XDG Base Directory specification for php
|
||||
|
||||
@@ -15,16 +18,16 @@ $ composer require dnoegel/php-xdg-base-dir
|
||||
## Usage
|
||||
|
||||
``` php
|
||||
$xdg = \XdgBaseDir\Xdg();
|
||||
$xdg = new \XdgBaseDir\Xdg();
|
||||
|
||||
echo $xdg->getHomeDir();
|
||||
echo $xdg->getHomeConfigDir()
|
||||
echo $xdg->getHomeDataDir()
|
||||
echo $xdg->getHomeCacheDir()
|
||||
echo $xdg->getRuntimeDir()
|
||||
echo $xdg->getHomeConfigDir();
|
||||
echo $xdg->getHomeDataDir();
|
||||
echo $xdg->getHomeCacheDir();
|
||||
echo $xdg->getRuntimeDir();
|
||||
|
||||
$xdg->getDataDirs() // returns array
|
||||
$xdg->getConfigDirs() // returns array
|
||||
print_r($xdg->getDataDirs()); // returns array
|
||||
print_r($xdg->getConfigDirs()); // returns array
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "dnoegel/php-xdg-base-dir",
|
||||
"description": "implementation of xdg base directory specification for php",
|
||||
"type": "project",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "@stable"
|
||||
"phpunit/phpunit": "~7.0|~6.0|~5.0|~4.8.35"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
24
vendor/dnoegel/php-xdg-base-dir/phpunit.xml.dist
vendored
24
vendor/dnoegel/php-xdg-base-dir/phpunit.xml.dist
vendored
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="php-xdg-base-dir unit tests">
|
||||
<directory>./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./src/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
21
vendor/dnoegel/php-xdg-base-dir/src/Xdg.php
vendored
21
vendor/dnoegel/php-xdg-base-dir/src/Xdg.php
vendored
@@ -6,9 +6,6 @@ namespace XdgBaseDir;
|
||||
* Simple implementation of the XDG standard http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
*
|
||||
* Based on the python implementation https://github.com/takluyver/pyxdg/blob/master/xdg/BaseDirectory.py
|
||||
*
|
||||
* Class Xdg
|
||||
* @package ShopwareCli\Application
|
||||
*/
|
||||
class Xdg
|
||||
{
|
||||
@@ -30,7 +27,13 @@ class Xdg
|
||||
*/
|
||||
public function getHomeConfigDir()
|
||||
{
|
||||
$path = getenv('XDG_CONFIG_HOME') ?: $this->getHomeDir() . DIRECTORY_SEPARATOR . '.config';
|
||||
if ($path = getenv('XDG_CONFIG_HOME')) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
$homeDir = $this->getHomeDir();
|
||||
|
||||
$path = DIRECTORY_SEPARATOR === $homeDir ? $homeDir.'.config' : $homeDir . DIRECTORY_SEPARATOR . '.config';
|
||||
|
||||
return $path;
|
||||
}
|
||||
@@ -104,7 +107,7 @@ class Xdg
|
||||
if (!$st['mode'] & self::S_IFDIR) {
|
||||
rmdir($fallback);
|
||||
$create = true;
|
||||
} elseif ($st['uid'] != getmyuid() ||
|
||||
} elseif ($st['uid'] != $this->getUid() ||
|
||||
$st['mode'] & (self::S_IRWXG | self::S_IRWXO)
|
||||
) {
|
||||
rmdir($fallback);
|
||||
@@ -118,4 +121,12 @@ class Xdg
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
private function getUid()
|
||||
{
|
||||
if (function_exists('posix_getuid')) {
|
||||
return posix_getuid();
|
||||
}
|
||||
|
||||
return getmyuid();
|
||||
}
|
||||
}
|
||||
|
||||
116
vendor/dnoegel/php-xdg-base-dir/tests/XdgTest.php
vendored
116
vendor/dnoegel/php-xdg-base-dir/tests/XdgTest.php
vendored
@@ -1,116 +0,0 @@
|
||||
<?php
|
||||
|
||||
class XdgTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @return \XdgBaseDir\Xdg
|
||||
*/
|
||||
public function getXdg()
|
||||
{
|
||||
return new \XdgBaseDir\Xdg();
|
||||
}
|
||||
|
||||
public function testGetHomeDir()
|
||||
{
|
||||
putenv('HOME=/fake-dir');
|
||||
$this->assertEquals('/fake-dir', $this->getXdg()->getHomeDir());
|
||||
}
|
||||
|
||||
public function testGetFallbackHomeDir()
|
||||
{
|
||||
putenv('HOME=');
|
||||
putenv('HOMEDRIVE=C:');
|
||||
putenv('HOMEPATH=fake-dir');
|
||||
$this->assertEquals('C:/fake-dir', $this->getXdg()->getHomeDir());
|
||||
}
|
||||
|
||||
public function testXdgPutCache()
|
||||
{
|
||||
putenv('XDG_DATA_HOME=tmp/');
|
||||
putenv('XDG_CONFIG_HOME=tmp/');
|
||||
putenv('XDG_CACHE_HOME=tmp/');
|
||||
$this->assertEquals('tmp/', $this->getXdg()->getHomeCacheDir());
|
||||
}
|
||||
|
||||
public function testXdgPutData()
|
||||
{
|
||||
putenv('XDG_DATA_HOME=tmp/');
|
||||
$this->assertEquals('tmp/', $this->getXdg()->getHomeDataDir());
|
||||
}
|
||||
|
||||
public function testXdgPutConfig()
|
||||
{
|
||||
putenv('XDG_CONFIG_HOME=tmp/');
|
||||
$this->assertEquals('tmp/', $this->getXdg()->getHomeConfigDir());
|
||||
}
|
||||
|
||||
public function testXdgDataDirsShouldIncludeHomeDataDir()
|
||||
{
|
||||
putenv('XDG_DATA_HOME=tmp/');
|
||||
putenv('XDG_CONFIG_HOME=tmp/');
|
||||
|
||||
$this->assertArrayHasKey('tmp/', array_flip($this->getXdg()->getDataDirs()));
|
||||
}
|
||||
|
||||
public function testXdgConfigDirsShouldIncludeHomeConfigDir()
|
||||
{
|
||||
putenv('XDG_CONFIG_HOME=tmp/');
|
||||
|
||||
$this->assertArrayHasKey('tmp/', array_flip($this->getXdg()->getConfigDirs()));
|
||||
}
|
||||
|
||||
/**
|
||||
* If XDG_RUNTIME_DIR is set, it should be returned
|
||||
*/
|
||||
public function testGetRuntimeDir()
|
||||
{
|
||||
putenv('XDG_RUNTIME_DIR=/tmp/');
|
||||
$runtimeDir = $this->getXdg()->getRuntimeDir();
|
||||
|
||||
$this->assertEquals(is_dir($runtimeDir), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* In strict mode, an exception should be shown if XDG_RUNTIME_DIR does not exist
|
||||
*
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testGetRuntimeDirShouldThrowException()
|
||||
{
|
||||
putenv('XDG_RUNTIME_DIR=');
|
||||
$this->getXdg()->getRuntimeDir(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* In fallback mode a directory should be created
|
||||
*/
|
||||
public function testGetRuntimeDirShouldCreateDirectory()
|
||||
{
|
||||
putenv('XDG_RUNTIME_DIR=');
|
||||
$dir = $this->getXdg()->getRuntimeDir(false);
|
||||
$permission = decoct(fileperms($dir) & 0777);
|
||||
$this->assertEquals(700, $permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure, that the fallback directories are created with correct permission
|
||||
*/
|
||||
public function testGetRuntimeShouldDeleteDirsWithWrongPermission()
|
||||
{
|
||||
$runtimeDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . XdgBaseDir\Xdg::RUNTIME_DIR_FALLBACK . getenv('USER');
|
||||
|
||||
rmdir($runtimeDir);
|
||||
mkdir($runtimeDir, 0764, true);
|
||||
|
||||
// Permission should be wrong now
|
||||
$permission = decoct(fileperms($runtimeDir) & 0777);
|
||||
$this->assertEquals(764, $permission);
|
||||
|
||||
putenv('XDG_RUNTIME_DIR=');
|
||||
$dir = $this->getXdg()->getRuntimeDir(false);
|
||||
|
||||
// Permission should be fixed
|
||||
$permission = decoct(fileperms($dir) & 0777);
|
||||
$this->assertEquals(700, $permission);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user