@@ -22,7 +22,7 @@ public function setUp() : void
2222 $ basedir = dirname (__DIR__ ) . '/app ' ;
2323 $ this ->config ['base_dir ' ] = $ basedir ;
2424 $ this ->config ['app_dir ' ] = $ basedir ;
25- $ this ->config ['cache_file ' ] = tempnam ( sys_get_temp_dir (), ' FRT ' ) ;
25+ $ this ->config ['cache_file ' ] = sys_get_temp_dir () . ' /fsrt.cache ' ;
2626 $ _SERVER = [];
2727 $ _FILES = [];
2828 $ _GET = [];
@@ -52,9 +52,9 @@ public function shouldExtractRouteFromURLSuccessfully($requestedPath, $folder, $
5252 $ router = new Router (
5353 $ this ->config ['default_return_type ' ],
5454 $ this ->request ->getMethod (),
55- $ this ->request ->getUri ()->getPath (),
56- $ this ->config ['folder ' ]
55+ $ this ->request ->getUri ()->getPath ()
5756 );
57+ $ router = $ router ->withSubFolder ($ this ->config ['folder ' ]);
5858 $ router ->add (Router::GET , '/ ' , 'app/main ' , null , 'home ' );
5959 $ router ->add (Router::GET , '/json ' , 'app/json ' , Router::JSON );
6060 $ router ->add (Router::POST , '/json ' , 'app/redirect ' , Router::REDIRECT );
@@ -90,14 +90,23 @@ public function shouldCacheRoutesSuccessfully() : void
9090 $ this ->request ->getUri ()->getPath ()
9191 );
9292 $ router = $ router ->withSubFolder ($ this ->config ['folder ' ])
93- ->withSubFolder ($ this ->config ['cache_file ' ]);
93+ ->withCacheFile ($ this ->config ['cache_file ' ]);
9494
9595 $ router ->add (Router::GET , '/ ' , 'app/main ' , Router::HTML , 'home ' );
9696 $ router ->getRoute ();
9797 $ this ->assertFileExists (
9898 $ this ->config ['cache_file ' ],
9999 'Couldn \'t cache the file '
100100 );
101+ // Rest of the test should run without throwing exception
102+ $ router = new Router (
103+ $ this ->config ['default_return_type ' ],
104+ $ this ->request ->getMethod (),
105+ $ this ->request ->getUri ()->getPath ()
106+ );
107+ $ router = $ router ->withSubFolder ($ this ->config ['folder ' ])
108+ ->withSubFolder ($ this ->config ['cache_file ' ]);
109+ $ router ->getRoute ();
101110 }
102111 /**
103112 * @test
@@ -132,13 +141,11 @@ public function shouldReadCacheRoutesSuccessfully($requestedPath, $folder, $expe
132141 $ router = new Router (
133142 $ this ->config ['default_return_type ' ],
134143 $ this ->request ->getMethod (),
135- $ this ->request ->getUri ()->getPath (),
136- $ this ->config ['folder ' ],
137- $ this ->config ['cache_file ' ]
144+ $ this ->request ->getUri ()->getPath ()
138145 );
146+ $ router = $ router ->withCacheFile ($ this ->config ['cache_file ' ])
147+ ->withSubFolder ($ this ->config ['folder ' ]);
139148 $ router ->add (Router::GET , '/ ' , 'app/main ' , Router::HTML , 'home ' );
140- $ r = $ router ->getRoute ();
141-
142149 $ router ->add (Router::GET , '/ ' , 'app/main ' , null , 'home ' );
143150 $ router ->add (Router::GET , '/json ' , 'app/json ' , Router::JSON );
144151 $ router ->add (Router::GET , '/json ' , 'app/json ' , Router::JSON );
@@ -322,8 +329,8 @@ public function shouldCorrectlyReturnNotFound() : void
322329
323330 public static function tearDownAfterClass () : void
324331 {
325- if (file_exists (' /tmp/fastroute .cache ' )) {
326- unlink (' /tmp/fastroute .cache ' );
332+ if (file_exists (sys_get_temp_dir () . ' /fsrt .cache ' )) {
333+ unlink (sys_get_temp_dir () . ' /fsrt .cache ' );
327334 }
328335 if (file_exists ('/tmp/failed.cache ' )) {
329336 unlink ('/tmp/failed.cache ' );
0 commit comments