public function testAppIsResetted() { Apricot::when('/', function () { }); $old = Apricot::getInstance(); Apricot::reset(); $new = Apricot::getInstance(); $this->assertTrue($old !== $new); }
public function testMiddlewareIsCalled() { Apricot::reset(); Apricot::add(function () { echo 'Foo'; }); Apricot::when('/', function () { echo 'Bar'; }); $this->assertTrue('FooBar' === Apricot::browse('/')); }
public function testUrlIsSecuredWithParams() { Apricot::reset(); Apricot::setEnvironment('test'); Apricot::secure('/secured', function ($token) { echo "Hello {$token}"; return true; }); Apricot::when('/secured/:token', function () { }); $this->assertTrue('Hello F00B4z' === Apricot::browse('/secured/F00B4z')); }
public function testAccessDeniedTriggeredWithCallback() { Apricot::reset(); Apricot::setEnvironment('test'); Apricot::when('/', function () { Apricot::triggerAccessDenied(); }); Apricot::accessDenied(function () { echo 'Stop!'; }); $this->assertTrue('Stop!' === Apricot::browse('/')); }
public function testSecureRouteNotMatchIfNoHttps() { Apricot::reset(); Apricot::setEnvironment('test'); Apricot::when('/secured', Apricot::with(array('_secure' => true), function () { echo 'Foo'; })); Apricot::notFound(function () { echo 'Not Found'; }); $this->assertTrue('Not Found' === Apricot::browse('/secured')); }