[COMPOSER] Add new php-ffmpeg package
This commit is contained in:
169
vendor/symfony/config/Tests/Resource/DirectoryResourceTest.php
vendored
Normal file
169
vendor/symfony/config/Tests/Resource/DirectoryResourceTest.php
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
<?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\Config\Tests\Resource;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Resource\DirectoryResource;
|
||||
|
||||
class DirectoryResourceTest extends TestCase
|
||||
{
|
||||
protected $directory;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->directory = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'symfonyDirectoryIterator';
|
||||
if (!file_exists($this->directory)) {
|
||||
mkdir($this->directory);
|
||||
}
|
||||
touch($this->directory.'/tmp.xml');
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (!is_dir($this->directory)) {
|
||||
return;
|
||||
}
|
||||
$this->removeDirectory($this->directory);
|
||||
}
|
||||
|
||||
protected function removeDirectory($directory)
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory), \RecursiveIteratorIterator::CHILD_FIRST);
|
||||
foreach ($iterator as $path) {
|
||||
if (preg_match('#[/\\\\]\.\.?$#', $path->__toString())) {
|
||||
continue;
|
||||
}
|
||||
if ($path->isDir()) {
|
||||
rmdir($path->__toString());
|
||||
} else {
|
||||
unlink($path->__toString());
|
||||
}
|
||||
}
|
||||
rmdir($directory);
|
||||
}
|
||||
|
||||
public function testGetResource()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
$this->assertSame($this->directory, $resource->getResource(), '->getResource() returns the path to the resource');
|
||||
}
|
||||
|
||||
public function testGetPattern()
|
||||
{
|
||||
$resource = new DirectoryResource('foo', 'bar');
|
||||
$this->assertEquals('bar', $resource->getPattern());
|
||||
}
|
||||
|
||||
public function testIsFresh()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
$this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if the resource has not changed');
|
||||
$this->assertFalse($resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated');
|
||||
|
||||
$resource = new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999));
|
||||
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist');
|
||||
}
|
||||
|
||||
public function testIsFreshUpdateFile()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
touch($this->directory.'/tmp.xml', time() + 20);
|
||||
$this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if an existing file is modified');
|
||||
}
|
||||
|
||||
public function testIsFreshNewFile()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
touch($this->directory.'/new.xml', time() + 20);
|
||||
$this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a new file is added');
|
||||
}
|
||||
|
||||
public function testIsFreshNewFileWithDifferentPattern()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory, '/.xml$/');
|
||||
touch($this->directory.'/new.yaml', time() + 20);
|
||||
$this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if a new file with a non-matching pattern is added');
|
||||
}
|
||||
|
||||
public function testIsFreshDeleteFile()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
$time = time();
|
||||
sleep(1);
|
||||
unlink($this->directory.'/tmp.xml');
|
||||
$this->assertFalse($resource->isFresh($time), '->isFresh() returns false if an existing file is removed');
|
||||
}
|
||||
|
||||
public function testIsFreshDeleteDirectory()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
$this->removeDirectory($this->directory);
|
||||
$this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the whole resource is removed');
|
||||
}
|
||||
|
||||
public function testIsFreshCreateFileInSubdirectory()
|
||||
{
|
||||
$subdirectory = $this->directory.'/subdirectory';
|
||||
mkdir($subdirectory);
|
||||
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
$this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if an unmodified subdirectory exists');
|
||||
|
||||
touch($subdirectory.'/newfile.xml', time() + 20);
|
||||
$this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a new file in a subdirectory is added');
|
||||
}
|
||||
|
||||
public function testIsFreshModifySubdirectory()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
|
||||
$subdirectory = $this->directory.'/subdirectory';
|
||||
mkdir($subdirectory);
|
||||
touch($subdirectory, time() + 20);
|
||||
|
||||
$this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if a subdirectory is modified (e.g. a file gets deleted)');
|
||||
}
|
||||
|
||||
public function testFilterRegexListNoMatch()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/');
|
||||
|
||||
touch($this->directory.'/new.bar', time() + 20);
|
||||
$this->assertTrue($resource->isFresh(time() + 10), '->isFresh() returns true if a new file not matching the filter regex is created');
|
||||
}
|
||||
|
||||
public function testFilterRegexListMatch()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/');
|
||||
|
||||
touch($this->directory.'/new.xml', time() + 20);
|
||||
$this->assertFalse($resource->isFresh(time() + 10), '->isFresh() returns false if an new file matching the filter regex is created ');
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory, '/\.(foo|xml)$/');
|
||||
|
||||
$unserialized = unserialize(serialize($resource));
|
||||
|
||||
$this->assertSame($this->directory, $resource->getResource());
|
||||
$this->assertSame('/\.(foo|xml)$/', $resource->getPattern());
|
||||
}
|
||||
|
||||
public function testResourcesWithDifferentPatternsAreDifferent()
|
||||
{
|
||||
$resourceA = new DirectoryResource($this->directory, '/.xml$/');
|
||||
$resourceB = new DirectoryResource($this->directory, '/.yaml$/');
|
||||
|
||||
$this->assertCount(2, array_unique(array($resourceA, $resourceB)));
|
||||
}
|
||||
}
|
71
vendor/symfony/config/Tests/Resource/FileExistenceResourceTest.php
vendored
Normal file
71
vendor/symfony/config/Tests/Resource/FileExistenceResourceTest.php
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
<?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\Config\Tests\Resource;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Resource\FileExistenceResource;
|
||||
|
||||
class FileExistenceResourceTest extends TestCase
|
||||
{
|
||||
protected $resource;
|
||||
protected $file;
|
||||
protected $time;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->file = realpath(sys_get_temp_dir()).'/tmp.xml';
|
||||
$this->time = time();
|
||||
$this->resource = new FileExistenceResource($this->file);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (file_exists($this->file)) {
|
||||
unlink($this->file);
|
||||
}
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
{
|
||||
$this->assertSame($this->file, (string) $this->resource);
|
||||
}
|
||||
|
||||
public function testGetResource()
|
||||
{
|
||||
$this->assertSame($this->file, $this->resource->getResource(), '->getResource() returns the path to the resource');
|
||||
}
|
||||
|
||||
public function testIsFreshWithExistingResource()
|
||||
{
|
||||
touch($this->file, $this->time);
|
||||
$serialized = serialize(new FileExistenceResource($this->file));
|
||||
|
||||
$resource = unserialize($serialized);
|
||||
$this->assertTrue($resource->isFresh($this->time), '->isFresh() returns true if the resource is still present');
|
||||
|
||||
unlink($this->file);
|
||||
$resource = unserialize($serialized);
|
||||
$this->assertFalse($resource->isFresh($this->time), '->isFresh() returns false if the resource has been deleted');
|
||||
}
|
||||
|
||||
public function testIsFreshWithAbsentResource()
|
||||
{
|
||||
$serialized = serialize(new FileExistenceResource($this->file));
|
||||
|
||||
$resource = unserialize($serialized);
|
||||
$this->assertTrue($resource->isFresh($this->time), '->isFresh() returns true if the resource is still absent');
|
||||
|
||||
touch($this->file, $this->time);
|
||||
$resource = unserialize($serialized);
|
||||
$this->assertFalse($resource->isFresh($this->time), '->isFresh() returns false if the resource has been created');
|
||||
}
|
||||
}
|
62
vendor/symfony/config/Tests/Resource/FileResourceTest.php
vendored
Normal file
62
vendor/symfony/config/Tests/Resource/FileResourceTest.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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\Config\Tests\Resource;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
|
||||
class FileResourceTest extends TestCase
|
||||
{
|
||||
protected $resource;
|
||||
protected $file;
|
||||
protected $time;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->file = realpath(sys_get_temp_dir()).'/tmp.xml';
|
||||
$this->time = time();
|
||||
touch($this->file, $this->time);
|
||||
$this->resource = new FileResource($this->file);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
unlink($this->file);
|
||||
}
|
||||
|
||||
public function testGetResource()
|
||||
{
|
||||
$this->assertSame(realpath($this->file), $this->resource->getResource(), '->getResource() returns the path to the resource');
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
{
|
||||
$this->assertSame(realpath($this->file), (string) $this->resource);
|
||||
}
|
||||
|
||||
public function testIsFresh()
|
||||
{
|
||||
$this->assertTrue($this->resource->isFresh($this->time), '->isFresh() returns true if the resource has not changed in same second');
|
||||
$this->assertTrue($this->resource->isFresh($this->time + 10), '->isFresh() returns true if the resource has not changed');
|
||||
$this->assertFalse($this->resource->isFresh($this->time - 86400), '->isFresh() returns false if the resource has been updated');
|
||||
|
||||
$resource = new FileResource('/____foo/foobar'.mt_rand(1, 999999));
|
||||
$this->assertFalse($resource->isFresh($this->time), '->isFresh() returns false if the resource does not exist');
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize()
|
||||
{
|
||||
$unserialized = unserialize(serialize($this->resource));
|
||||
|
||||
$this->assertSame(realpath($this->file), $this->resource->getResource());
|
||||
}
|
||||
}
|
39
vendor/symfony/config/Tests/Resource/ResourceStub.php
vendored
Normal file
39
vendor/symfony/config/Tests/Resource/ResourceStub.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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\Config\Tests\Resource;
|
||||
|
||||
use Symfony\Component\Config\Resource\SelfCheckingResourceInterface;
|
||||
|
||||
class ResourceStub implements SelfCheckingResourceInterface
|
||||
{
|
||||
private $fresh = true;
|
||||
|
||||
public function setFresh($isFresh)
|
||||
{
|
||||
$this->fresh = $isFresh;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return 'stub';
|
||||
}
|
||||
|
||||
public function isFresh($timestamp)
|
||||
{
|
||||
return $this->fresh;
|
||||
}
|
||||
|
||||
public function getResource()
|
||||
{
|
||||
return 'stub';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user