1 | <?php |
||
22 | class TestCase extends WebTestCase |
||
23 | { |
||
24 | /** |
||
25 | * @var Application |
||
26 | */ |
||
27 | protected $app; |
||
28 | |||
29 | /** |
||
30 | * Set up unit. |
||
31 | */ |
||
32 | 13 | public function setUp() |
|
33 | 1 | { |
|
34 | 13 | $this->app = $this->createApplication(); |
|
35 | 13 | parent::setUp(); |
|
36 | 13 | } |
|
37 | |||
38 | /** |
||
39 | * @return Application |
||
40 | */ |
||
41 | public function createApplication() |
||
42 | { |
||
43 | return new Application(getcwd()); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param ServerRequestInterface $request |
||
48 | * @param array $params |
||
49 | * @param array $headers |
||
50 | * |
||
51 | * @return Response |
||
52 | */ |
||
53 | public function handleRequest(ServerRequestInterface $request, array $params = [], array $headers = []) |
||
54 | { |
||
55 | if ('GET' === $request->getMethod()) { |
||
56 | $request->withQueryParams($params); |
||
57 | } else { |
||
58 | $request->withParsedBody($params); |
||
59 | } |
||
60 | foreach ($headers as $name => $header) { |
||
61 | $request->withAddedHeader($name, $header); |
||
62 | } |
||
63 | |||
64 | return $this->app->handleRequest($request); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Returns the test database connection. |
||
69 | * |
||
70 | * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection |
||
71 | */ |
||
72 | 13 | protected function getConnection() |
|
81 | |||
82 | /** |
||
83 | * Returns the test dataset. |
||
84 | * |
||
85 | * @return PHPUnit_Extensions_Database_DataSet_IDataSet |
||
86 | */ |
||
87 | 13 | protected function getDataSet() |
|
107 | } |
||
108 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.