Skip to content

Commit 6dbafb1

Browse files
committed
Improve missing lock_factory message when no cache_directory was provided
1 parent 3da8b49 commit 6dbafb1

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Psr6Store.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function __construct(array $options = [])
135135

136136
$resolver->setDefault('lock_factory', function (Options $options) {
137137
if (!isset($options['cache_directory'])) {
138-
throw new MissingOptionsException('The cache_directory option is required unless you set the cache explicitly');
138+
throw new MissingOptionsException('The cache_directory option is required unless you set the lock_factory explicitly as by default locks are also stored in the configured cache_directory.');
139139
}
140140

141141
return new Factory(

tests/Psr6StoreTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ protected function tearDown()
4444
$this->store->cleanup();
4545
}
4646

47+
public function testCustomCacheWithoutLockFactory()
48+
{
49+
$this->expectException(MissingOptionsException::class);
50+
$this->expectExceptionMessage('The cache_directory option is required unless you set the lock_factory explicitly as by default locks are also stored in the configured cache_directory.');
51+
52+
$cache = $this->createMock(TagAwareAdapterInterface::class);
53+
54+
new Psr6Store([
55+
'cache' => $cache,
56+
]);
57+
}
58+
4759
public function testCustomCacheAndLockFactory()
4860
{
4961
$cache = $this->createMock(TagAwareAdapterInterface::class);

0 commit comments

Comments
 (0)