$user = User::find($id); $user->logOut(); return $app['twig']->render('home.html.twig'); }); //list of users page //after sign up $app->post("/signup", function () use($app) { $user_name = $_POST['user_name']; $password = $_POST['password']; $retype_password = $_POST['retype_password']; $latitude = 45.516231; $longitude = -122.682519; $signed_in = true; $user = new User($user_name, $password, $longitude, $latitude, $signed_in, $id = null); $user->save(); return $app['twig']->render('users.html.twig', array('user' => $user, 'avialable_users' => $user->findUsersNear(), 'requests' => $user->findMeetupRequests())); }); //log in page $app->get("/login", function () use($app) { return $app['twig']->render('login.html.twig'); }); $app->get("/logged_on", function () use($app) { $user_name = $_GET['username']; $user = User::findByUserName($user_name); $user_logged = $user->logIn($user_name, $_GET['password']); if ($user_logged == "Wrong Password") { return $app['twig']->render('login.html.twig'); } else { return $app['twig']->render('users.html.twig', array('user' => $user_logged, 'avialable_users' => $user->findUsersNear(), 'requests' => $user->findMeetupRequests())); } });
function test_addMeetUpRequest() { //Arrange $user_name = "Nathan"; $password = "******"; $latitude = 45.520969; $longitude = -122.679953; $signed_in = 1; $id = 1; $test_user = new User($user_name, $password, $longitude, $latitude, $signed_in, $id); $test_user->save(); $user_name2 = "John"; $password2 = "xxx"; $latitude2 = 45.515852; $longitude2 = -122.674644; $signed_in2 = 1; $id2 = 1; $test_user2 = new User($user_name2, $password2, $longitude2, $latitude2, $signed_in2, $id2); $test_user2->save(); $place_name = "Director Park"; $address = "SW Park Ave"; $longitude = 45.518672; $latitude = -122.681211; $id3 = 4; $test_place = new Place($place_name, $address, $longitude, $latitude, $id3); //Act $test_user->addMeetUpRequest($test_user2->getId(), $test_place->getId()); $result = $test_user2->findMeetupRequests(); //Assert $this->assertEquals([$test_user], $result); }