Skip to content

Commit 7a022b7

Browse files
committed
test for overrides
1 parent 3d6f732 commit 7a022b7

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/AppTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHPUnit\Framework\TestCase;
66
use Utopia\Tests\UtopiaRequestTest;
77
use Utopia\Validator\Text;
8+
use Exception;
89

910
class 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

0 commit comments

Comments
 (0)