File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 18
18
use DateInterval ;
19
19
use FilesystemIterator ;
20
20
use Generator ;
21
+ use InvalidArgumentException ;
21
22
use Psr \SimpleCache \CacheInterface ;
22
23
use Traversable ;
23
24
use function chmod ;
@@ -88,6 +89,10 @@ public function __construct(string $cache_path = '')
88
89
$ this ->mkdir ($ cache_path ); // ensure that the parent path exists
89
90
}
90
91
92
+ if (! is_writable ($ cache_path .DIRECTORY_SEPARATOR )) {
93
+ throw new InvalidArgumentException (sprintf ('cache path does not exist or is not writable: %s ' , $ cache_path ));
94
+ }
95
+
91
96
$ this ->cache_path = $ cache_path ;
92
97
}
93
98
Original file line number Diff line number Diff line change @@ -69,8 +69,14 @@ public function testConstructorOnParentCachePathIsNotExisted()
69
69
70
70
public function testSetOnNotWritableCachePath ()
71
71
{
72
+ self ::expectException (\InvalidArgumentException::class);
72
73
$ cache = new Cache ('/bin ' );
73
- self ::assertFalse ($ cache ->set ('key ' , 'value ' ));
74
+ }
75
+
76
+ public function testSetOnNotExistingCachePath ()
77
+ {
78
+ self ::expectException (\InvalidArgumentException::class);
79
+ $ cache = new Cache ('/foo/bar ' );
74
80
}
75
81
76
82
/**
You can’t perform that action at this time.
0 commit comments