diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2018-12-01 17:57:53 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2018-12-01 18:56:03 +0000 |
| commit | e70f282ef978b175c5529f439f3b572c5b8531a2 (patch) | |
| tree | cc022e973d89a5507dcbb35561ef93852c551dff /vendor/symfony/cache/Tests | |
| parent | c16be598f1a8d42127bd64c4878bd92297e18f3b (diff) | |
| download | webtrees-e70f282ef978b175c5529f439f3b572c5b8531a2.tar.gz webtrees-e70f282ef978b175c5529f439f3b572c5b8531a2.tar.bz2 webtrees-e70f282ef978b175c5529f439f3b572c5b8531a2.zip | |
Update minimum version of PHP to 7.1
Diffstat (limited to 'vendor/symfony/cache/Tests')
29 files changed, 752 insertions, 60 deletions
diff --git a/vendor/symfony/cache/Tests/Adapter/AdapterTestCase.php b/vendor/symfony/cache/Tests/Adapter/AdapterTestCase.php index d3175adc77..72d143e3c0 100644 --- a/vendor/symfony/cache/Tests/Adapter/AdapterTestCase.php +++ b/vendor/symfony/cache/Tests/Adapter/AdapterTestCase.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Cache\IntegrationTests\CachePoolTest; use Psr\Cache\CacheItemPoolInterface; +use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\PruneableInterface; abstract class AdapterTestCase extends CachePoolTest @@ -21,15 +22,67 @@ abstract class AdapterTestCase extends CachePoolTest { parent::setUp(); - if (!array_key_exists('testDeferredSaveWithoutCommit', $this->skippedTests) && \defined('HHVM_VERSION')) { - $this->skippedTests['testDeferredSaveWithoutCommit'] = 'Destructors are called late on HHVM.'; - } - if (!array_key_exists('testPrune', $this->skippedTests) && !$this->createCachePool() instanceof PruneableInterface) { $this->skippedTests['testPrune'] = 'Not a pruneable cache pool.'; } } + public function testGet() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $cache = $this->createCachePool(); + + $value = mt_rand(); + + $this->assertSame($value, $cache->get('foo', function (CacheItem $item) use ($value) { + $this->assertSame('foo', $item->getKey()); + + return $value; + })); + + $item = $cache->getItem('foo'); + $this->assertSame($value, $item->get()); + + $isHit = true; + $this->assertSame($value, $cache->get('foo', function (CacheItem $item) use (&$isHit) { $isHit = false; }, 0)); + $this->assertTrue($isHit); + + $this->assertNull($cache->get('foo', function (CacheItem $item) use (&$isHit, $value) { + $isHit = false; + $this->assertTrue($item->isHit()); + $this->assertSame($value, $item->get()); + }, INF)); + $this->assertFalse($isHit); + } + + public function testGetMetadata() + { + if (isset($this->skippedTests[__FUNCTION__])) { + $this->markTestSkipped($this->skippedTests[__FUNCTION__]); + } + + $cache = $this->createCachePool(0, __FUNCTION__); + + $cache->deleteItem('foo'); + $cache->get('foo', function ($item) { + $item->expiresAfter(10); + sleep(1); + + return 'bar'; + }); + + $item = $cache->getItem('foo'); + + $expected = array( + CacheItem::METADATA_EXPIRY => 9.5 + time(), + CacheItem::METADATA_CTIME => 1000, + ); + $this->assertEquals($expected, $item->getMetadata(), 'Item metadata should embed expiry and ctime.', .6); + } + public function testDefaultLifeTime() { if (isset($this->skippedTests[__FUNCTION__])) { diff --git a/vendor/symfony/cache/Tests/Adapter/ApcuAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/ApcuAdapterTest.php index 2b3c6b4432..a17b42bce4 100644 --- a/vendor/symfony/cache/Tests/Adapter/ApcuAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/ApcuAdapterTest.php @@ -24,10 +24,10 @@ class ApcuAdapterTest extends AdapterTestCase public function createCachePool($defaultLifetime = 0) { - if (!\function_exists('apcu_fetch') || !ini_get('apc.enabled')) { + if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)) { $this->markTestSkipped('APCu extension is required.'); } - if ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli')) { + if ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) { if ('testWithCliSapi' !== $this->getName()) { $this->markTestSkipped('apc.enable_cli=1 is required.'); } diff --git a/vendor/symfony/cache/Tests/Adapter/ArrayAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/ArrayAdapterTest.php index 725d790150..7b65061cd1 100644 --- a/vendor/symfony/cache/Tests/Adapter/ArrayAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/ArrayAdapterTest.php @@ -19,6 +19,7 @@ use Symfony\Component\Cache\Adapter\ArrayAdapter; class ArrayAdapterTest extends AdapterTestCase { protected $skippedTests = array( + 'testGetMetadata' => 'ArrayAdapter does not keep metadata.', 'testDeferredSaveWithoutCommit' => 'Assumes a shared cache which ArrayAdapter is not.', 'testSaveWithoutExpire' => 'Assumes a shared cache which ArrayAdapter is not.', ); @@ -35,12 +36,12 @@ class ArrayAdapterTest extends AdapterTestCase // Hit $item = $cache->getItem('foo'); - $item->set('4711'); + $item->set('::4711'); $cache->save($item); $fooItem = $cache->getItem('foo'); $this->assertTrue($fooItem->isHit()); - $this->assertEquals('4711', $fooItem->get()); + $this->assertEquals('::4711', $fooItem->get()); // Miss (should be present as NULL in $values) $cache->getItem('bar'); @@ -49,7 +50,7 @@ class ArrayAdapterTest extends AdapterTestCase $this->assertCount(2, $values); $this->assertArrayHasKey('foo', $values); - $this->assertSame(serialize('4711'), $values['foo']); + $this->assertSame(serialize('::4711'), $values['foo']); $this->assertArrayHasKey('bar', $values); $this->assertNull($values['bar']); } diff --git a/vendor/symfony/cache/Tests/Adapter/ChainAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/ChainAdapterTest.php index a47058f513..09ba6e444c 100644 --- a/vendor/symfony/cache/Tests/Adapter/ChainAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/ChainAdapterTest.php @@ -24,8 +24,12 @@ use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter; */ class ChainAdapterTest extends AdapterTestCase { - public function createCachePool($defaultLifetime = 0) + public function createCachePool($defaultLifetime = 0, $testMethod = null) { + if ('testGetMetadata' === $testMethod) { + return new ChainAdapter(array(new FilesystemAdapter('', $defaultLifetime)), $defaultLifetime); + } + return new ChainAdapter(array(new ArrayAdapter($defaultLifetime), new ExternalAdapter(), new FilesystemAdapter('', $defaultLifetime)), $defaultLifetime); } diff --git a/vendor/symfony/cache/Tests/Adapter/MaxIdLengthAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/MaxIdLengthAdapterTest.php index 5e301f2509..7613afa7f9 100644 --- a/vendor/symfony/cache/Tests/Adapter/MaxIdLengthAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/MaxIdLengthAdapterTest.php @@ -26,7 +26,7 @@ class MaxIdLengthAdapterTest extends TestCase $cache->expects($this->exactly(2)) ->method('doHave') ->withConsecutive( - array($this->equalTo('----------:0GTYWa9n4ed8vqNlOT2iEr:')), + array($this->equalTo('----------:nWfzGiCgLczv3SSUzXL3kg:')), array($this->equalTo('----------:---------------------------------------')) ); @@ -56,7 +56,7 @@ class MaxIdLengthAdapterTest extends TestCase $reflectionProperty->setValue($cache, true); // Versioning enabled - $this->assertEquals('--------------------------:1:------------', $reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12)))); + $this->assertEquals('--------------------------:1/------------', $reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12)))); $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 12))))); $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 23))))); $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, array(str_repeat('-', 40))))); diff --git a/vendor/symfony/cache/Tests/Adapter/MemcachedAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/MemcachedAdapterTest.php index d1f8790340..85292994fe 100644 --- a/vendor/symfony/cache/Tests/Adapter/MemcachedAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/MemcachedAdapterTest.php @@ -137,7 +137,7 @@ class MemcachedAdapterTest extends AdapterTestCase 'localhost', 11222, ); - if (ini_get('memcached.use_sasl')) { + if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { yield array( 'memcached://user:password@127.0.0.1?weight=50', '127.0.0.1', @@ -154,7 +154,7 @@ class MemcachedAdapterTest extends AdapterTestCase '/var/local/run/memcached.socket', 0, ); - if (ini_get('memcached.use_sasl')) { + if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { yield array( 'memcached://user:password@/var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', @@ -192,4 +192,46 @@ class MemcachedAdapterTest extends AdapterTestCase array(\Memcached::OPT_SOCKET_RECV_SIZE => 1, \Memcached::OPT_SOCKET_SEND_SIZE => 2, \Memcached::OPT_RETRY_TIMEOUT => 8), ); } + + public function testMultiServerDsn() + { + $dsn = 'memcached:?host[localhost]&host[localhost:12345]&host[/some/memcached.sock:]=3'; + $client = MemcachedAdapter::createConnection($dsn); + + $expected = array( + 0 => array( + 'host' => 'localhost', + 'port' => 11211, + 'type' => 'TCP', + ), + 1 => array( + 'host' => 'localhost', + 'port' => 12345, + 'type' => 'TCP', + ), + 2 => array( + 'host' => '/some/memcached.sock', + 'port' => 0, + 'type' => 'SOCKET', + ), + ); + $this->assertSame($expected, $client->getServerList()); + + $dsn = 'memcached://localhost?host[foo.bar]=3'; + $client = MemcachedAdapter::createConnection($dsn); + + $expected = array( + 0 => array( + 'host' => 'localhost', + 'port' => 11211, + 'type' => 'TCP', + ), + 1 => array( + 'host' => 'foo.bar', + 'port' => 11211, + 'type' => 'TCP', + ), + ); + $this->assertSame($expected, $client->getServerList()); + } } diff --git a/vendor/symfony/cache/Tests/Adapter/NamespacedProxyAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/NamespacedProxyAdapterTest.php index c271403338..f1ffcbb823 100644 --- a/vendor/symfony/cache/Tests/Adapter/NamespacedProxyAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/NamespacedProxyAdapterTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\ArrayAdapter; +use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\ProxyAdapter; /** @@ -19,8 +20,12 @@ use Symfony\Component\Cache\Adapter\ProxyAdapter; */ class NamespacedProxyAdapterTest extends ProxyAdapterTest { - public function createCachePool($defaultLifetime = 0) + public function createCachePool($defaultLifetime = 0, $testMethod = null) { + if ('testGetMetadata' === $testMethod) { + return new ProxyAdapter(new FilesystemAdapter(), 'foo', $defaultLifetime); + } + return new ProxyAdapter(new ArrayAdapter($defaultLifetime), 'foo', $defaultLifetime); } } diff --git a/vendor/symfony/cache/Tests/Adapter/PdoDbalAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/PdoDbalAdapterTest.php index f89a27ce64..eea89b7458 100644 --- a/vendor/symfony/cache/Tests/Adapter/PdoDbalAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/PdoDbalAdapterTest.php @@ -33,7 +33,6 @@ class PdoDbalAdapterTest extends AdapterTestCase self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); $pool = new PdoAdapter(DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'path' => self::$dbFile))); - $pool->createTable(); } public static function tearDownAfterClass() diff --git a/vendor/symfony/cache/Tests/Adapter/PhpArrayAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/PhpArrayAdapterTest.php index 930594fb92..96e63e64e3 100644 --- a/vendor/symfony/cache/Tests/Adapter/PhpArrayAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/PhpArrayAdapterTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemInterface; +use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\NullAdapter; use Symfony\Component\Cache\Adapter\PhpArrayAdapter; @@ -21,6 +22,7 @@ use Symfony\Component\Cache\Adapter\PhpArrayAdapter; class PhpArrayAdapterTest extends AdapterTestCase { protected $skippedTests = array( + 'testGet' => 'PhpArrayAdapter is read-only.', 'testBasicUsage' => 'PhpArrayAdapter is read-only.', 'testBasicUsageWithLongKey' => 'PhpArrayAdapter is read-only.', 'testClear' => 'PhpArrayAdapter is read-only.', @@ -67,8 +69,12 @@ class PhpArrayAdapterTest extends AdapterTestCase } } - public function createCachePool() + public function createCachePool($defaultLifetime = 0, $testMethod = null) { + if ('testGetMetadata' === $testMethod) { + return new PhpArrayAdapter(self::$file, new FilesystemAdapter()); + } + return new PhpArrayAdapterWrapper(self::$file, new NullAdapter()); } @@ -101,16 +107,32 @@ class PhpArrayAdapterTest extends AdapterTestCase public function testStoredFile() { - $expected = array( + $data = array( 'integer' => 42, 'float' => 42.42, 'boolean' => true, 'array_simple' => array('foo', 'bar'), 'array_associative' => array('foo' => 'bar', 'foo2' => 'bar2'), ); + $expected = array( + array( + 'integer' => 0, + 'float' => 1, + 'boolean' => 2, + 'array_simple' => 3, + 'array_associative' => 4, + ), + array( + 0 => 42, + 1 => 42.42, + 2 => true, + 3 => array('foo', 'bar'), + 4 => array('foo' => 'bar', 'foo2' => 'bar2'), + ), + ); $adapter = $this->createCachePool(); - $adapter->warmUp($expected); + $adapter->warmUp($data); $values = eval(substr(file_get_contents(self::$file), 6)); @@ -120,12 +142,16 @@ class PhpArrayAdapterTest extends AdapterTestCase class PhpArrayAdapterWrapper extends PhpArrayAdapter { + protected $data = array(); + public function save(CacheItemInterface $item) { \call_user_func(\Closure::bind(function () use ($item) { - $this->values[$item->getKey()] = $item->get(); - $this->warmUp($this->values); - $this->values = eval(substr(file_get_contents($this->file), 6)); + $key = $item->getKey(); + $this->keys[$key] = $id = \count($this->values); + $this->data[$key] = $this->values[$id] = $item->get(); + $this->warmUp($this->data); + list($this->keys, $this->values) = eval(substr(file_get_contents($this->file), 6)); }, $this, PhpArrayAdapter::class)); return true; diff --git a/vendor/symfony/cache/Tests/Adapter/PhpFilesAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/PhpFilesAdapterTest.php index 8e93c937f6..9fecd9724b 100644 --- a/vendor/symfony/cache/Tests/Adapter/PhpFilesAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/PhpFilesAdapterTest.php @@ -25,10 +25,6 @@ class PhpFilesAdapterTest extends AdapterTestCase public function createCachePool() { - if (!PhpFilesAdapter::isSupported()) { - $this->markTestSkipped('OPcache extension is not enabled.'); - } - return new PhpFilesAdapter('sf-cache'); } diff --git a/vendor/symfony/cache/Tests/Adapter/PredisAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/PredisAdapterTest.php index c005d64abf..c65515b54d 100644 --- a/vendor/symfony/cache/Tests/Adapter/PredisAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/PredisAdapterTest.php @@ -34,19 +34,13 @@ class PredisAdapterTest extends AbstractRedisAdapterTest $params = array( 'scheme' => 'tcp', - 'host' => $redisHost, - 'path' => '', - 'dbindex' => '1', + 'host' => 'localhost', 'port' => 6379, - 'class' => 'Predis\Client', - 'timeout' => 3, 'persistent' => 0, - 'persistent_id' => null, - 'read_timeout' => 0, - 'retry_interval' => 0, - 'lazy' => false, + 'timeout' => 3, + 'read_write_timeout' => 0, + 'tcp_nodelay' => true, 'database' => '1', - 'password' => null, ); $this->assertSame($params, $connection->getParameters()->toArray()); } diff --git a/vendor/symfony/cache/Tests/Adapter/PredisRedisClusterAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/PredisRedisClusterAdapterTest.php new file mode 100644 index 0000000000..9974e93635 --- /dev/null +++ b/vendor/symfony/cache/Tests/Adapter/PredisRedisClusterAdapterTest.php @@ -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\Adapter; + +use Symfony\Component\Cache\Adapter\RedisAdapter; + +class PredisRedisClusterAdapterTest extends AbstractRedisAdapterTest +{ + public static function setupBeforeClass() + { + if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { + self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); + } + + self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']', array('class' => \Predis\Client::class, 'redis_cluster' => true)); + } + + public static function tearDownAfterClass() + { + self::$redis = null; + } +} diff --git a/vendor/symfony/cache/Tests/Adapter/ProxyAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/ProxyAdapterTest.php index ff4b9d34bc..fbbdac22a8 100644 --- a/vendor/symfony/cache/Tests/Adapter/ProxyAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/ProxyAdapterTest.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; +use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\ProxyAdapter; use Symfony\Component\Cache\CacheItem; @@ -27,8 +28,12 @@ class ProxyAdapterTest extends AdapterTestCase 'testPrune' => 'ProxyAdapter just proxies', ); - public function createCachePool($defaultLifetime = 0) + public function createCachePool($defaultLifetime = 0, $testMethod = null) { + if ('testGetMetadata' === $testMethod) { + return new ProxyAdapter(new FilesystemAdapter(), '', $defaultLifetime); + } + return new ProxyAdapter(new ArrayAdapter(), '', $defaultLifetime); } diff --git a/vendor/symfony/cache/Tests/Adapter/RedisAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/RedisAdapterTest.php index 28c310fb18..5208df67cb 100644 --- a/vendor/symfony/cache/Tests/Adapter/RedisAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/RedisAdapterTest.php @@ -33,6 +33,11 @@ class RedisAdapterTest extends AbstractRedisAdapterTest public function testCreateConnection() { + $redis = RedisAdapter::createConnection('redis:?host[h1]&host[h2]&host[/foo:]'); + $this->assertInstanceOf(\RedisArray::class, $redis); + $this->assertSame(array('h1:6379', 'h2:6379', '/foo'), $redis->_hosts()); + @$redis = null; // some versions of phpredis connect on destruct, let's silence the warning + $redisHost = getenv('REDIS_HOST'); $redis = RedisAdapter::createConnection('redis://'.$redisHost); diff --git a/vendor/symfony/cache/Tests/Adapter/RedisClusterAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/RedisClusterAdapterTest.php index 852079c00c..344f1d0743 100644 --- a/vendor/symfony/cache/Tests/Adapter/RedisClusterAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/RedisClusterAdapterTest.php @@ -11,6 +11,10 @@ namespace Symfony\Component\Cache\Tests\Adapter; +use Symfony\Component\Cache\Adapter\AbstractAdapter; +use Symfony\Component\Cache\Adapter\RedisAdapter; +use Symfony\Component\Cache\Traits\RedisClusterProxy; + class RedisClusterAdapterTest extends AbstractRedisAdapterTest { public static function setupBeforeClass() @@ -22,6 +26,33 @@ class RedisClusterAdapterTest extends AbstractRedisAdapterTest self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); } - self::$redis = new \RedisCluster(null, explode(' ', $hosts)); + self::$redis = AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']', array('lazy' => true, 'redis_cluster' => true)); + } + + public function createCachePool($defaultLifetime = 0) + { + $this->assertInstanceOf(RedisClusterProxy::class, self::$redis); + $adapter = new RedisAdapter(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime); + + return $adapter; + } + + /** + * @dataProvider provideFailedCreateConnection + * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException + * @expectedExceptionMessage Redis connection failed + */ + public function testFailedCreateConnection($dsn) + { + RedisAdapter::createConnection($dsn); + } + + public function provideFailedCreateConnection() + { + return array( + array('redis://localhost:1234?redis_cluster=1'), + array('redis://foo@localhost?redis_cluster=1'), + array('redis://localhost/123?redis_cluster=1'), + ); } } diff --git a/vendor/symfony/cache/Tests/Adapter/TagAwareAdapterTest.php b/vendor/symfony/cache/Tests/Adapter/TagAwareAdapterTest.php index 7074299e7a..ad37fbef7d 100644 --- a/vendor/symfony/cache/Tests/Adapter/TagAwareAdapterTest.php +++ b/vendor/symfony/cache/Tests/Adapter/TagAwareAdapterTest.php @@ -14,6 +14,7 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\AdapterInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\TagAwareAdapter; +use Symfony\Component\Cache\CacheItem; /** * @group time-sensitive @@ -138,6 +139,9 @@ class TagAwareAdapterTest extends AdapterTestCase $this->assertFalse($pool->getItem('foo')->isHit()); } + /** + * @group legacy + */ public function testGetPreviousTags() { $pool = $this->createCachePool(); @@ -149,6 +153,17 @@ class TagAwareAdapterTest extends AdapterTestCase $this->assertSame(array('foo' => 'foo'), $i->getPreviousTags()); } + public function testGetMetadata() + { + $pool = $this->createCachePool(); + + $i = $pool->getItem('k'); + $pool->save($i->tag('foo')); + + $i = $pool->getItem('k'); + $this->assertSame(array('foo' => 'foo'), $i->getMetadata()[CacheItem::METADATA_TAGS]); + } + public function testPrune() { $cache = new TagAwareAdapter($this->getPruneableMock()); diff --git a/vendor/symfony/cache/Tests/CacheItemTest.php b/vendor/symfony/cache/Tests/CacheItemTest.php index 4aae16b63c..6049f3ec9b 100644 --- a/vendor/symfony/cache/Tests/CacheItemTest.php +++ b/vendor/symfony/cache/Tests/CacheItemTest.php @@ -55,12 +55,15 @@ class CacheItemTest extends TestCase public function testTag() { $item = new CacheItem(); + $r = new \ReflectionProperty($item, 'isTaggable'); + $r->setAccessible(true); + $r->setValue($item, true); $this->assertSame($item, $item->tag('foo')); $this->assertSame($item, $item->tag(array('bar', 'baz'))); \call_user_func(\Closure::bind(function () use ($item) { - $this->assertSame(array('foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'), $item->tags); + $this->assertSame(array('foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'), $item->newMetadata[CacheItem::METADATA_TAGS]); }, $this, CacheItem::class)); } @@ -72,6 +75,24 @@ class CacheItemTest extends TestCase public function testInvalidTag($tag) { $item = new CacheItem(); + $r = new \ReflectionProperty($item, 'isTaggable'); + $r->setAccessible(true); + $r->setValue($item, true); + $item->tag($tag); } + + /** + * @expectedException \Symfony\Component\Cache\Exception\LogicException + * @expectedExceptionMessage Cache item "foo" comes from a non tag-aware pool: you cannot tag it. + */ + public function testNonTaggableItem() + { + $item = new CacheItem(); + $r = new \ReflectionProperty($item, 'key'); + $r->setAccessible(true); + $r->setValue($item, 'foo'); + + $item->tag(array()); + } } diff --git a/vendor/symfony/cache/Tests/DependencyInjection/CacheCollectorPassTest.php b/vendor/symfony/cache/Tests/DependencyInjection/CacheCollectorPassTest.php new file mode 100644 index 0000000000..421f5764de --- /dev/null +++ b/vendor/symfony/cache/Tests/DependencyInjection/CacheCollectorPassTest.php @@ -0,0 +1,49 @@ +<?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\DependencyInjection; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Cache\Adapter\FilesystemAdapter; +use Symfony\Component\Cache\Adapter\TagAwareAdapter; +use Symfony\Component\Cache\Adapter\TraceableAdapter; +use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter; +use Symfony\Component\Cache\DataCollector\CacheDataCollector; +use Symfony\Component\Cache\DependencyInjection\CacheCollectorPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +class CacheCollectorPassTest extends TestCase +{ + public function testProcess() + { + $container = new ContainerBuilder(); + $container + ->register('fs', FilesystemAdapter::class) + ->addTag('cache.pool'); + $container + ->register('tagged_fs', TagAwareAdapter::class) + ->addArgument(new Reference('fs')) + ->addTag('cache.pool'); + + $collector = $container->register('data_collector.cache', CacheDataCollector::class); + (new CacheCollectorPass())->process($container); + + $this->assertEquals(array( + array('addInstance', array('fs', new Reference('fs'))), + array('addInstance', array('tagged_fs', new Reference('tagged_fs'))), + ), $collector->getMethodCalls()); + + $this->assertSame(TraceableAdapter::class, $container->findDefinition('fs')->getClass()); + $this->assertSame(TraceableTagAwareAdapter::class, $container->getDefinition('tagged_fs')->getClass()); + $this->assertFalse($collector->isPublic(), 'The "data_collector.cache" should be private after processing'); + } +} diff --git a/vendor/symfony/cache/Tests/DependencyInjection/CachePoolClearerPassTest.php b/vendor/symfony/cache/Tests/DependencyInjection/CachePoolClearerPassTest.php new file mode 100644 index 0000000000..6aa68c29cd --- /dev/null +++ b/vendor/symfony/cache/Tests/DependencyInjection/CachePoolClearerPassTest.php @@ -0,0 +1,73 @@ +<?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\DependencyInjection; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Cache\DependencyInjection\CachePoolClearerPass; +use Symfony\Component\Cache\DependencyInjection\CachePoolPass; +use Symfony\Component\DependencyInjection\Compiler\RemoveUnusedDefinitionsPass; +use Symfony\Component\DependencyInjection\Compiler\RepeatedPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer; + +class CachePoolClearerPassTest extends TestCase +{ + public function testPoolRefsAreWeak() + { + $container = new ContainerBuilder(); + $container->setParameter('kernel.container_class', 'app'); + $container->setParameter('kernel.project_dir', 'foo'); + + $globalClearer = new Definition(Psr6CacheClearer::class); + $container->setDefinition('cache.global_clearer', $globalClearer); + + $publicPool = new Definition(); + $publicPool->addArgument('namespace'); + $publicPool->addTag('cache.pool', array('clearer' => 'clearer_alias')); + $container->setDefinition('public.pool', $publicPool); + + $publicPool = new Definition(); + $publicPool->addArgument('namespace'); + $publicPool->addTag('cache.pool', array('clearer' => 'clearer_alias', 'name' => 'pool2')); + $container->setDefinition('public.pool2', $publicPool); + + $privatePool = new Definition(); + $privatePool->setPublic(false); + $privatePool->addArgument('namespace'); + $privatePool->addTag('cache.pool', array('clearer' => 'clearer_alias')); + $container->setDefinition('private.pool', $privatePool); + + $clearer = new Definition(); + $container->setDefinition('clearer', $clearer); + $container->setAlias('clearer_alias', 'clearer'); + + $pass = new RemoveUnusedDefinitionsPass(); + foreach ($container->getCompiler()->getPassConfig()->getRemovingPasses() as $removingPass) { + if ($removingPass instanceof RepeatedPass) { + $pass->setRepeatedPass(new RepeatedPass(array($pass))); + break; + } + } + foreach (array(new CachePoolPass(), $pass, new CachePoolClearerPass()) as $pass) { + $pass->process($container); + } + + $expected = array(array( + 'public.pool' => new Reference('public.pool'), + 'pool2' => new Reference('public.pool2'), + )); + $this->assertEquals($expected, $clearer->getArguments()); + $this->assertEquals($expected, $globalClearer->getArguments()); + } +} diff --git a/vendor/symfony/cache/Tests/DependencyInjection/CachePoolPassTest.php b/vendor/symfony/cache/Tests/DependencyInjection/CachePoolPassTest.php new file mode 100644 index 0000000000..f757e79821 --- /dev/null +++ b/vendor/symfony/cache/Tests/DependencyInjection/CachePoolPassTest.php @@ -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\Cache\Tests\DependencyInjection; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Cache\Adapter\ArrayAdapter; +use Symfony\Component\Cache\DependencyInjection\CachePoolPass; +use Symfony\Component\DependencyInjection\ChildDefinition; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Reference; + +class CachePoolPassTest extends TestCase +{ + private $cachePoolPass; + + protected function setUp() + { + $this->cachePoolPass = new CachePoolPass(); + } + + public function testNamespaceArgumentIsReplaced() + { + $container = new ContainerBuilder(); + $container->setParameter('kernel.container_class', 'app'); + $container->setParameter('kernel.project_dir', 'foo'); + $adapter = new Definition(); + $adapter->setAbstract(true); + $adapter->addTag('cache.pool'); + $container->setDefinition('app.cache_adapter', $adapter); + $container->setAlias('app.cache_adapter_alias', 'app.cache_adapter'); + $cachePool = new ChildDefinition('app.cache_adapter_alias'); + $cachePool->addArgument(null); + $cachePool->addTag('cache.pool'); + $container->setDefinition('app.cache_pool', $cachePool); + + $this->cachePoolPass->process($container); + + $this->assertSame('z3X945Jbf5', $cachePool->getArgument(0)); + } + + public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed() + { + $container = new ContainerBuilder(); + $container->setParameter('kernel.container_class', 'app'); + $container->setParameter('kernel.project_dir', 'foo'); + + $container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0); + + $cachePool = new ChildDefinition('cache.adapter.array'); + $cachePool->addTag('cache.pool'); + $container->setDefinition('app.cache_pool', $cachePool); + + $this->cachePoolPass->process($container); + + $this->assertCount(0, $container->getDefinition('app.cache_pool')->getArguments()); + } + + public function testArgsAreReplaced() + { + $container = new ContainerBuilder(); + $container->setParameter('kernel.container_class', 'app'); + $container->setParameter('cache.prefix.seed', 'foo'); + $cachePool = new Definition(); + $cachePool->addTag('cache.pool', array( + 'provider' => 'foobar', + 'default_lifetime' => 3, + )); + $cachePool->addArgument(null); + $cachePool->addArgument(null); + $cachePool->addArgument(null); + $container->setDefinition('app.cache_pool', $cachePool); + + $this->cachePoolPass->process($container); + + $this->assertInstanceOf(Reference::class, $cachePool->getArgument(0)); + $this->assertSame('foobar', (string) $cachePool->getArgument(0)); + $this->assertSame('tQNhcV-8xa', $cachePool->getArgument(1)); + $this->assertSame(3, $cachePool->getArgument(2)); + } + + public function testWithNameAttribute() + { + $container = new ContainerBuilder(); + $container->setParameter('kernel.container_class', 'app'); + $container->setParameter('cache.prefix.seed', 'foo'); + $cachePool = new Definition(); + $cachePool->addTag('cache.pool', array( + 'name' => 'foobar', + 'provider' => 'foobar', + )); + $cachePool->addArgument(null); + $cachePool->addArgument(null); + $cachePool->addArgument(null); + $container->setDefinition('app.cache_pool', $cachePool); + + $this->cachePoolPass->process($container); + + $this->assertSame('+naTpPa4Sm', $cachePool->getArgument(1)); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Invalid "cache.pool" tag for service "app.cache_pool": accepted attributes are + */ + public function testThrowsExceptionWhenCachePoolTagHasUnknownAttributes() + { + $container = new ContainerBuilder(); + $container->setParameter('kernel.container_class', 'app'); + $container->setParameter('kernel.project_dir', 'foo'); + $adapter = new Definition(); + $adapter->setAbstract(true); + $adapter->addTag('cache.pool'); + $container->setDefinition('app.cache_adapter', $adapter); + $cachePool = new ChildDefinition('app.cache_adapter'); + $cachePool->addTag('cache.pool', array('foobar' => 123)); + $container->setDefinition('app.cache_pool', $cachePool); + + $this->cachePoolPass->process($container); + } +} diff --git a/vendor/symfony/cache/Tests/DependencyInjection/CachePoolPrunerPassTest.php b/vendor/symfony/cache/Tests/DependencyInjection/CachePoolPrunerPassTest.php new file mode 100644 index 0000000000..e4de6f6807 --- /dev/null +++ b/vendor/symfony/cache/Tests/DependencyInjection/CachePoolPrunerPassTest.php @@ -0,0 +1,72 @@ +<?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\DependencyInjection; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Cache\Adapter\FilesystemAdapter; +use Symfony\Component\Cache\Adapter\PhpFilesAdapter; +use Symfony\Component\Cache\DependencyInjection\CachePoolPrunerPass; +use Symfony\Component\DependencyInjection\Argument\IteratorArgument; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +class CachePoolPrunerPassTest extends TestCase +{ + public function testCompilerPassReplacesCommandArgument() + { + $container = new ContainerBuilder(); + $container->register('console.command.cache_pool_prune')->addArgument(array()); + $container->register('pool.foo', FilesystemAdapter::class)->addTag('cache.pool'); + $container->register('pool.bar', PhpFilesAdapter::class)->addTag('cache.pool'); + + $pass = new CachePoolPrunerPass(); + $pass->process($container); + + $expected = array( + 'pool.foo' => new Reference('pool.foo'), + 'pool.bar' => new Reference('pool.bar'), + ); + $argument = $container->getDefinition('console.command.cache_pool_prune')->getArgument(0); + + $this->assertInstanceOf(IteratorArgument::class, $argument); + $this->assertEquals($expected, $argument->getValues()); + } + + public function testCompilePassIsIgnoredIfCommandDoesNotExist() + { + $container = new ContainerBuilder(); + + $definitionsBefore = \count($container->getDefinitions()); + $aliasesBefore = \count($container->getAliases()); + + $pass = new CachePoolPrunerPass(); + $pass->process($container); + + // the container is untouched (i.e. no new definitions or aliases) + $this->assertCount($definitionsBefore, $container->getDefinitions()); + $this->assertCount($aliasesBefore, $container->getAliases()); + } + + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException + * @expectedExceptionMessage Class "Symfony\Component\Cache\Tests\DependencyInjection\NotFound" used for service "pool.not-found" cannot be found. + */ + public function testCompilerPassThrowsOnInvalidDefinitionClass() + { + $container = new ContainerBuilder(); + $container->register('console.command.cache_pool_prune')->addArgument(array()); + $container->register('pool.not-found', NotFound::class)->addTag('cache.pool'); + + $pass = new CachePoolPrunerPass(); + $pass->process($container); + } +} diff --git a/vendor/symfony/cache/Tests/Fixtures/ArrayCache.php b/vendor/symfony/cache/Tests/Fixtures/ArrayCache.php index 7cdcafd8e5..27fb82de01 100644 --- a/vendor/symfony/cache/Tests/Fixtures/ArrayCache.php +++ b/vendor/symfony/cache/Tests/Fixtures/ArrayCache.php @@ -21,12 +21,12 @@ class ArrayCache extends CacheProvider $expiry = $this->data[$id][1]; - return !$expiry || time() < $expiry || !$this->doDelete($id); + return !$expiry || microtime(true) < $expiry || !$this->doDelete($id); } protected function doSave($id, $data, $lifeTime = 0) { - $this->data[$id] = array($data, $lifeTime ? time() + $lifeTime : false); + $this->data[$id] = array($data, $lifeTime ? microtime(true) + $lifeTime : false); return true; } diff --git a/vendor/symfony/cache/Tests/LockRegistryTest.php b/vendor/symfony/cache/Tests/LockRegistryTest.php new file mode 100644 index 0000000000..3f7d959570 --- /dev/null +++ b/vendor/symfony/cache/Tests/LockRegistryTest.php @@ -0,0 +1,26 @@ +<?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; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Cache\LockRegistry; + +class LockRegistryTest extends TestCase +{ + public function testFiles() + { + $lockFiles = LockRegistry::setFiles(array()); + LockRegistry::setFiles($lockFiles); + $expected = array_map('realpath', glob(__DIR__.'/../Adapter/*')); + $this->assertSame($expected, $lockFiles); + } +} diff --git a/vendor/symfony/cache/Tests/Marshaller/DefaultMarshallerTest.php b/vendor/symfony/cache/Tests/Marshaller/DefaultMarshallerTest.php new file mode 100644 index 0000000000..fc625d12fc --- /dev/null +++ b/vendor/symfony/cache/Tests/Marshaller/DefaultMarshallerTest.php @@ -0,0 +1,104 @@ +<?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\Marshaller; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Cache\Marshaller\DefaultMarshaller; + +class DefaultMarshallerTest extends TestCase +{ + public function testSerialize() + { + $marshaller = new DefaultMarshaller(); + $values = array( + 'a' => 123, + 'b' => function () {}, + ); + + $expected = array('a' => \extension_loaded('igbinary') ? igbinary_serialize(123) : serialize(123)); + $this->assertSame($expected, $marshaller->marshall($values, $failed)); + $this->assertSame(array('b'), $failed); + } + + public function testNativeUnserialize() + { + $marshaller = new DefaultMarshaller(); + $this->assertNull($marshaller->unmarshall(serialize(null))); + $this->assertFalse($marshaller->unmarshall(serialize(false))); + $this->assertSame('', $marshaller->unmarshall(serialize(''))); + $this->assertSame(0, $marshaller->unmarshall(serialize(0))); + } + + /** + * @requires extension igbinary + */ + public function testIgbinaryUnserialize() + { + $marshaller = new DefaultMarshaller(); + $this->assertNull($marshaller->unmarshall(igbinary_serialize(null))); + $this->assertFalse($marshaller->unmarshall(igbinary_serialize(false))); + $this->assertSame('', $marshaller->unmarshall(igbinary_serialize(''))); + $this->assertSame(0, $marshaller->unmarshall(igbinary_serialize(0))); + } + + /** + * @expectedException \DomainException + * @expectedExceptionMessage Class not found: NotExistingClass + */ + public function testNativeUnserializeNotFoundClass() + { + $marshaller = new DefaultMarshaller(); + $marshaller->unmarshall('O:16:"NotExistingClass":0:{}'); + } + + /** + * @requires extension igbinary + * @expectedException \DomainException + * @expectedExceptionMessage Class not found: NotExistingClass + */ + public function testIgbinaryUnserializeNotFoundClass() + { + $marshaller = new DefaultMarshaller(); + $marshaller->unmarshall(rawurldecode('%00%00%00%02%17%10NotExistingClass%14%00')); + } + + /** + * @expectedException \DomainException + * @expectedExceptionMessage unserialize(): Error at offset 0 of 3 bytes + */ + public function testNativeUnserializeInvalid() + { + $marshaller = new DefaultMarshaller(); + set_error_handler(function () { return false; }); + try { + @$marshaller->unmarshall(':::'); + } finally { + restore_error_handler(); + } + } + + /** + * @requires extension igbinary + * @expectedException \DomainException + * @expectedExceptionMessage igbinary_unserialize_zval: unknown type '61', position 5 + */ + public function testIgbinaryUnserializeInvalid() + { + $marshaller = new DefaultMarshaller(); + set_error_handler(function () { return false; }); + try { + @$marshaller->unmarshall(rawurldecode('%00%00%00%02abc')); + } finally { + restore_error_handler(); + } + } +} diff --git a/vendor/symfony/cache/Tests/Simple/ApcuCacheTest.php b/vendor/symfony/cache/Tests/Simple/ApcuCacheTest.php index 737ed4e99d..3df32c1c5e 100644 --- a/vendor/symfony/cache/Tests/Simple/ApcuCacheTest.php +++ b/vendor/symfony/cache/Tests/Simple/ApcuCacheTest.php @@ -23,7 +23,7 @@ class ApcuCacheTest extends CacheTestCase public function createSimpleCache($defaultLifetime = 0) { - if (!\function_exists('apcu_fetch') || !ini_get('apc.enabled') || ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli'))) { + 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) { diff --git a/vendor/symfony/cache/Tests/Simple/CacheTestCase.php b/vendor/symfony/cache/Tests/Simple/CacheTestCase.php index d0d8573598..5b84d8b093 100644 --- a/vendor/symfony/cache/Tests/Simple/CacheTestCase.php +++ b/vendor/symfony/cache/Tests/Simple/CacheTestCase.php @@ -28,10 +28,6 @@ abstract class CacheTestCase extends SimpleCacheTest public static function validKeys() { - if (\defined('HHVM_VERSION')) { - return parent::validKeys(); - } - return array_merge(parent::validKeys(), array(array("a\0b"))); } diff --git a/vendor/symfony/cache/Tests/Simple/MemcachedCacheTest.php b/vendor/symfony/cache/Tests/Simple/MemcachedCacheTest.php index b46d7e443d..ee9e49d3dd 100644 --- a/vendor/symfony/cache/Tests/Simple/MemcachedCacheTest.php +++ b/vendor/symfony/cache/Tests/Simple/MemcachedCacheTest.php @@ -146,7 +146,7 @@ class MemcachedCacheTest extends CacheTestCase 'localhost', 11222, ); - if (ini_get('memcached.use_sasl')) { + if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { yield array( 'memcached://user:password@127.0.0.1?weight=50', '127.0.0.1', @@ -163,7 +163,7 @@ class MemcachedCacheTest extends CacheTestCase '/var/local/run/memcached.socket', 0, ); - if (ini_get('memcached.use_sasl')) { + if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { yield array( 'memcached://user:password@/var/local/run/memcached.socket?weight=25', '/var/local/run/memcached.socket', diff --git a/vendor/symfony/cache/Tests/Simple/PhpArrayCacheTest.php b/vendor/symfony/cache/Tests/Simple/PhpArrayCacheTest.php index b4862c61bd..e0c7285802 100644 --- a/vendor/symfony/cache/Tests/Simple/PhpArrayCacheTest.php +++ b/vendor/symfony/cache/Tests/Simple/PhpArrayCacheTest.php @@ -95,16 +95,32 @@ class PhpArrayCacheTest extends CacheTestCase public function testStoredFile() { - $expected = array( + $data = array( 'integer' => 42, 'float' => 42.42, 'boolean' => true, 'array_simple' => array('foo', 'bar'), 'array_associative' => array('foo' => 'bar', 'foo2' => 'bar2'), ); + $expected = array( + array( + 'integer' => 0, + 'float' => 1, + 'boolean' => 2, + 'array_simple' => 3, + 'array_associative' => 4, + ), + array( + 0 => 42, + 1 => 42.42, + 2 => true, + 3 => array('foo', 'bar'), + 4 => array('foo' => 'bar', 'foo2' => 'bar2'), + ), + ); $cache = new PhpArrayCache(self::$file, new NullCache()); - $cache->warmUp($expected); + $cache->warmUp($data); $values = eval(substr(file_get_contents(self::$file), 6)); @@ -114,12 +130,14 @@ class PhpArrayCacheTest extends CacheTestCase class PhpArrayCacheWrapper extends PhpArrayCache { + protected $data = array(); + 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->data[$key] = $value; + $this->warmUp($this->data); + list($this->keys, $this->values) = eval(substr(file_get_contents($this->file), 6)); }, $this, PhpArrayCache::class)); return true; @@ -132,10 +150,10 @@ class PhpArrayCacheWrapper extends PhpArrayCache } \call_user_func(\Closure::bind(function () use ($values) { foreach ($values as $key => $value) { - $this->values[$key] = $value; + $this->data[$key] = $value; } - $this->warmUp($this->values); - $this->values = eval(substr(file_get_contents($this->file), 6)); + $this->warmUp($this->data); + list($this->keys, $this->values) = eval(substr(file_get_contents($this->file), 6)); }, $this, PhpArrayCache::class)); return true; diff --git a/vendor/symfony/cache/Tests/Simple/PhpFilesCacheTest.php b/vendor/symfony/cache/Tests/Simple/PhpFilesCacheTest.php index 7a402682ae..38e5ee90b1 100644 --- a/vendor/symfony/cache/Tests/Simple/PhpFilesCacheTest.php +++ b/vendor/symfony/cache/Tests/Simple/PhpFilesCacheTest.php @@ -25,10 +25,6 @@ class PhpFilesCacheTest extends CacheTestCase public function createSimpleCache() { - if (!PhpFilesCache::isSupported()) { - $this->markTestSkipped('OPcache extension is not enabled.'); - } - return new PhpFilesCache('sf-cache'); } |
