diff --git a/src/Symfony/Component/Cache/Simple/Psr6Cache.php b/src/Symfony/Component/Cache/Simple/Psr6Cache.php index 29c039f2c169d..fceb9ba70fd80 100644 --- a/src/Symfony/Component/Cache/Simple/Psr6Cache.php +++ b/src/Symfony/Component/Cache/Simple/Psr6Cache.php @@ -154,7 +154,7 @@ public function getMultiple($keys, $default = null) $values[$key] = $item->isHit() ? $item->get() : $default; } - return $value; + return $values; } foreach ($items as $key => $item) { diff --git a/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php b/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php index 779a374ec7ab8..deb0b3bc3402a 100644 --- a/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php +++ b/src/Symfony/Component/Cache/Tests/Fixtures/ExternalAdapter.php @@ -24,9 +24,9 @@ class ExternalAdapter implements CacheItemPoolInterface { private $cache; - public function __construct() + public function __construct(int $defaultLifetime = 0) { - $this->cache = new ArrayAdapter(); + $this->cache = new ArrayAdapter($defaultLifetime); } public function getItem($key) diff --git a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php index 1bc75c906035e..65d48a978c503 100644 --- a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php +++ b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php @@ -11,13 +11,9 @@ 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 +abstract class Psr6CacheTest extends CacheTestCase { protected $skippedTests = [ 'testPrune' => 'Psr6Cache just proxies', @@ -25,6 +21,8 @@ class Psr6CacheTest extends CacheTestCase public function createSimpleCache($defaultLifetime = 0) { - return new Psr6Cache(new FilesystemAdapter('', $defaultLifetime)); + return new Psr6Cache($this->createCacheItemPool($defaultLifetime)); } + + abstract protected function createCacheItemPool($defaultLifetime = 0); } diff --git a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithAdapterTest.php b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithAdapterTest.php new file mode 100644 index 0000000000000..46da9354d6db5 --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithAdapterTest.php @@ -0,0 +1,25 @@ + + * + * 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; + +/** + * @group time-sensitive + */ +class Psr6CacheWithAdapterTest extends Psr6CacheTest +{ + protected function createCacheItemPool($defaultLifetime = 0) + { + return new FilesystemAdapter('', $defaultLifetime); + } +} diff --git a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithoutAdapterTest.php b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithoutAdapterTest.php new file mode 100644 index 0000000000000..a8c4164dcbb1d --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithoutAdapterTest.php @@ -0,0 +1,25 @@ + + * + * 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\Tests\Fixtures\ExternalAdapter; + +/** + * @group time-sensitive + */ +class Psr6CacheWithoutAdapterTest extends Psr6CacheTest +{ + protected function createCacheItemPool($defaultLifetime = 0) + { + return new ExternalAdapter($defaultLifetime); + } +}