Answer the question
In order to leave comments, you need to log in
How to test an HTTP request?
Hello, I can't find the answer to this seemingly simple question anywhere.
Started learning testing (Outside Laravel\Symfony, pure php) but can't figure out how to test the request.
For example, there is a class:
class Test
{
public function __construct()
{
//
}
public function function()
{
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
include 'testhtml.php';
} else {
return $this->newFunc($_POST['login'], $_POST['password']);
}
}
public function newFunc($login, $password)
{
echo "Ваш логин: $login, пароль: $password";
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form method="POST">
<input type="text" name="login">
<input type="password" name="password">
<input type="submit" name="submit">
</form>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question