public function testInvalidLoginRedirects()
 {
     $login = UnitTestingLoginProvider::singleton();
     $login->logOut();
     $_SERVER["SCRIPT_NAME"] = "/cant/be/here";
     $request = new WebRequest();
     $request->initialise();
     $response = Application::current()->generateResponseForRequest($request);
     $this->assertInstanceOf(RedirectResponse::class, $response);
 }
Esempio n. 2
0
 protected function initialise()
 {
     require_once __DIR__ . '/../../unit/UrlHandlers/UrlHandlerTestUnitTest.php';
     parent::initialise();
     $login = new ValidateLoginUrlHandler(UnitTestingLoginProvider::singleton(), "/login/index");
     $login->SetPriority(20);
     $this->addUrlHandlers(["/cant/be/here" => $login]);
     $login = new ValidateLoginUrlHandler(UnitTestingLoginProvider::singleton(), "/defo/not/here/login/index/", ["login/index/" => new ClassMappedUrlHandler(SimpleContent::class)]);
     $login->setPriority(20);
     $this->addUrlHandlers(["/defo/not/here/" => $login]);
     $this->addUrlHandlers([new UnitTestComputedUrlHandler()]);
     $this->addUrlHandlers(["/" => new ClassMappedUrlHandler(SimpleContent::class, ["nmh/" => new NamespaceMappedUrlHandler('Rhubarb\\Crown\\Tests\\Fixtures\\UrlHandlers\\NamespaceMappedHandlerTests'), "simple/" => new ClassMappedUrlHandler(SimpleContent::class), "files/" => new StaticResourceUrlHandler(__DIR__ . "/../UrlHandlers/")])]);
     $this->addUrlHandlers("/priority-test/", new ValidateLoginUrlHandler(UnitTestingLoginProvider::singleton(), "/login/index"));
     $test = new NamespaceMappedUrlHandler('Rhubarb\\Leaf\\Presenters');
     $test->setPriority(100);
     $this->addUrlHandlers("/priority-test/", $test);
     EmailProvider::setProviderClassName(UnitTestingEmailProvider::class);
 }
Esempio n. 3
0
 public function testForceLogin()
 {
     $loginProvider = UnitTestingLoginProvider::singleton();
     $loginProvider->forceLogin();
     $this->assertTrue($loginProvider->isLoggedIn());
 }