@@ -26,13 +26,13 @@ protected function setUp(): void
2626 {
2727 parent ::setUp ();
2828
29- //Initialize path
30- $ this ->config = new \Config \Cache ();
31- $ this ->config ->storePath .= self ::$ directory ;
29+ // Initialize path
30+ $ this ->config = new \Config \Cache ();
31+ $ this ->config ->file [ ' storePath ' ] .= self ::$ directory ;
3232
33- if (! is_dir ($ this ->config ->storePath ))
33+ if (! is_dir ($ this ->config ->file [ ' storePath ' ] ))
3434 {
35- mkdir ($ this ->config ->storePath , 0777 , true );
35+ mkdir ($ this ->config ->file [ ' storePath ' ] , 0777 , true );
3636 }
3737
3838 $ this ->fileHandler = new FileHandler ($ this ->config );
@@ -41,20 +41,20 @@ protected function setUp(): void
4141
4242 public function tearDown (): void
4343 {
44- if (is_dir ($ this ->config ->storePath ))
44+ if (is_dir ($ this ->config ->file [ ' storePath ' ] ))
4545 {
46- chmod ($ this ->config ->storePath , 0777 );
46+ chmod ($ this ->config ->file [ ' storePath ' ] , 0777 );
4747
4848 foreach (self ::getKeyArray () as $ key )
4949 {
50- if (is_file ($ this ->config ->storePath . DIRECTORY_SEPARATOR . $ key ))
50+ if (is_file ($ this ->config ->file [ ' storePath ' ] . DIRECTORY_SEPARATOR . $ key ))
5151 {
52- chmod ($ this ->config ->storePath . DIRECTORY_SEPARATOR . $ key , 0777 );
53- unlink ($ this ->config ->storePath . DIRECTORY_SEPARATOR . $ key );
52+ chmod ($ this ->config ->file [ ' storePath ' ] . DIRECTORY_SEPARATOR . $ key , 0777 );
53+ unlink ($ this ->config ->file [ ' storePath ' ] . DIRECTORY_SEPARATOR . $ key );
5454 }
5555 }
5656
57- rmdir ($ this ->config ->storePath );
57+ rmdir ($ this ->config ->file [ ' storePath ' ] );
5858 }
5959 }
6060
@@ -67,15 +67,15 @@ public function testNewWithNonWritablePath()
6767 {
6868 $ this ->expectException ('CodeIgniter\Cache\Exceptions\CacheException ' );
6969
70- chmod ($ this ->config ->storePath , 0444 );
70+ chmod ($ this ->config ->file [ ' storePath ' ] , 0444 );
7171 new FileHandler ($ this ->config );
7272 }
7373
7474 public function testSetDefaultPath ()
7575 {
76- //Initialize path
77- $ config = new \Config \Cache ();
78- $ config ->storePath = null ;
76+ // Initialize path
77+ $ config = new \Config \Cache ();
78+ $ config ->file [ ' storePath ' ] = null ;
7979
8080 $ this ->fileHandler = new FileHandler ($ config );
8181 $ this ->fileHandler ->initialize ();
@@ -98,7 +98,7 @@ public function testSave()
9898 {
9999 $ this ->assertTrue ($ this ->fileHandler ->save (self ::$ key1 , 'value ' ));
100100
101- chmod ($ this ->config ->storePath , 0444 );
101+ chmod ($ this ->config ->file [ ' storePath ' ] , 0444 );
102102 $ this ->assertFalse ($ this ->fileHandler ->save (self ::$ key2 , 'value ' ));
103103 }
104104
@@ -173,6 +173,36 @@ public function testIsSupported()
173173 $ this ->assertTrue ($ this ->fileHandler ->isSupported ());
174174 }
175175
176+ /**
177+ * @dataProvider modeProvider
178+ */
179+ public function testSaveMode ($ int , $ string )
180+ {
181+ // Initialize mode
182+ $ config = new \Config \Cache ();
183+ $ config ->file ['mode ' ] = $ int ;
184+
185+ $ this ->fileHandler = new FileHandler ($ config );
186+ $ this ->fileHandler ->initialize ();
187+
188+ $ this ->fileHandler ->save (self ::$ key1 , 'value ' );
189+
190+ $ file = $ config ->file ['storePath ' ] . DIRECTORY_SEPARATOR . self ::$ key1 ;
191+ $ mode = substr (sprintf ('%o ' , fileperms ($ file )), -4 );
192+
193+ $ this ->assertEquals ($ string , $ mode );
194+ }
195+
196+ public function modeProvider ()
197+ {
198+ return [
199+ [0640 , '0640 ' ],
200+ [0600 , '0600 ' ],
201+ [0660 , '0660 ' ],
202+ [0777 , '0777 ' ],
203+ ];
204+ }
205+
176206 //--------------------------------------------------------------------
177207
178208 public function testFileHandler ()
@@ -200,8 +230,8 @@ final class BaseTestFileHandler extends FileHandler
200230
201231 public function __construct ()
202232 {
203- $ this ->config = new \Config \Cache ();
204- $ this ->config ->storePath .= self ::$ directory ;
233+ $ this ->config = new \Config \Cache ();
234+ $ this ->config ->file [ ' storePath ' ] .= self ::$ directory ;
205235
206236 parent ::__construct ($ this ->config );
207237 }
0 commit comments