first commit
This commit is contained in:
47
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/AbstractRedisCacheTest.php
vendored
Normal file
47
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/AbstractRedisCacheTest.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\Cache\Tests\Simple;
|
||||
|
||||
use Symfony\Component\Cache\Simple\RedisCache;
|
||||
|
||||
abstract class AbstractRedisCacheTest extends CacheTestCase
|
||||
{
|
||||
protected $skippedTests = [
|
||||
'testSetTtl' => 'Testing expiration slows down the test suite',
|
||||
'testSetMultipleTtl' => 'Testing expiration slows down the test suite',
|
||||
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
|
||||
];
|
||||
|
||||
protected static $redis;
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
return new RedisCache(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
if (!\extension_loaded('redis')) {
|
||||
self::markTestSkipped('Extension redis required.');
|
||||
}
|
||||
try {
|
||||
(new \Redis())->connect(getenv('REDIS_HOST'));
|
||||
} catch (\Exception $e) {
|
||||
self::markTestSkipped($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
self::$redis = null;
|
||||
}
|
||||
}
|
||||
35
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/ApcuCacheTest.php
vendored
Normal file
35
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/ApcuCacheTest.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Symfony\Component\Cache\Simple\ApcuCache;
|
||||
|
||||
class ApcuCacheTest extends CacheTestCase
|
||||
{
|
||||
protected $skippedTests = [
|
||||
'testSetTtl' => 'Testing expiration slows down the test suite',
|
||||
'testSetMultipleTtl' => 'Testing expiration slows down the test suite',
|
||||
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
|
||||
];
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) || ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) {
|
||||
$this->markTestSkipped('APCu extension is required.');
|
||||
}
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Fails transiently on Windows.');
|
||||
}
|
||||
|
||||
return new ApcuCache(str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
}
|
||||
}
|
||||
25
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/ArrayCacheTest.php
vendored
Normal file
25
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/ArrayCacheTest.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Symfony\Component\Cache\Simple\ArrayCache;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class ArrayCacheTest extends CacheTestCase
|
||||
{
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
return new ArrayCache($defaultLifetime);
|
||||
}
|
||||
}
|
||||
150
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/CacheTestCase.php
vendored
Normal file
150
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/CacheTestCase.php
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Cache\IntegrationTests\SimpleCacheTest;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\PruneableInterface;
|
||||
|
||||
abstract class CacheTestCase extends SimpleCacheTest
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!\array_key_exists('testPrune', $this->skippedTests) && !$this->createSimpleCache() instanceof PruneableInterface) {
|
||||
$this->skippedTests['testPrune'] = 'Not a pruneable cache pool.';
|
||||
}
|
||||
}
|
||||
|
||||
public static function validKeys()
|
||||
{
|
||||
if (\defined('HHVM_VERSION')) {
|
||||
return parent::validKeys();
|
||||
}
|
||||
|
||||
return array_merge(parent::validKeys(), [["a\0b"]]);
|
||||
}
|
||||
|
||||
public function testDefaultLifeTime()
|
||||
{
|
||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
||||
}
|
||||
|
||||
$cache = $this->createSimpleCache(2);
|
||||
$cache->clear();
|
||||
|
||||
$cache->set('key.dlt', 'value');
|
||||
sleep(1);
|
||||
|
||||
$this->assertSame('value', $cache->get('key.dlt'));
|
||||
|
||||
sleep(2);
|
||||
$this->assertNull($cache->get('key.dlt'));
|
||||
|
||||
$cache->clear();
|
||||
}
|
||||
|
||||
public function testNotUnserializable()
|
||||
{
|
||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
||||
}
|
||||
|
||||
$cache = $this->createSimpleCache();
|
||||
$cache->clear();
|
||||
|
||||
$cache->set('foo', new NotUnserializable());
|
||||
|
||||
$this->assertNull($cache->get('foo'));
|
||||
|
||||
$cache->setMultiple(['foo' => new NotUnserializable()]);
|
||||
|
||||
foreach ($cache->getMultiple(['foo']) as $value) {
|
||||
}
|
||||
$this->assertNull($value);
|
||||
|
||||
$cache->clear();
|
||||
}
|
||||
|
||||
public function testPrune()
|
||||
{
|
||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
||||
}
|
||||
|
||||
if (!method_exists($this, 'isPruned')) {
|
||||
$this->fail('Test classes for pruneable caches must implement `isPruned($cache, $name)` method.');
|
||||
}
|
||||
|
||||
/** @var PruneableInterface|CacheInterface $cache */
|
||||
$cache = $this->createSimpleCache();
|
||||
$cache->clear();
|
||||
|
||||
$cache->set('foo', 'foo-val', new \DateInterval('PT05S'));
|
||||
$cache->set('bar', 'bar-val', new \DateInterval('PT10S'));
|
||||
$cache->set('baz', 'baz-val', new \DateInterval('PT15S'));
|
||||
$cache->set('qux', 'qux-val', new \DateInterval('PT20S'));
|
||||
|
||||
sleep(30);
|
||||
$cache->prune();
|
||||
$this->assertTrue($this->isPruned($cache, 'foo'));
|
||||
$this->assertTrue($this->isPruned($cache, 'bar'));
|
||||
$this->assertTrue($this->isPruned($cache, 'baz'));
|
||||
$this->assertTrue($this->isPruned($cache, 'qux'));
|
||||
|
||||
$cache->set('foo', 'foo-val');
|
||||
$cache->set('bar', 'bar-val', new \DateInterval('PT20S'));
|
||||
$cache->set('baz', 'baz-val', new \DateInterval('PT40S'));
|
||||
$cache->set('qux', 'qux-val', new \DateInterval('PT80S'));
|
||||
|
||||
$cache->prune();
|
||||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
||||
$this->assertFalse($this->isPruned($cache, 'bar'));
|
||||
$this->assertFalse($this->isPruned($cache, 'baz'));
|
||||
$this->assertFalse($this->isPruned($cache, 'qux'));
|
||||
|
||||
sleep(30);
|
||||
$cache->prune();
|
||||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
||||
$this->assertTrue($this->isPruned($cache, 'bar'));
|
||||
$this->assertFalse($this->isPruned($cache, 'baz'));
|
||||
$this->assertFalse($this->isPruned($cache, 'qux'));
|
||||
|
||||
sleep(30);
|
||||
$cache->prune();
|
||||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
||||
$this->assertTrue($this->isPruned($cache, 'baz'));
|
||||
$this->assertFalse($this->isPruned($cache, 'qux'));
|
||||
|
||||
sleep(30);
|
||||
$cache->prune();
|
||||
$this->assertFalse($this->isPruned($cache, 'foo'));
|
||||
$this->assertTrue($this->isPruned($cache, 'qux'));
|
||||
|
||||
$cache->clear();
|
||||
}
|
||||
}
|
||||
|
||||
class NotUnserializable implements \Serializable
|
||||
{
|
||||
public function serialize()
|
||||
{
|
||||
return serialize(123);
|
||||
}
|
||||
|
||||
public function unserialize($ser)
|
||||
{
|
||||
throw new \Exception(__CLASS__);
|
||||
}
|
||||
}
|
||||
113
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/ChainCacheTest.php
vendored
Normal file
113
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/ChainCacheTest.php
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\PruneableInterface;
|
||||
use Symfony\Component\Cache\Simple\ArrayCache;
|
||||
use Symfony\Component\Cache\Simple\ChainCache;
|
||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class ChainCacheTest extends CacheTestCase
|
||||
{
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
return new ChainCache([new ArrayCache($defaultLifetime), new FilesystemCache('', $defaultLifetime)], $defaultLifetime);
|
||||
}
|
||||
|
||||
public function testEmptyCachesException()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
||||
$this->expectExceptionMessage('At least one cache must be specified.');
|
||||
new ChainCache([]);
|
||||
}
|
||||
|
||||
public function testInvalidCacheException()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
||||
$this->expectExceptionMessage('The class "stdClass" does not implement');
|
||||
new ChainCache([new \stdClass()]);
|
||||
}
|
||||
|
||||
public function testPrune()
|
||||
{
|
||||
if (isset($this->skippedTests[__FUNCTION__])) {
|
||||
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
|
||||
}
|
||||
|
||||
$cache = new ChainCache([
|
||||
$this->getPruneableMock(),
|
||||
$this->getNonPruneableMock(),
|
||||
$this->getPruneableMock(),
|
||||
]);
|
||||
$this->assertTrue($cache->prune());
|
||||
|
||||
$cache = new ChainCache([
|
||||
$this->getPruneableMock(),
|
||||
$this->getFailingPruneableMock(),
|
||||
$this->getPruneableMock(),
|
||||
]);
|
||||
$this->assertFalse($cache->prune());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockObject|PruneableCacheInterface
|
||||
*/
|
||||
private function getPruneableMock()
|
||||
{
|
||||
$pruneable = $this
|
||||
->getMockBuilder(PruneableCacheInterface::class)
|
||||
->getMock();
|
||||
|
||||
$pruneable
|
||||
->expects($this->atLeastOnce())
|
||||
->method('prune')
|
||||
->willReturn(true);
|
||||
|
||||
return $pruneable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockObject|PruneableCacheInterface
|
||||
*/
|
||||
private function getFailingPruneableMock()
|
||||
{
|
||||
$pruneable = $this
|
||||
->getMockBuilder(PruneableCacheInterface::class)
|
||||
->getMock();
|
||||
|
||||
$pruneable
|
||||
->expects($this->atLeastOnce())
|
||||
->method('prune')
|
||||
->willReturn(false);
|
||||
|
||||
return $pruneable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockObject|CacheInterface
|
||||
*/
|
||||
private function getNonPruneableMock()
|
||||
{
|
||||
return $this
|
||||
->getMockBuilder(CacheInterface::class)
|
||||
->getMock();
|
||||
}
|
||||
}
|
||||
|
||||
interface PruneableCacheInterface extends PruneableInterface, CacheInterface
|
||||
{
|
||||
}
|
||||
31
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/DoctrineCacheTest.php
vendored
Normal file
31
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/DoctrineCacheTest.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Symfony\Component\Cache\Simple\DoctrineCache;
|
||||
use Symfony\Component\Cache\Tests\Fixtures\ArrayCache;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class DoctrineCacheTest extends CacheTestCase
|
||||
{
|
||||
protected $skippedTests = [
|
||||
'testObjectDoesNotChangeInCache' => 'ArrayCache does not use serialize/unserialize',
|
||||
'testNotUnserializable' => 'ArrayCache does not use serialize/unserialize',
|
||||
];
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
return new DoctrineCache(new ArrayCache($defaultLifetime), '', $defaultLifetime);
|
||||
}
|
||||
}
|
||||
34
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/FilesystemCacheTest.php
vendored
Normal file
34
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/FilesystemCacheTest.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\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class FilesystemCacheTest extends CacheTestCase
|
||||
{
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
return new FilesystemCache('', $defaultLifetime);
|
||||
}
|
||||
|
||||
protected function isPruned(CacheInterface $cache, $name)
|
||||
{
|
||||
$getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile');
|
||||
$getFileMethod->setAccessible(true);
|
||||
|
||||
return !file_exists($getFileMethod->invoke($cache, $name));
|
||||
}
|
||||
}
|
||||
178
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/MemcachedCacheTest.php
vendored
Normal file
178
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/MemcachedCacheTest.php
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||
use Symfony\Component\Cache\Simple\MemcachedCache;
|
||||
|
||||
class MemcachedCacheTest extends CacheTestCase
|
||||
{
|
||||
protected $skippedTests = [
|
||||
'testSetTtl' => 'Testing expiration slows down the test suite',
|
||||
'testSetMultipleTtl' => 'Testing expiration slows down the test suite',
|
||||
'testDefaultLifeTime' => 'Testing expiration slows down the test suite',
|
||||
];
|
||||
|
||||
protected static $client;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
if (!MemcachedCache::isSupported()) {
|
||||
self::markTestSkipped('Extension memcached >=2.2.0 required.');
|
||||
}
|
||||
self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'));
|
||||
self::$client->get('foo');
|
||||
$code = self::$client->getResultCode();
|
||||
|
||||
if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) {
|
||||
self::markTestSkipped('Memcached error: '.strtolower(self::$client->getResultMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
$client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]) : self::$client;
|
||||
|
||||
return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
}
|
||||
|
||||
public function testCreatePersistentConnectionShouldNotDupServerList()
|
||||
{
|
||||
$instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['persistent_id' => 'persistent']);
|
||||
$this->assertCount(1, $instance->getServerList());
|
||||
|
||||
$instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['persistent_id' => 'persistent']);
|
||||
$this->assertCount(1, $instance->getServerList());
|
||||
}
|
||||
|
||||
public function testOptions()
|
||||
{
|
||||
$client = MemcachedCache::createConnection([], [
|
||||
'libketama_compatible' => false,
|
||||
'distribution' => 'modula',
|
||||
'compression' => true,
|
||||
'serializer' => 'php',
|
||||
'hash' => 'md5',
|
||||
]);
|
||||
|
||||
$this->assertSame(\Memcached::SERIALIZER_PHP, $client->getOption(\Memcached::OPT_SERIALIZER));
|
||||
$this->assertSame(\Memcached::HASH_MD5, $client->getOption(\Memcached::OPT_HASH));
|
||||
$this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION));
|
||||
$this->assertSame(0, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE));
|
||||
$this->assertSame(\Memcached::DISTRIBUTION_MODULA, $client->getOption(\Memcached::OPT_DISTRIBUTION));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideBadOptions
|
||||
*/
|
||||
public function testBadOptions($name, $value)
|
||||
{
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
$this->expectException('ErrorException');
|
||||
$this->expectExceptionMessage('constant(): Couldn\'t find constant Memcached::');
|
||||
} else {
|
||||
$this->expectException('Error');
|
||||
$this->expectExceptionMessage('Undefined constant Memcached::');
|
||||
}
|
||||
|
||||
MemcachedCache::createConnection([], [$name => $value]);
|
||||
}
|
||||
|
||||
public function provideBadOptions()
|
||||
{
|
||||
return [
|
||||
['foo', 'bar'],
|
||||
['hash', 'zyx'],
|
||||
['serializer', 'zyx'],
|
||||
['distribution', 'zyx'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testDefaultOptions()
|
||||
{
|
||||
$this->assertTrue(MemcachedCache::isSupported());
|
||||
|
||||
$client = MemcachedCache::createConnection([]);
|
||||
|
||||
$this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION));
|
||||
$this->assertSame(1, $client->getOption(\Memcached::OPT_BINARY_PROTOCOL));
|
||||
$this->assertSame(1, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE));
|
||||
}
|
||||
|
||||
public function testOptionSerializer()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Cache\Exception\CacheException');
|
||||
$this->expectExceptionMessage('MemcachedAdapter: "serializer" option must be "php" or "igbinary".');
|
||||
if (!\Memcached::HAVE_JSON) {
|
||||
$this->markTestSkipped('Memcached::HAVE_JSON required');
|
||||
}
|
||||
|
||||
new MemcachedCache(MemcachedCache::createConnection([], ['serializer' => 'json']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideServersSetting
|
||||
*/
|
||||
public function testServersSetting($dsn, $host, $port)
|
||||
{
|
||||
$client1 = MemcachedCache::createConnection($dsn);
|
||||
$client2 = MemcachedCache::createConnection([$dsn]);
|
||||
$client3 = MemcachedCache::createConnection([[$host, $port]]);
|
||||
$expect = [
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
];
|
||||
|
||||
$f = function ($s) { return ['host' => $s['host'], 'port' => $s['port']]; };
|
||||
$this->assertSame([$expect], array_map($f, $client1->getServerList()));
|
||||
$this->assertSame([$expect], array_map($f, $client2->getServerList()));
|
||||
$this->assertSame([$expect], array_map($f, $client3->getServerList()));
|
||||
}
|
||||
|
||||
public function provideServersSetting()
|
||||
{
|
||||
yield [
|
||||
'memcached://127.0.0.1/50',
|
||||
'127.0.0.1',
|
||||
11211,
|
||||
];
|
||||
yield [
|
||||
'memcached://localhost:11222?weight=25',
|
||||
'localhost',
|
||||
11222,
|
||||
];
|
||||
if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) {
|
||||
yield [
|
||||
'memcached://user:password@127.0.0.1?weight=50',
|
||||
'127.0.0.1',
|
||||
11211,
|
||||
];
|
||||
}
|
||||
yield [
|
||||
'memcached:///var/run/memcached.sock?weight=25',
|
||||
'/var/run/memcached.sock',
|
||||
0,
|
||||
];
|
||||
yield [
|
||||
'memcached:///var/local/run/memcached.socket?weight=25',
|
||||
'/var/local/run/memcached.socket',
|
||||
0,
|
||||
];
|
||||
if (filter_var(ini_get('memcached.use_sasl'), \FILTER_VALIDATE_BOOLEAN)) {
|
||||
yield [
|
||||
'memcached://user:password@/var/local/run/memcached.socket?weight=25',
|
||||
'/var/local/run/memcached.socket',
|
||||
0,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
25
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/MemcachedCacheTextModeTest.php
vendored
Normal file
25
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/MemcachedCacheTextModeTest.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Symfony\Component\Cache\Adapter\AbstractAdapter;
|
||||
use Symfony\Component\Cache\Simple\MemcachedCache;
|
||||
|
||||
class MemcachedCacheTextModeTest extends MemcachedCacheTest
|
||||
{
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]);
|
||||
|
||||
return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
|
||||
}
|
||||
}
|
||||
96
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/NullCacheTest.php
vendored
Normal file
96
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/NullCacheTest.php
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Cache\Simple\NullCache;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class NullCacheTest extends TestCase
|
||||
{
|
||||
public function createCachePool()
|
||||
{
|
||||
return new NullCache();
|
||||
}
|
||||
|
||||
public function testGetItem()
|
||||
{
|
||||
$cache = $this->createCachePool();
|
||||
|
||||
$this->assertNull($cache->get('key'));
|
||||
}
|
||||
|
||||
public function testHas()
|
||||
{
|
||||
$this->assertFalse($this->createCachePool()->has('key'));
|
||||
}
|
||||
|
||||
public function testGetMultiple()
|
||||
{
|
||||
$cache = $this->createCachePool();
|
||||
|
||||
$keys = ['foo', 'bar', 'baz', 'biz'];
|
||||
|
||||
$default = new \stdClass();
|
||||
$items = $cache->getMultiple($keys, $default);
|
||||
$count = 0;
|
||||
|
||||
foreach ($items as $key => $item) {
|
||||
$this->assertContains($key, $keys, 'Cache key can not change.');
|
||||
$this->assertSame($default, $item);
|
||||
|
||||
// Remove $key for $keys
|
||||
foreach ($keys as $k => $v) {
|
||||
if ($v === $key) {
|
||||
unset($keys[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
++$count;
|
||||
}
|
||||
|
||||
$this->assertSame(4, $count);
|
||||
}
|
||||
|
||||
public function testClear()
|
||||
{
|
||||
$this->assertTrue($this->createCachePool()->clear());
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$this->assertTrue($this->createCachePool()->delete('key'));
|
||||
}
|
||||
|
||||
public function testDeleteMultiple()
|
||||
{
|
||||
$this->assertTrue($this->createCachePool()->deleteMultiple(['key', 'foo', 'bar']));
|
||||
}
|
||||
|
||||
public function testSet()
|
||||
{
|
||||
$cache = $this->createCachePool();
|
||||
|
||||
$this->assertFalse($cache->set('key', 'val'));
|
||||
$this->assertNull($cache->get('key'));
|
||||
}
|
||||
|
||||
public function testSetMultiple()
|
||||
{
|
||||
$cache = $this->createCachePool();
|
||||
|
||||
$this->assertFalse($cache->setMultiple(['key' => 'val']));
|
||||
$this->assertNull($cache->get('key'));
|
||||
}
|
||||
}
|
||||
47
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/PdoCacheTest.php
vendored
Normal file
47
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/PdoCacheTest.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\Cache\Tests\Simple;
|
||||
|
||||
use Symfony\Component\Cache\Simple\PdoCache;
|
||||
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class PdoCacheTest extends CacheTestCase
|
||||
{
|
||||
use PdoPruneableTrait;
|
||||
|
||||
protected static $dbFile;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
if (!\extension_loaded('pdo_sqlite')) {
|
||||
self::markTestSkipped('Extension pdo_sqlite required.');
|
||||
}
|
||||
|
||||
self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache');
|
||||
|
||||
$pool = new PdoCache('sqlite:'.self::$dbFile);
|
||||
$pool->createTable();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
@unlink(self::$dbFile);
|
||||
}
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
return new PdoCache('sqlite:'.self::$dbFile, 'ns', $defaultLifetime);
|
||||
}
|
||||
}
|
||||
48
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/PdoDbalCacheTest.php
vendored
Normal file
48
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/PdoDbalCacheTest.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Symfony\Component\Cache\Simple\PdoCache;
|
||||
use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class PdoDbalCacheTest extends CacheTestCase
|
||||
{
|
||||
use PdoPruneableTrait;
|
||||
|
||||
protected static $dbFile;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
if (!\extension_loaded('pdo_sqlite')) {
|
||||
self::markTestSkipped('Extension pdo_sqlite required.');
|
||||
}
|
||||
|
||||
self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache');
|
||||
|
||||
$pool = new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]));
|
||||
$pool->createTable();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
@unlink(self::$dbFile);
|
||||
}
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
return new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]), '', $defaultLifetime);
|
||||
}
|
||||
}
|
||||
145
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/PhpArrayCacheTest.php
vendored
Normal file
145
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/PhpArrayCacheTest.php
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Symfony\Component\Cache\Simple\NullCache;
|
||||
use Symfony\Component\Cache\Simple\PhpArrayCache;
|
||||
use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class PhpArrayCacheTest extends CacheTestCase
|
||||
{
|
||||
protected $skippedTests = [
|
||||
'testBasicUsageWithLongKey' => 'PhpArrayCache does no writes',
|
||||
|
||||
'testDelete' => 'PhpArrayCache does no writes',
|
||||
'testDeleteMultiple' => 'PhpArrayCache does no writes',
|
||||
'testDeleteMultipleGenerator' => 'PhpArrayCache does no writes',
|
||||
|
||||
'testSetTtl' => 'PhpArrayCache does no expiration',
|
||||
'testSetMultipleTtl' => 'PhpArrayCache does no expiration',
|
||||
'testSetExpiredTtl' => 'PhpArrayCache does no expiration',
|
||||
'testSetMultipleExpiredTtl' => 'PhpArrayCache does no expiration',
|
||||
|
||||
'testGetInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testSetInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testDeleteInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testDeleteMultipleInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testSetInvalidTtl' => 'PhpArrayCache does no validation',
|
||||
'testSetMultipleInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testSetMultipleInvalidTtl' => 'PhpArrayCache does no validation',
|
||||
'testHasInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testSetValidData' => 'PhpArrayCache does no validation',
|
||||
|
||||
'testDefaultLifeTime' => 'PhpArrayCache does not allow configuring a default lifetime.',
|
||||
'testPrune' => 'PhpArrayCache just proxies',
|
||||
];
|
||||
|
||||
protected static $file;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php';
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->createSimpleCache()->clear();
|
||||
|
||||
if (file_exists(sys_get_temp_dir().'/symfony-cache')) {
|
||||
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');
|
||||
}
|
||||
}
|
||||
|
||||
public function createSimpleCache()
|
||||
{
|
||||
return new PhpArrayCacheWrapper(self::$file, new NullCache());
|
||||
}
|
||||
|
||||
public function testStore()
|
||||
{
|
||||
$arrayWithRefs = [];
|
||||
$arrayWithRefs[0] = 123;
|
||||
$arrayWithRefs[1] = &$arrayWithRefs[0];
|
||||
|
||||
$object = (object) [
|
||||
'foo' => 'bar',
|
||||
'foo2' => 'bar2',
|
||||
];
|
||||
|
||||
$expected = [
|
||||
'null' => null,
|
||||
'serializedString' => serialize($object),
|
||||
'arrayWithRefs' => $arrayWithRefs,
|
||||
'object' => $object,
|
||||
'arrayWithObject' => ['bar' => $object],
|
||||
];
|
||||
|
||||
$cache = new PhpArrayCache(self::$file, new NullCache());
|
||||
$cache->warmUp($expected);
|
||||
|
||||
foreach ($expected as $key => $value) {
|
||||
$this->assertSame(serialize($value), serialize($cache->get($key)), 'Warm up should create a PHP file that OPCache can load in memory');
|
||||
}
|
||||
}
|
||||
|
||||
public function testStoredFile()
|
||||
{
|
||||
$expected = [
|
||||
'integer' => 42,
|
||||
'float' => 42.42,
|
||||
'boolean' => true,
|
||||
'array_simple' => ['foo', 'bar'],
|
||||
'array_associative' => ['foo' => 'bar', 'foo2' => 'bar2'],
|
||||
];
|
||||
|
||||
$cache = new PhpArrayCache(self::$file, new NullCache());
|
||||
$cache->warmUp($expected);
|
||||
|
||||
$values = eval(substr(file_get_contents(self::$file), 6));
|
||||
|
||||
$this->assertSame($expected, $values, 'Warm up should create a PHP file that OPCache can load in memory');
|
||||
}
|
||||
}
|
||||
|
||||
class PhpArrayCacheWrapper extends PhpArrayCache
|
||||
{
|
||||
public function set($key, $value, $ttl = null)
|
||||
{
|
||||
\call_user_func(\Closure::bind(function () use ($key, $value) {
|
||||
$this->values[$key] = $value;
|
||||
$this->warmUp($this->values);
|
||||
$this->values = eval(substr(file_get_contents($this->file), 6));
|
||||
}, $this, PhpArrayCache::class));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setMultiple($values, $ttl = null)
|
||||
{
|
||||
if (!\is_array($values) && !$values instanceof \Traversable) {
|
||||
return parent::setMultiple($values, $ttl);
|
||||
}
|
||||
\call_user_func(\Closure::bind(function () use ($values) {
|
||||
foreach ($values as $key => $value) {
|
||||
$this->values[$key] = $value;
|
||||
}
|
||||
$this->warmUp($this->values);
|
||||
$this->values = eval(substr(file_get_contents($this->file), 6));
|
||||
}, $this, PhpArrayCache::class));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
57
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php
vendored
Normal file
57
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
||||
use Symfony\Component\Cache\Simple\PhpArrayCache;
|
||||
use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class PhpArrayCacheWithFallbackTest extends CacheTestCase
|
||||
{
|
||||
protected $skippedTests = [
|
||||
'testGetInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testDeleteInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testDeleteMultipleInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
//'testSetValidData' => 'PhpArrayCache does no validation',
|
||||
'testSetInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testSetInvalidTtl' => 'PhpArrayCache does no validation',
|
||||
'testSetMultipleInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testSetMultipleInvalidTtl' => 'PhpArrayCache does no validation',
|
||||
'testHasInvalidKeys' => 'PhpArrayCache does no validation',
|
||||
'testPrune' => 'PhpArrayCache just proxies',
|
||||
];
|
||||
|
||||
protected static $file;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php';
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->createSimpleCache()->clear();
|
||||
|
||||
if (file_exists(sys_get_temp_dir().'/symfony-cache')) {
|
||||
FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache');
|
||||
}
|
||||
}
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
return new PhpArrayCache(self::$file, new FilesystemCache('php-array-fallback', $defaultLifetime));
|
||||
}
|
||||
}
|
||||
42
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/PhpFilesCacheTest.php
vendored
Normal file
42
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/PhpFilesCacheTest.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Component\Cache\Simple\PhpFilesCache;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class PhpFilesCacheTest extends CacheTestCase
|
||||
{
|
||||
protected $skippedTests = [
|
||||
'testDefaultLifeTime' => 'PhpFilesCache does not allow configuring a default lifetime.',
|
||||
];
|
||||
|
||||
public function createSimpleCache()
|
||||
{
|
||||
if (!PhpFilesCache::isSupported()) {
|
||||
$this->markTestSkipped('OPcache extension is not enabled.');
|
||||
}
|
||||
|
||||
return new PhpFilesCache('sf-cache');
|
||||
}
|
||||
|
||||
protected function isPruned(CacheInterface $cache, $name)
|
||||
{
|
||||
$getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile');
|
||||
$getFileMethod->setAccessible(true);
|
||||
|
||||
return !file_exists($getFileMethod->invoke($cache, $name));
|
||||
}
|
||||
}
|
||||
30
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/Psr6CacheTest.php
vendored
Normal file
30
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/Psr6CacheTest.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Simple\Psr6Cache;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class Psr6CacheTest extends CacheTestCase
|
||||
{
|
||||
protected $skippedTests = [
|
||||
'testPrune' => 'Psr6Cache just proxies',
|
||||
];
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
return new Psr6Cache(new FilesystemAdapter('', $defaultLifetime));
|
||||
}
|
||||
}
|
||||
24
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/RedisArrayCacheTest.php
vendored
Normal file
24
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/RedisArrayCacheTest.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
class RedisArrayCacheTest extends AbstractRedisCacheTest
|
||||
{
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setupBeforeClass();
|
||||
if (!class_exists('RedisArray')) {
|
||||
self::markTestSkipped('The RedisArray class is required.');
|
||||
}
|
||||
self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]);
|
||||
}
|
||||
}
|
||||
82
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/RedisCacheTest.php
vendored
Normal file
82
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/RedisCacheTest.php
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Symfony\Component\Cache\Simple\RedisCache;
|
||||
|
||||
class RedisCacheTest extends AbstractRedisCacheTest
|
||||
{
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
parent::setupBeforeClass();
|
||||
self::$redis = RedisCache::createConnection('redis://'.getenv('REDIS_HOST'));
|
||||
}
|
||||
|
||||
public function testCreateConnection()
|
||||
{
|
||||
$redisHost = getenv('REDIS_HOST');
|
||||
|
||||
$redis = RedisCache::createConnection('redis://'.$redisHost);
|
||||
$this->assertInstanceOf(\Redis::class, $redis);
|
||||
$this->assertTrue($redis->isConnected());
|
||||
$this->assertSame(0, $redis->getDbNum());
|
||||
|
||||
$redis = RedisCache::createConnection('redis://'.$redisHost.'/2');
|
||||
$this->assertSame(2, $redis->getDbNum());
|
||||
|
||||
$redis = RedisCache::createConnection('redis://'.$redisHost, ['timeout' => 3]);
|
||||
$this->assertEquals(3, $redis->getTimeout());
|
||||
|
||||
$redis = RedisCache::createConnection('redis://'.$redisHost.'?timeout=4');
|
||||
$this->assertEquals(4, $redis->getTimeout());
|
||||
|
||||
$redis = RedisCache::createConnection('redis://'.$redisHost, ['read_timeout' => 5]);
|
||||
$this->assertEquals(5, $redis->getReadTimeout());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFailedCreateConnection
|
||||
*/
|
||||
public function testFailedCreateConnection($dsn)
|
||||
{
|
||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
||||
$this->expectExceptionMessage('Redis connection ');
|
||||
RedisCache::createConnection($dsn);
|
||||
}
|
||||
|
||||
public function provideFailedCreateConnection()
|
||||
{
|
||||
return [
|
||||
['redis://localhost:1234'],
|
||||
['redis://foo@localhost'],
|
||||
['redis://localhost/123'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidCreateConnection
|
||||
*/
|
||||
public function testInvalidCreateConnection($dsn)
|
||||
{
|
||||
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
|
||||
$this->expectExceptionMessage('Invalid Redis DSN');
|
||||
RedisCache::createConnection($dsn);
|
||||
}
|
||||
|
||||
public function provideInvalidCreateConnection()
|
||||
{
|
||||
return [
|
||||
['foo://localhost'],
|
||||
['redis://'],
|
||||
];
|
||||
}
|
||||
}
|
||||
27
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/RedisClusterCacheTest.php
vendored
Normal file
27
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/RedisClusterCacheTest.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
class RedisClusterCacheTest extends AbstractRedisCacheTest
|
||||
{
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
if (!class_exists('RedisCluster')) {
|
||||
self::markTestSkipped('The RedisCluster class is required.');
|
||||
}
|
||||
if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) {
|
||||
self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.');
|
||||
}
|
||||
|
||||
self::$redis = new \RedisCluster(null, explode(' ', $hosts));
|
||||
}
|
||||
}
|
||||
171
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/TraceableCacheTest.php
vendored
Normal file
171
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/TraceableCacheTest.php
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
<?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\Cache\Tests\Simple;
|
||||
|
||||
use Symfony\Component\Cache\Simple\FilesystemCache;
|
||||
use Symfony\Component\Cache\Simple\TraceableCache;
|
||||
|
||||
/**
|
||||
* @group time-sensitive
|
||||
*/
|
||||
class TraceableCacheTest extends CacheTestCase
|
||||
{
|
||||
protected $skippedTests = [
|
||||
'testPrune' => 'TraceableCache just proxies',
|
||||
];
|
||||
|
||||
public function createSimpleCache($defaultLifetime = 0)
|
||||
{
|
||||
return new TraceableCache(new FilesystemCache('', $defaultLifetime));
|
||||
}
|
||||
|
||||
public function testGetMissTrace()
|
||||
{
|
||||
$pool = $this->createSimpleCache();
|
||||
$pool->get('k');
|
||||
$calls = $pool->getCalls();
|
||||
$this->assertCount(1, $calls);
|
||||
|
||||
$call = $calls[0];
|
||||
$this->assertSame('get', $call->name);
|
||||
$this->assertSame(['k' => false], $call->result);
|
||||
$this->assertSame(0, $call->hits);
|
||||
$this->assertSame(1, $call->misses);
|
||||
$this->assertNotEmpty($call->start);
|
||||
$this->assertNotEmpty($call->end);
|
||||
}
|
||||
|
||||
public function testGetHitTrace()
|
||||
{
|
||||
$pool = $this->createSimpleCache();
|
||||
$pool->set('k', 'foo');
|
||||
$pool->get('k');
|
||||
$calls = $pool->getCalls();
|
||||
$this->assertCount(2, $calls);
|
||||
|
||||
$call = $calls[1];
|
||||
$this->assertSame(1, $call->hits);
|
||||
$this->assertSame(0, $call->misses);
|
||||
}
|
||||
|
||||
public function testGetMultipleMissTrace()
|
||||
{
|
||||
$pool = $this->createSimpleCache();
|
||||
$pool->set('k1', 123);
|
||||
$values = $pool->getMultiple(['k0', 'k1']);
|
||||
foreach ($values as $value) {
|
||||
}
|
||||
$calls = $pool->getCalls();
|
||||
$this->assertCount(2, $calls);
|
||||
|
||||
$call = $calls[1];
|
||||
$this->assertSame('getMultiple', $call->name);
|
||||
$this->assertSame(['k1' => true, 'k0' => false], $call->result);
|
||||
$this->assertSame(1, $call->misses);
|
||||
$this->assertNotEmpty($call->start);
|
||||
$this->assertNotEmpty($call->end);
|
||||
}
|
||||
|
||||
public function testHasMissTrace()
|
||||
{
|
||||
$pool = $this->createSimpleCache();
|
||||
$pool->has('k');
|
||||
$calls = $pool->getCalls();
|
||||
$this->assertCount(1, $calls);
|
||||
|
||||
$call = $calls[0];
|
||||
$this->assertSame('has', $call->name);
|
||||
$this->assertSame(['k' => false], $call->result);
|
||||
$this->assertNotEmpty($call->start);
|
||||
$this->assertNotEmpty($call->end);
|
||||
}
|
||||
|
||||
public function testHasHitTrace()
|
||||
{
|
||||
$pool = $this->createSimpleCache();
|
||||
$pool->set('k', 'foo');
|
||||
$pool->has('k');
|
||||
$calls = $pool->getCalls();
|
||||
$this->assertCount(2, $calls);
|
||||
|
||||
$call = $calls[1];
|
||||
$this->assertSame('has', $call->name);
|
||||
$this->assertSame(['k' => true], $call->result);
|
||||
$this->assertNotEmpty($call->start);
|
||||
$this->assertNotEmpty($call->end);
|
||||
}
|
||||
|
||||
public function testDeleteTrace()
|
||||
{
|
||||
$pool = $this->createSimpleCache();
|
||||
$pool->delete('k');
|
||||
$calls = $pool->getCalls();
|
||||
$this->assertCount(1, $calls);
|
||||
|
||||
$call = $calls[0];
|
||||
$this->assertSame('delete', $call->name);
|
||||
$this->assertSame(['k' => true], $call->result);
|
||||
$this->assertSame(0, $call->hits);
|
||||
$this->assertSame(0, $call->misses);
|
||||
$this->assertNotEmpty($call->start);
|
||||
$this->assertNotEmpty($call->end);
|
||||
}
|
||||
|
||||
public function testDeleteMultipleTrace()
|
||||
{
|
||||
$pool = $this->createSimpleCache();
|
||||
$arg = ['k0', 'k1'];
|
||||
$pool->deleteMultiple($arg);
|
||||
$calls = $pool->getCalls();
|
||||
$this->assertCount(1, $calls);
|
||||
|
||||
$call = $calls[0];
|
||||
$this->assertSame('deleteMultiple', $call->name);
|
||||
$this->assertSame(['keys' => $arg, 'result' => true], $call->result);
|
||||
$this->assertSame(0, $call->hits);
|
||||
$this->assertSame(0, $call->misses);
|
||||
$this->assertNotEmpty($call->start);
|
||||
$this->assertNotEmpty($call->end);
|
||||
}
|
||||
|
||||
public function testTraceSetTrace()
|
||||
{
|
||||
$pool = $this->createSimpleCache();
|
||||
$pool->set('k', 'foo');
|
||||
$calls = $pool->getCalls();
|
||||
$this->assertCount(1, $calls);
|
||||
|
||||
$call = $calls[0];
|
||||
$this->assertSame('set', $call->name);
|
||||
$this->assertSame(['k' => true], $call->result);
|
||||
$this->assertSame(0, $call->hits);
|
||||
$this->assertSame(0, $call->misses);
|
||||
$this->assertNotEmpty($call->start);
|
||||
$this->assertNotEmpty($call->end);
|
||||
}
|
||||
|
||||
public function testSetMultipleTrace()
|
||||
{
|
||||
$pool = $this->createSimpleCache();
|
||||
$pool->setMultiple(['k' => 'foo']);
|
||||
$calls = $pool->getCalls();
|
||||
$this->assertCount(1, $calls);
|
||||
|
||||
$call = $calls[0];
|
||||
$this->assertSame('setMultiple', $call->name);
|
||||
$this->assertSame(['keys' => ['k'], 'result' => true], $call->result);
|
||||
$this->assertSame(0, $call->hits);
|
||||
$this->assertSame(0, $call->misses);
|
||||
$this->assertNotEmpty($call->start);
|
||||
$this->assertNotEmpty($call->end);
|
||||
}
|
||||
}
|
||||
11
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/index.php
vendored
Normal file
11
modules/inpostshipping/vendor/symfony/cache/Tests/Simple/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