public static function setUpBeforeClass() { parent::setUpBeforeClass(); $user = new User(); $user->Forename = "Alice"; $user->Surname = "Smith"; $user->Save(); $user = new User(); $user->Forename = "Bob"; $user->Surname = "Diamond"; $user->Save(); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); $user = new User(); $user->Username = "******"; $user->Password = '******'; $user->Active = 1; $user->Save(); $user = new User(); $user->Username = "******"; $user->Password = '******'; $user->Active = 0; $user->Save(); $testLoginProvider = new TestLoginProvider(); $testLoginProvider->LogOut(); }
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()); }