1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace EasySwoole\HttpAnnotation\Tests;
- use EasySwoole\Http\Request;
- use EasySwoole\Http\Response;
- trait ControllerBase
- {
- protected function fakeRequest(string $requestPath = '/',array $query = null,array $post = []):Request
- {
- if($query === null){
- $query = [
- "groupParamA"=>"groupParamA",
- 'groupParamB'=>"groupParamB"
- ];
- }else if(!empty($query)){
- $query = $query + [
- "groupParamA"=>"groupParamA",
- 'groupParamB'=>"groupParamB"
- ];
- }
- $request = new Request();
- $request->getUri()->withPath($requestPath);
- //全局的参数
- $request->withQueryParams($query);
- if(!empty($post)){
- $request->withMethod('POST')->withParsedBody($post);
- }else{
- $request->withMethod('GET');
- }
- return $request;
- }
- protected function fakeResponse():Response
- {
- return new Response();
- }
- }
|