File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55use PHPUnit \Framework \TestCase ;
66use Utopia \Tests \UtopiaRequestTest ;
77use Utopia \Validator \Text ;
8+ use Exception ;
89
910class AppTest extends TestCase
1011{
@@ -315,6 +316,31 @@ public function testCanAddAndExecuteHooks()
315316 $ this ->assertEquals ('x-def ' , $ result );
316317 }
317318
319+ public function testAllowRouteOverrides () {
320+ App::setAllowOverride (false );
321+ $ this ->assertFalse (App::getAllowOverride ());
322+ App::get ('/ ' )->action (function () {
323+ echo 'Hello first ' ;
324+ });
325+
326+ $ this ->expectException (Exception::class);
327+ App::get ('/ ' )->action (function (){
328+ echo 'Hello second ' ;
329+ });
330+
331+ // Test success
332+ App::setAllowOverride (true );
333+ $ this ->assertTrue (App::getAllowOverride ());
334+ App::get ('/ ' )->action (function () {
335+ echo 'Hello first ' ;
336+ });
337+
338+ App::get ('/ ' )->action (function (){
339+ echo 'Hello second ' ;
340+ });
341+
342+ }
343+
318344 public function testCanHookThrowExceptions ()
319345 {
320346 $ this ->app
You can’t perform that action at this time.
0 commit comments