diff --git a/src/Configuration/Cache/IlluminateCacheProvider.php b/src/Configuration/Cache/IlluminateCacheProvider.php index d075f347..6aafcd55 100644 --- a/src/Configuration/Cache/IlluminateCacheProvider.php +++ b/src/Configuration/Cache/IlluminateCacheProvider.php @@ -42,7 +42,7 @@ public function resolve(array $settings = []): CacheItemPoolInterface trigger_error('Using driver "' . $this->store . '" with a custom store is deprecated. Please use the "illuminate" driver.', E_USER_DEPRECATED); } - return new Psr16Adapter($this->cache->store($store)); + return new Psr16Adapter($this->cache->store($store), $settings['namespace'] ?? ''); } public function getStore(): string diff --git a/tests/Configuration/Cache/IlluminateCacheProviderTest.php b/tests/Configuration/Cache/IlluminateCacheProviderTest.php new file mode 100644 index 00000000..5b9faff7 --- /dev/null +++ b/tests/Configuration/Cache/IlluminateCacheProviderTest.php @@ -0,0 +1,64 @@ +repository = m::mock(Repository::class); + $manager = m::mock(Factory::class); + $manager->shouldReceive('store') + ->once() + ->andReturn($this->repository); + + $this->driver = new IlluminateCacheProvider($manager); + } + + public function test_driver_returns_provided_namespace(): void + { + $this->repository->shouldReceive('getMultiple') + ->withSomeOfArgs(['namespace_item']) + ->once(); + + $cache = $this->driver->resolve(['store' => 'redis', 'namespace' => 'namespace']); + $cache->getItem('item'); + + $this->assertTrue(true); + } + + public function test_driver_has_no_namespace_by_default(): void + { + $this->repository->shouldReceive('getMultiple') + ->withSomeOfArgs(['item']) + ->once(); + + $cache = $this->driver->resolve(['store' => 'redis']); + $cache->getItem('item'); + + $this->assertTrue(true); + } + + public function tearDown(): void + { + m::close(); + } +}