Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -0,0 +1,47 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Filesystem\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
use Symfony\Component\Filesystem\Exception\IOException;
/**
* Test class for Filesystem.
*/
class ExceptionTest extends TestCase
{
public function testGetPath()
{
$e = new IOException('', 0, null, '/foo');
$this->assertEquals('/foo', $e->getPath(), 'The pass should be returned.');
}
public function testGeneratedMessage()
{
$e = new FileNotFoundException(null, 0, null, '/foo');
$this->assertEquals('/foo', $e->getPath());
$this->assertEquals('File "/foo" could not be found.', $e->getMessage(), 'A message should be generated.');
}
public function testGeneratedMessageWithoutPath()
{
$e = new FileNotFoundException();
$this->assertEquals('File could not be found.', $e->getMessage(), 'A message should be generated.');
}
public function testCustomMessage()
{
$e = new FileNotFoundException('bar', 0, null, '/foo');
$this->assertEquals('bar', $e->getMessage(), 'A custom message should be possible still.');
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,166 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Filesystem\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;
class FilesystemTestCase extends TestCase
{
private $umask;
protected $longPathNamesWindows = array();
/**
* @var \Symfony\Component\Filesystem\Filesystem
*/
protected $filesystem = null;
/**
* @var string
*/
protected $workspace = null;
/**
* @var bool|null Flag for hard links on Windows
*/
private static $linkOnWindows = null;
/**
* @var bool|null Flag for symbolic links on Windows
*/
private static $symlinkOnWindows = null;
public static function setUpBeforeClass()
{
if ('\\' === \DIRECTORY_SEPARATOR) {
self::$linkOnWindows = true;
$originFile = tempnam(sys_get_temp_dir(), 'li');
$targetFile = tempnam(sys_get_temp_dir(), 'li');
if (true !== @link($originFile, $targetFile)) {
$report = error_get_last();
if (\is_array($report) && false !== strpos($report['message'], 'error code(1314)')) {
self::$linkOnWindows = false;
}
} else {
@unlink($targetFile);
}
self::$symlinkOnWindows = true;
$originDir = tempnam(sys_get_temp_dir(), 'sl');
$targetDir = tempnam(sys_get_temp_dir(), 'sl');
if (true !== @symlink($originDir, $targetDir)) {
$report = error_get_last();
if (\is_array($report) && false !== strpos($report['message'], 'error code(1314)')) {
self::$symlinkOnWindows = false;
}
} else {
@unlink($targetDir);
}
}
}
protected function setUp()
{
$this->umask = umask(0);
$this->filesystem = new Filesystem();
$this->workspace = sys_get_temp_dir().'/'.microtime(true).'.'.mt_rand();
mkdir($this->workspace, 0777, true);
$this->workspace = realpath($this->workspace);
}
protected function tearDown()
{
if (!empty($this->longPathNamesWindows)) {
foreach ($this->longPathNamesWindows as $path) {
exec('DEL '.$path);
}
$this->longPathNamesWindows = array();
}
$this->filesystem->remove($this->workspace);
umask($this->umask);
}
/**
* @param int $expectedFilePerms Expected file permissions as three digits (i.e. 755)
* @param string $filePath
*/
protected function assertFilePermissions($expectedFilePerms, $filePath)
{
$actualFilePerms = (int) substr(sprintf('%o', fileperms($filePath)), -3);
$this->assertEquals(
$expectedFilePerms,
$actualFilePerms,
sprintf('File permissions for %s must be %s. Actual %s', $filePath, $expectedFilePerms, $actualFilePerms)
);
}
protected function getFileOwner($filepath)
{
$this->markAsSkippedIfPosixIsMissing();
$infos = stat($filepath);
if ($datas = posix_getpwuid($infos['uid'])) {
return $datas['name'];
}
}
protected function getFileGroup($filepath)
{
$this->markAsSkippedIfPosixIsMissing();
$infos = stat($filepath);
if ($datas = posix_getgrgid($infos['gid'])) {
return $datas['name'];
}
$this->markTestSkipped('Unable to retrieve file group name');
}
protected function markAsSkippedIfLinkIsMissing()
{
if (!\function_exists('link')) {
$this->markTestSkipped('link is not supported');
}
if ('\\' === \DIRECTORY_SEPARATOR && false === self::$linkOnWindows) {
$this->markTestSkipped('link requires "Create hard links" privilege on windows');
}
}
protected function markAsSkippedIfSymlinkIsMissing($relative = false)
{
if ('\\' === \DIRECTORY_SEPARATOR && false === self::$symlinkOnWindows) {
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on Windows');
}
// https://bugs.php.net/bug.php?id=69473
if ($relative && '\\' === \DIRECTORY_SEPARATOR && 1 === PHP_ZTS) {
$this->markTestSkipped('symlink does not support relative paths on thread safe Windows PHP versions');
}
}
protected function markAsSkippedIfChmodIsMissing()
{
if ('\\' === \DIRECTORY_SEPARATOR) {
$this->markTestSkipped('chmod is not supported on Windows');
}
}
protected function markAsSkippedIfPosixIsMissing()
{
if (!\function_exists('posix_isatty')) {
$this->markTestSkipped('Function posix_isatty is required.');
}
}
}

View file

@ -0,0 +1,46 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Filesystem\Tests\Fixtures\MockStream;
/**
* Mock stream class to be used with stream_wrapper_register.
* stream_wrapper_register('mock', 'Symfony\Component\Filesystem\Tests\Fixtures\MockStream\MockStream').
*/
class MockStream
{
/**
* Opens file or URL.
*
* @param string $path Specifies the URL that was passed to the original function
* @param string $mode The mode used to open the file, as detailed for fopen()
* @param int $options Holds additional flags set by the streams API
* @param string $opened_path If the path is opened successfully, and STREAM_USE_PATH is set in options,
* opened_path should be set to the full path of the file/resource that was actually opened
*
* @return bool
*/
public function stream_open($path, $mode, $options, &$opened_path)
{
return true;
}
/**
* @param string $path The file path or URL to stat
* @param array $flags Holds additional flags set by the streams API
*
* @return array File stats
*/
public function url_stat($path, $flags)
{
return array();
}
}

View file

@ -0,0 +1,148 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Filesystem\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\LockHandler;
/**
* @group legacy
*/
class LockHandlerTest extends TestCase
{
/**
* @expectedException \Symfony\Component\Filesystem\Exception\IOException
* @expectedExceptionMessage Failed to create "/a/b/c/d/e": mkdir(): Permission denied.
*/
public function testConstructWhenRepositoryDoesNotExist()
{
if (!getenv('USER') || 'root' === getenv('USER')) {
$this->markTestSkipped('This test will fail if run under superuser');
}
new LockHandler('lock', '/a/b/c/d/e');
}
/**
* @expectedException \Symfony\Component\Filesystem\Exception\IOException
* @expectedExceptionMessage The directory "/" is not writable.
*/
public function testConstructWhenRepositoryIsNotWriteable()
{
if (!getenv('USER') || 'root' === getenv('USER')) {
$this->markTestSkipped('This test will fail if run under superuser');
}
new LockHandler('lock', '/');
}
public function testErrorHandlingInLockIfLockPathBecomesUnwritable()
{
// skip test on Windows; PHP can't easily set file as unreadable on Windows
if ('\\' === \DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test cannot run on Windows.');
}
if (!getenv('USER') || 'root' === getenv('USER')) {
$this->markTestSkipped('This test will fail if run under superuser');
}
$lockPath = sys_get_temp_dir().'/'.uniqid('', true);
$e = null;
$wrongMessage = null;
try {
mkdir($lockPath);
$lockHandler = new LockHandler('lock', $lockPath);
chmod($lockPath, 0444);
$lockHandler->lock();
} catch (IOException $e) {
if (false === strpos($e->getMessage(), 'Permission denied')) {
$wrongMessage = $e->getMessage();
} else {
$this->addToAssertionCount(1);
}
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
if (is_dir($lockPath)) {
$fs = new Filesystem();
$fs->remove($lockPath);
}
$this->assertInstanceOf('Symfony\Component\Filesystem\Exception\IOException', $e, sprintf('Expected IOException to be thrown, got %s instead.', \get_class($e)));
$this->assertNull($wrongMessage, sprintf('Expected exception message to contain "Permission denied", got "%s" instead.', $wrongMessage));
}
public function testConstructSanitizeName()
{
$lock = new LockHandler('<?php echo "% hello word ! %" ?>');
$file = sprintf('%s/sf.-php-echo-hello-word-.4b3d9d0d27ddef3a78a64685dda3a963e478659a9e5240feaf7b4173a8f28d5f.lock', sys_get_temp_dir());
// ensure the file does not exist before the lock
@unlink($file);
$lock->lock();
$this->assertFileExists($file);
$lock->release();
}
public function testLockRelease()
{
$name = 'symfony-test-filesystem.lock';
$l1 = new LockHandler($name);
$l2 = new LockHandler($name);
$this->assertTrue($l1->lock());
$this->assertFalse($l2->lock());
$l1->release();
$this->assertTrue($l2->lock());
$l2->release();
}
public function testLockTwice()
{
$name = 'symfony-test-filesystem.lock';
$lockHandler = new LockHandler($name);
$this->assertTrue($lockHandler->lock());
$this->assertTrue($lockHandler->lock());
$lockHandler->release();
}
public function testLockIsReleased()
{
$name = 'symfony-test-filesystem.lock';
$l1 = new LockHandler($name);
$l2 = new LockHandler($name);
$this->assertTrue($l1->lock());
$this->assertFalse($l2->lock());
$l1 = null;
$this->assertTrue($l2->lock());
$l2->release();
}
}