first commit
This commit is contained in:
130
modules/inpostshipping/vendor/symfony/config/Tests/Resource/ClassExistenceResourceTest.php
vendored
Normal file
130
modules/inpostshipping/vendor/symfony/config/Tests/Resource/ClassExistenceResourceTest.php
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
<?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\ClassExistenceResource;
|
||||
use Symfony\Component\Config\Tests\Fixtures\BadFileName;
|
||||
use Symfony\Component\Config\Tests\Fixtures\BadParent;
|
||||
use Symfony\Component\Config\Tests\Fixtures\ParseError;
|
||||
use Symfony\Component\Config\Tests\Fixtures\Resource\ConditionalClass;
|
||||
|
||||
class ClassExistenceResourceTest extends TestCase
|
||||
{
|
||||
public function testToString()
|
||||
{
|
||||
$res = new ClassExistenceResource('BarClass');
|
||||
$this->assertSame('BarClass', (string) $res);
|
||||
}
|
||||
|
||||
public function testGetResource()
|
||||
{
|
||||
$res = new ClassExistenceResource('BarClass');
|
||||
$this->assertSame('BarClass', $res->getResource());
|
||||
}
|
||||
|
||||
public function testIsFreshWhenClassDoesNotExist()
|
||||
{
|
||||
$res = new ClassExistenceResource('Symfony\Component\Config\Tests\Fixtures\BarClass');
|
||||
|
||||
$this->assertTrue($res->isFresh(time()));
|
||||
|
||||
eval(<<<EOF
|
||||
namespace Symfony\Component\Config\Tests\Fixtures;
|
||||
|
||||
class BarClass
|
||||
{
|
||||
}
|
||||
EOF
|
||||
);
|
||||
|
||||
$this->assertFalse($res->isFresh(time()));
|
||||
}
|
||||
|
||||
public function testIsFreshWhenClassExists()
|
||||
{
|
||||
$res = new ClassExistenceResource('Symfony\Component\Config\Tests\Resource\ClassExistenceResourceTest');
|
||||
|
||||
$this->assertTrue($res->isFresh(time()));
|
||||
}
|
||||
|
||||
public function testExistsKo()
|
||||
{
|
||||
spl_autoload_register($autoloader = function ($class) use (&$loadedClass) { $loadedClass = $class; });
|
||||
|
||||
try {
|
||||
$res = new ClassExistenceResource('MissingFooClass');
|
||||
$this->assertTrue($res->isFresh(0));
|
||||
|
||||
$this->assertSame('MissingFooClass', $loadedClass);
|
||||
|
||||
$loadedClass = 123;
|
||||
|
||||
new ClassExistenceResource('MissingFooClass', false);
|
||||
|
||||
$this->assertSame(123, $loadedClass);
|
||||
} finally {
|
||||
spl_autoload_unregister($autoloader);
|
||||
}
|
||||
}
|
||||
|
||||
public function testBadParentWithTimestamp()
|
||||
{
|
||||
$res = new ClassExistenceResource(BadParent::class, false);
|
||||
$this->assertTrue($res->isFresh(time()));
|
||||
}
|
||||
|
||||
public function testBadParentWithNoTimestamp()
|
||||
{
|
||||
$this->expectException('ReflectionException');
|
||||
$this->expectExceptionMessage('Class "Symfony\Component\Config\Tests\Fixtures\MissingParent" not found while loading "Symfony\Component\Config\Tests\Fixtures\BadParent".');
|
||||
|
||||
$res = new ClassExistenceResource(BadParent::class, false);
|
||||
$res->isFresh(0);
|
||||
}
|
||||
|
||||
public function testBadFileName()
|
||||
{
|
||||
$this->expectException('ReflectionException');
|
||||
$this->expectExceptionMessage('Mismatch between file name and class name.');
|
||||
|
||||
$res = new ClassExistenceResource(BadFileName::class, false);
|
||||
$res->isFresh(0);
|
||||
}
|
||||
|
||||
public function testBadFileNameBis()
|
||||
{
|
||||
$this->expectException('ReflectionException');
|
||||
$this->expectExceptionMessage('Mismatch between file name and class name.');
|
||||
|
||||
$res = new ClassExistenceResource(BadFileName::class, false);
|
||||
$res->isFresh(0);
|
||||
}
|
||||
|
||||
public function testConditionalClass()
|
||||
{
|
||||
$res = new ClassExistenceResource(ConditionalClass::class, false);
|
||||
|
||||
$this->assertFalse($res->isFresh(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7
|
||||
*/
|
||||
public function testParseError()
|
||||
{
|
||||
$this->expectException('ParseError');
|
||||
|
||||
$res = new ClassExistenceResource(ParseError::class, false);
|
||||
$res->isFresh(0);
|
||||
}
|
||||
}
|
||||
47
modules/inpostshipping/vendor/symfony/config/Tests/Resource/ComposerResourceTest.php
vendored
Normal file
47
modules/inpostshipping/vendor/symfony/config/Tests/Resource/ComposerResourceTest.php
vendored
Normal 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\Config\Tests\Resource;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Resource\ComposerResource;
|
||||
|
||||
class ComposerResourceTest extends TestCase
|
||||
{
|
||||
public function testGetVendor()
|
||||
{
|
||||
$res = new ComposerResource();
|
||||
|
||||
$r = new \ReflectionClass(ClassLoader::class);
|
||||
$found = false;
|
||||
|
||||
foreach ($res->getVendors() as $vendor) {
|
||||
if ($vendor && 0 === strpos($r->getFileName(), $vendor)) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertTrue($found);
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize()
|
||||
{
|
||||
$res = new ComposerResource();
|
||||
$ser = unserialize(serialize($res));
|
||||
|
||||
$this->assertTrue($res->isFresh(0));
|
||||
$this->assertTrue($ser->isFresh(0));
|
||||
|
||||
$this->assertEquals($res, $ser);
|
||||
}
|
||||
}
|
||||
181
modules/inpostshipping/vendor/symfony/config/Tests/Resource/DirectoryResourceTest.php
vendored
Normal file
181
modules/inpostshipping/vendor/symfony/config/Tests/Resource/DirectoryResourceTest.php
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
<?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(realpath($this->directory), $resource->getResource(), '->getResource() returns the path to the resource');
|
||||
}
|
||||
|
||||
public function testGetPattern()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory, 'bar');
|
||||
$this->assertEquals('bar', $resource->getPattern());
|
||||
}
|
||||
|
||||
public function testResourceDoesNotExist()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessageMatches('/The directory ".*" does not exist./');
|
||||
new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999));
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
public function testIsFreshForDeletedResources()
|
||||
{
|
||||
$resource = new DirectoryResource($this->directory);
|
||||
$this->removeDirectory($this->directory);
|
||||
|
||||
$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)$/');
|
||||
|
||||
unserialize(serialize($resource));
|
||||
|
||||
$this->assertSame(realpath($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([$resourceA, $resourceB]));
|
||||
}
|
||||
}
|
||||
71
modules/inpostshipping/vendor/symfony/config/Tests/Resource/FileExistenceResourceTest.php
vendored
Normal file
71
modules/inpostshipping/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');
|
||||
}
|
||||
}
|
||||
81
modules/inpostshipping/vendor/symfony/config/Tests/Resource/FileResourceTest.php
vendored
Normal file
81
modules/inpostshipping/vendor/symfony/config/Tests/Resource/FileResourceTest.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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 = sys_get_temp_dir().'/tmp.xml';
|
||||
$this->time = time();
|
||||
touch($this->file, $this->time);
|
||||
$this->resource = new FileResource($this->file);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (file_exists($this->file)) {
|
||||
@unlink($this->file);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetResource()
|
||||
{
|
||||
$this->assertSame(realpath($this->file), $this->resource->getResource(), '->getResource() returns the path to the resource');
|
||||
}
|
||||
|
||||
public function testGetResourceWithScheme()
|
||||
{
|
||||
$resource = new FileResource('file://'.$this->file);
|
||||
$this->assertSame('file://'.$this->file, $resource->getResource(), '->getResource() returns the path to the schemed resource');
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
{
|
||||
$this->assertSame(realpath($this->file), (string) $this->resource);
|
||||
}
|
||||
|
||||
public function testResourceDoesNotExist()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->expectExceptionMessageMatches('/The file ".*" does not exist./');
|
||||
new FileResource('/____foo/foobar'.mt_rand(1, 999999));
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
public function testIsFreshForDeletedResources()
|
||||
{
|
||||
unlink($this->file);
|
||||
|
||||
$this->assertFalse($this->resource->isFresh($this->time), '->isFresh() returns false if the resource does not exist');
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize()
|
||||
{
|
||||
unserialize(serialize($this->resource));
|
||||
|
||||
$this->assertSame(realpath($this->file), $this->resource->getResource());
|
||||
}
|
||||
}
|
||||
114
modules/inpostshipping/vendor/symfony/config/Tests/Resource/GlobResourceTest.php
vendored
Normal file
114
modules/inpostshipping/vendor/symfony/config/Tests/Resource/GlobResourceTest.php
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
<?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\GlobResource;
|
||||
|
||||
class GlobResourceTest extends TestCase
|
||||
{
|
||||
protected function tearDown()
|
||||
{
|
||||
$dir = \dirname(__DIR__).'/Fixtures';
|
||||
@rmdir($dir.'/TmpGlob');
|
||||
@unlink($dir.'/TmpGlob');
|
||||
@unlink($dir.'/Resource/TmpGlob');
|
||||
touch($dir.'/Resource/.hiddenFile');
|
||||
}
|
||||
|
||||
public function testIterator()
|
||||
{
|
||||
$dir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures';
|
||||
$resource = new GlobResource($dir, '/Resource', true);
|
||||
|
||||
$paths = iterator_to_array($resource);
|
||||
|
||||
$file = $dir.'/Resource'.\DIRECTORY_SEPARATOR.'ConditionalClass.php';
|
||||
$this->assertEquals([$file => new \SplFileInfo($file)], $paths);
|
||||
$this->assertInstanceOf('SplFileInfo', current($paths));
|
||||
$this->assertSame($dir, $resource->getPrefix());
|
||||
|
||||
$resource = new GlobResource($dir, '/**/Resource', true);
|
||||
|
||||
$paths = iterator_to_array($resource);
|
||||
|
||||
$file = $dir.\DIRECTORY_SEPARATOR.'Resource'.\DIRECTORY_SEPARATOR.'ConditionalClass.php';
|
||||
$this->assertEquals([$file => $file], $paths);
|
||||
$this->assertInstanceOf('SplFileInfo', current($paths));
|
||||
$this->assertSame($dir, $resource->getPrefix());
|
||||
}
|
||||
|
||||
public function testIsFreshNonRecursiveDetectsNewFile()
|
||||
{
|
||||
$dir = \dirname(__DIR__).'/Fixtures';
|
||||
$resource = new GlobResource($dir, '/*', false);
|
||||
|
||||
$this->assertTrue($resource->isFresh(0));
|
||||
|
||||
mkdir($dir.'/TmpGlob');
|
||||
$this->assertTrue($resource->isFresh(0));
|
||||
|
||||
rmdir($dir.'/TmpGlob');
|
||||
$this->assertTrue($resource->isFresh(0));
|
||||
|
||||
touch($dir.'/TmpGlob');
|
||||
$this->assertFalse($resource->isFresh(0));
|
||||
|
||||
unlink($dir.'/TmpGlob');
|
||||
$this->assertTrue($resource->isFresh(0));
|
||||
}
|
||||
|
||||
public function testIsFreshNonRecursiveDetectsRemovedFile()
|
||||
{
|
||||
$dir = \dirname(__DIR__).'/Fixtures';
|
||||
$resource = new GlobResource($dir, '/*', false);
|
||||
|
||||
touch($dir.'/TmpGlob');
|
||||
touch($dir.'/.TmpGlob');
|
||||
$this->assertTrue($resource->isFresh(0));
|
||||
|
||||
unlink($dir.'/.TmpGlob');
|
||||
$this->assertTrue($resource->isFresh(0));
|
||||
|
||||
unlink($dir.'/TmpGlob');
|
||||
$this->assertFalse($resource->isFresh(0));
|
||||
}
|
||||
|
||||
public function testIsFreshRecursiveDetectsRemovedFile()
|
||||
{
|
||||
$dir = \dirname(__DIR__).'/Fixtures';
|
||||
$resource = new GlobResource($dir, '/*', true);
|
||||
|
||||
touch($dir.'/Resource/TmpGlob');
|
||||
$this->assertTrue($resource->isFresh(0));
|
||||
|
||||
unlink($dir.'/Resource/TmpGlob');
|
||||
$this->assertFalse($resource->isFresh(0));
|
||||
|
||||
touch($dir.'/Resource/TmpGlob');
|
||||
$this->assertTrue($resource->isFresh(0));
|
||||
|
||||
unlink($dir.'/Resource/.hiddenFile');
|
||||
$this->assertTrue($resource->isFresh(0));
|
||||
}
|
||||
|
||||
public function testIsFreshRecursiveDetectsNewFile()
|
||||
{
|
||||
$dir = \dirname(__DIR__).'/Fixtures';
|
||||
$resource = new GlobResource($dir, '/*', true);
|
||||
|
||||
$this->assertTrue($resource->isFresh(0));
|
||||
|
||||
touch($dir.'/Resource/TmpGlob');
|
||||
$this->assertFalse($resource->isFresh(0));
|
||||
}
|
||||
}
|
||||
223
modules/inpostshipping/vendor/symfony/config/Tests/Resource/ReflectionClassResourceTest.php
vendored
Normal file
223
modules/inpostshipping/vendor/symfony/config/Tests/Resource/ReflectionClassResourceTest.php
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
<?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\ReflectionClassResource;
|
||||
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
class ReflectionClassResourceTest extends TestCase
|
||||
{
|
||||
public function testToString()
|
||||
{
|
||||
$res = new ReflectionClassResource(new \ReflectionClass('ErrorException'));
|
||||
|
||||
$this->assertSame('reflection.ErrorException', (string) $res);
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize()
|
||||
{
|
||||
$res = new ReflectionClassResource(new \ReflectionClass(DummyInterface::class));
|
||||
$ser = unserialize(serialize($res));
|
||||
|
||||
$this->assertTrue($res->isFresh(0));
|
||||
$this->assertTrue($ser->isFresh(0));
|
||||
|
||||
$this->assertSame((string) $res, (string) $ser);
|
||||
}
|
||||
|
||||
public function testIsFresh()
|
||||
{
|
||||
$res = new ReflectionClassResource(new \ReflectionClass(__CLASS__));
|
||||
$mtime = filemtime(__FILE__);
|
||||
|
||||
$this->assertTrue($res->isFresh($mtime), '->isFresh() returns true if the resource has not changed in same second');
|
||||
$this->assertTrue($res->isFresh($mtime + 10), '->isFresh() returns true if the resource has not changed');
|
||||
$this->assertTrue($res->isFresh($mtime - 86400), '->isFresh() returns true if the resource has not changed');
|
||||
}
|
||||
|
||||
public function testIsFreshForDeletedResources()
|
||||
{
|
||||
$now = time();
|
||||
$tmp = sys_get_temp_dir().'/tmp.php';
|
||||
file_put_contents($tmp, '<?php class ReflectionClassResourceTestClass {}');
|
||||
require $tmp;
|
||||
|
||||
$res = new ReflectionClassResource(new \ReflectionClass('ReflectionClassResourceTestClass'));
|
||||
$this->assertTrue($res->isFresh($now));
|
||||
|
||||
unlink($tmp);
|
||||
$this->assertFalse($res->isFresh($now), '->isFresh() returns false if the resource does not exist');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideHashedSignature
|
||||
*/
|
||||
public function testHashedSignature($changeExpected, $changedLine, $changedCode, $setContext = null)
|
||||
{
|
||||
if ($setContext) {
|
||||
$setContext();
|
||||
}
|
||||
|
||||
$code = <<<'EOPHP'
|
||||
/* 0*/
|
||||
/* 1*/ class %s extends ErrorException
|
||||
/* 2*/ {
|
||||
/* 3*/ const FOO = 123;
|
||||
/* 4*/
|
||||
/* 5*/ public $pub = [];
|
||||
/* 6*/
|
||||
/* 7*/ protected $prot;
|
||||
/* 8*/
|
||||
/* 9*/ private $priv;
|
||||
/*10*/
|
||||
/*11*/ public function pub($arg = null) {}
|
||||
/*12*/
|
||||
/*13*/ protected function prot($a = []) {}
|
||||
/*14*/
|
||||
/*15*/ private function priv() {}
|
||||
/*16*/
|
||||
/*17*/ public function ccc($bar = A_CONSTANT_THAT_FOR_SURE_WILL_NEVER_BE_DEFINED_CCCCCC) {}
|
||||
/*18*/ }
|
||||
EOPHP;
|
||||
|
||||
static $expectedSignature, $generateSignature;
|
||||
|
||||
if (null === $expectedSignature) {
|
||||
eval(sprintf($code, $class = 'Foo'.str_replace('.', '_', uniqid('', true))));
|
||||
$r = new \ReflectionClass(ReflectionClassResource::class);
|
||||
$generateSignature = $r->getMethod('generateSignature');
|
||||
$generateSignature->setAccessible(true);
|
||||
$generateSignature = $generateSignature->getClosure($r->newInstanceWithoutConstructor());
|
||||
$expectedSignature = implode("\n", iterator_to_array($generateSignature(new \ReflectionClass($class))));
|
||||
}
|
||||
|
||||
$code = explode("\n", $code);
|
||||
if (null !== $changedCode) {
|
||||
$code[$changedLine] = $changedCode;
|
||||
}
|
||||
eval(sprintf(implode("\n", $code), $class = 'Foo'.str_replace('.', '_', uniqid('', true))));
|
||||
$signature = implode("\n", iterator_to_array($generateSignature(new \ReflectionClass($class))));
|
||||
|
||||
if ($changeExpected) {
|
||||
$this->assertNotSame($expectedSignature, $signature);
|
||||
} else {
|
||||
$this->assertSame($expectedSignature, $signature);
|
||||
}
|
||||
}
|
||||
|
||||
public function provideHashedSignature()
|
||||
{
|
||||
yield [0, 0, "// line change\n\n"];
|
||||
yield [1, 0, '/** class docblock */'];
|
||||
yield [1, 1, 'abstract class %s'];
|
||||
yield [1, 1, 'final class %s'];
|
||||
yield [1, 1, 'class %s extends Exception'];
|
||||
yield [1, 1, 'class %s implements '.DummyInterface::class];
|
||||
yield [1, 3, 'const FOO = 456;'];
|
||||
yield [1, 3, 'const BAR = 123;'];
|
||||
yield [1, 4, '/** pub docblock */'];
|
||||
yield [1, 5, 'protected $pub = [];'];
|
||||
yield [1, 5, 'public $pub = [123];'];
|
||||
yield [1, 6, '/** prot docblock */'];
|
||||
yield [1, 7, 'private $prot;'];
|
||||
yield [0, 8, '/** priv docblock */'];
|
||||
yield [0, 9, 'private $priv = 123;'];
|
||||
yield [1, 10, '/** pub docblock */'];
|
||||
if (\PHP_VERSION_ID >= 50600) {
|
||||
yield [1, 11, 'public function pub(...$arg) {}'];
|
||||
}
|
||||
if (\PHP_VERSION_ID >= 70000) {
|
||||
yield [1, 11, 'public function pub($arg = null): Foo {}'];
|
||||
}
|
||||
yield [0, 11, "public function pub(\$arg = null) {\nreturn 123;\n}"];
|
||||
yield [1, 12, '/** prot docblock */'];
|
||||
yield [1, 13, 'protected function prot($a = [123]) {}'];
|
||||
yield [0, 14, '/** priv docblock */'];
|
||||
yield [0, 15, ''];
|
||||
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
// PHP7.4 typed properties without default value are
|
||||
// undefined, make sure this doesn't throw an error
|
||||
yield [1, 5, 'public array $pub;'];
|
||||
yield [0, 7, 'protected int $prot;'];
|
||||
yield [0, 9, 'private string $priv;'];
|
||||
}
|
||||
|
||||
yield [1, 17, 'public function ccc($bar = 187) {}'];
|
||||
yield [1, 17, 'public function ccc($bar = ANOTHER_ONE_THAT_WILL_NEVER_BE_DEFINED_CCCCCCCCC) {}'];
|
||||
yield [1, 17, null, static function () { \define('A_CONSTANT_THAT_FOR_SURE_WILL_NEVER_BE_DEFINED_CCCCCC', 'foo'); }];
|
||||
}
|
||||
|
||||
public function testEventSubscriber()
|
||||
{
|
||||
$res = new ReflectionClassResource(new \ReflectionClass(TestEventSubscriber::class));
|
||||
$this->assertTrue($res->isFresh(0));
|
||||
|
||||
TestEventSubscriber::$subscribedEvents = [123];
|
||||
$this->assertFalse($res->isFresh(0));
|
||||
|
||||
$res = new ReflectionClassResource(new \ReflectionClass(TestEventSubscriber::class));
|
||||
$this->assertTrue($res->isFresh(0));
|
||||
}
|
||||
|
||||
public function testServiceSubscriber()
|
||||
{
|
||||
$res = new ReflectionClassResource(new \ReflectionClass(TestServiceSubscriber::class));
|
||||
$this->assertTrue($res->isFresh(0));
|
||||
|
||||
TestServiceSubscriber::$subscribedServices = [123];
|
||||
$this->assertFalse($res->isFresh(0));
|
||||
|
||||
$res = new ReflectionClassResource(new \ReflectionClass(TestServiceSubscriber::class));
|
||||
$this->assertTrue($res->isFresh(0));
|
||||
}
|
||||
|
||||
public function testIgnoresObjectsInSignature()
|
||||
{
|
||||
$res = new ReflectionClassResource(new \ReflectionClass(TestServiceWithStaticProperty::class));
|
||||
$this->assertTrue($res->isFresh(0));
|
||||
|
||||
TestServiceWithStaticProperty::$initializedObject = new TestServiceWithStaticProperty();
|
||||
$this->assertTrue($res->isFresh(0));
|
||||
}
|
||||
}
|
||||
|
||||
interface DummyInterface
|
||||
{
|
||||
}
|
||||
|
||||
class TestEventSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public static $subscribedEvents = [];
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return self::$subscribedEvents;
|
||||
}
|
||||
}
|
||||
|
||||
class TestServiceSubscriber implements ServiceSubscriberInterface
|
||||
{
|
||||
public static $subscribedServices = [];
|
||||
|
||||
public static function getSubscribedServices()
|
||||
{
|
||||
return self::$subscribedServices;
|
||||
}
|
||||
}
|
||||
|
||||
class TestServiceWithStaticProperty
|
||||
{
|
||||
public static $initializedObject;
|
||||
}
|
||||
34
modules/inpostshipping/vendor/symfony/config/Tests/Resource/ResourceStub.php
vendored
Normal file
34
modules/inpostshipping/vendor/symfony/config/Tests/Resource/ResourceStub.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
11
modules/inpostshipping/vendor/symfony/config/Tests/Resource/index.php
vendored
Normal file
11
modules/inpostshipping/vendor/symfony/config/Tests/Resource/index.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
Reference in New Issue
Block a user