php POST、GET、PUT、DELETE 测试
好吧,“创建脚本”:
$method = $_SERVER['REQUEST_METHOD'];
switch($method) {
case 'PUT':
echo 'put method';
break;
case 'GET':
echo 'get method';
break;
case 'POST':
echo 'post method';
break;
case 'DELETE':
echo 'delete method';
default:
echo 'valid method\'s: PUT, GET, POST, DELETE';
}
- 测试每种方法的最佳/最简单方法是什么?
想测试它们,因为实际上每种方法都存在不同的任务。
Well, "created script":
$method = $_SERVER['REQUEST_METHOD'];
switch($method) {
case 'PUT':
echo 'put method';
break;
case 'GET':
echo 'get method';
break;
case 'POST':
echo 'post method';
break;
case 'DELETE':
echo 'delete method';
default:
echo 'valid method\'s: PUT, GET, POST, DELETE';
}
- What's is best/simplest way to test each method ?
Wanna test them because actually in each method exist different task.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编写一个脚本,为每个方法向您正在测试的脚本所在的 URI 发出一个或多个 HTTP 请求(包含已知数据)。
每次请求后,脚本应检查响应是否符合您的预期,以及任何副作用(例如在服务器上创建文件或数据库中的条目已更改)是否符合您的预期。
Write a script that makes one or more HTTP requests (containing known data) for each method to the URI that the script you are testing resides at.
After each request the script should check that the response is as you expect it and that any side effects (such as the creation of files on the server, or entries in a database have changed) are as you expect.
设置具有特定操作的表单:
对于“GET”,您只需通过调用您的 URL 并附加
?key=value
来发送查询字符串Set up a form with a particular action:
For "GET" you can just send in a querystring by calling your URL and appending
?key=value