1 | <?php |
||
25 | abstract class AbstractRequester |
||
26 | { |
||
27 | protected $method = 'get'; |
||
28 | protected $path = '/'; |
||
29 | protected $requestHeader = []; |
||
30 | protected $query = []; |
||
31 | protected $requestBody = null; |
||
32 | /** |
||
33 | * @var Schema |
||
34 | */ |
||
35 | protected $schema = null; |
||
36 | |||
37 | protected $statusExpected = 200; |
||
38 | protected $assertHeader = []; |
||
39 | protected $assertBody = null; |
||
40 | |||
41 | /** |
||
42 | * abstract function to be implemented by derived classes |
||
43 | * |
||
44 | * This function must be implemented by derived classes. It should process |
||
45 | * the given request and return an according response. |
||
46 | * |
||
47 | * @param RequestInterface $request |
||
48 | * @return ResponseInterface |
||
49 | */ |
||
50 | abstract protected function handleRequest(RequestInterface $request); |
||
51 | |||
52 | /** |
||
53 | * @param Schema $schema |
||
54 | * @return $this |
||
55 | */ |
||
56 | public function withSchema($schema) |
||
62 | |||
63 | /** |
||
64 | * @return bool |
||
65 | */ |
||
66 | public function hasSchema() |
||
70 | |||
71 | /** |
||
72 | * @param string $method |
||
73 | * @return $this |
||
74 | */ |
||
75 | public function withMethod($method) |
||
81 | |||
82 | /** |
||
83 | * @param string $path |
||
84 | * @return $this |
||
85 | */ |
||
86 | public function withPath($path) |
||
92 | |||
93 | /** |
||
94 | * @param array $requestHeader |
||
95 | * @return $this |
||
96 | */ |
||
97 | public function withRequestHeader($requestHeader) |
||
108 | |||
109 | /** |
||
110 | * @param array $query |
||
111 | * @return $this |
||
112 | */ |
||
113 | public function withQuery($query = null) |
||
124 | |||
125 | /** |
||
126 | * @param null $requestBody |
||
127 | * @return $this |
||
128 | */ |
||
129 | public function withRequestBody($requestBody) |
||
135 | |||
136 | public function assertResponseCode($code) |
||
142 | |||
143 | public function assertHeaderContains($header, $contains) |
||
149 | |||
150 | public function assertBodyContains($contains) |
||
156 | |||
157 | /** |
||
158 | * @return mixed |
||
159 | * @throws Exception\DefinitionNotFoundException |
||
160 | * @throws Exception\GenericSwaggerException |
||
161 | * @throws Exception\HttpMethodNotFoundException |
||
162 | * @throws Exception\InvalidDefinitionException |
||
163 | * @throws Exception\PathNotFoundException |
||
164 | * @throws NotMatchedException |
||
165 | * @throws StatusCodeNotMatchedException |
||
166 | * @throws MessageException |
||
167 | */ |
||
168 | public function send() |
||
244 | } |
||
245 |