/** * test grabbing a favorite team from favoriteTeamProfileId **/ public function testGetInvalidFavoriteTeamByFavoriteTeamProfileId() { // grab a favorite team that exceeds the maximum allowable favoriteteamteamid length $favoriteTeamTeamId = FavoriteTeam::getFavoriteTeamsByFavoriteTeamProfileId($this->getPDO(), SprotsTest::INVALID_KEY, SprotsTest::INVALID_KEY); $this->assertEquals(0, 0); }
//determine which HTTP method was used $method = array_key_exists("HTTP_X_HTTP_METHOD", $_SERVER) ? $_SERVER["HTTP_X_HTTP_METHOD"] : $SERVER["REQUEST_METHOD"]; //sanitize inputs $id = filter_input(INPUT_GET, "id", FILTER_VALIDATE_INT); //make sure the id is valid for methods that require it if (($method === "DELETE" || $method === "PUT") && (empty($id) === true || $id < 0)) { throw new InvalidArgumentException("id can not be empty or negative", 405); } //sanitize and trim other fields $favoriteTeamProfileId = filter_input(INPUT_GET, "profileId", FILTER_VALIDATE_INT); $favoriteTeamTeamId = filter_input(INPUT_GET, "teamId", FILTER_VALIDATE_INT); //get the team based on the given field if (empty($id) === false) { $favoriteTeam = FavoriteTeam::getFavoriteTeamByFavoriteTeamProfileIdAndFavoriteTeamTeamId($pdo, $id); $reply->data = $favoriteTeam; } elseif (empty($favoriteTeamTeamId) === false) { $favoriteTeam = FavoriteTeam::getFavoriteTeamsByFavoriteTeamProfileId($pdo, $teamId); $reply->date = $favoriteTeam; } } catch (Exception $exception) { $reply->status = $exception->getCode(); $reply->message = $exception->getMessage(); } catch (TypeError $typeError) { $reply->status = $typeError->getCode(); $reply->message = $typeError->getMessage(); } header("Content-type: application/json"); if ($reply->data === null) { unset($reply->data); } echo json_encode($reply);