public function testTheLoginUrlisExcludedFromRedirect() { $_SERVER["SCRIPT_NAME"] = "/defo/not/here/login/index/"; $request = new WebRequest(); $context = new PhpContext(); $context->Request = $request; $request->initialise(); $response = Application::current()->generateResponseForRequest($request); $this->assertInstanceOf(HtmlResponse::class, $response); }
public function testTheLoginUrlisExcludedFromRedirect() { $_SERVER["SCRIPT_NAME"] = "/defo/not/here/login/index/"; $request = new WebRequest(); $context = new Context(); $context->Request = $request; $request->initialise(); $response = Module::generateResponseForRequest($request); $this->assertInstanceOf("\\Rhubarb\\Crown\\Response\\HtmlResponse", $response); }
protected function tearDown() { $_ENV = $this->stashSuperglobals['env']; $_SERVER = $this->stashSuperglobals['server']; $_GET = $this->stashSuperglobals['get']; $_POST = $this->stashSuperglobals['post']; $_FILES = $this->stashSuperglobals['files']; $_COOKIE = $this->stashSuperglobals['cookie']; $_SESSION = $this->stashSuperglobals['session']; $_REQUEST = $this->stashSuperglobals['request']; $this->stashSuperglobals = []; // WebRequest as Request is an abstract class WebRequest::ResetRequest(); }
public function testNoSSL() { $this->assertFalse($this->request->isSSL()); }
public function testUrlWithBothIDAndActionGetsRelevantPresenter() { $crud = new CrudUrlHandler("Rhubarb\\Stem\\UnitTesting\\User", "Rhubarb\\Leaf\\UnitTesting\\Presenters\\Cruds2"); $crud->SetUrl("/users/"); $user = new User(); $user->Forename = "Goat"; $user->Save(); $request = new WebRequest(); $request->UrlPath = "/users/" . $user->UniqueIdentifier . "/edit/"; $request->Server("HTTP_ACCEPT", "text/html"); $request->Server("REQUEST_METHOD", "get"); $response = $crud->GenerateResponse($request); $this->assertInstanceOf("Rhubarb\\Leaf\\UnitTesting\\Presenters\\Cruds2\\Cruds2EditPresenter", $response->GetGenerator()); $this->assertFalse($response->GetGenerator()->GetRestModel()->IsNewRecord()); $this->assertEquals("Goat", $response->GetContent()); $request = new WebRequest(); $request->UrlPath = "/users/" . $user->UniqueIdentifier . "/"; $request->Server("HTTP_ACCEPT", "text/html"); $request->Server("REQUEST_METHOD", "get"); $response = $crud->GenerateResponse($request); $this->assertInstanceOf("Rhubarb\\Leaf\\UnitTesting\\Presenters\\Cruds2\\Cruds2ItemPresenter", $response->GetGenerator()); }