1 | <?php |
||
12 | class HttpResponseAdapterTest extends \PHPUnit_Framework_TestCase |
||
13 | { |
||
14 | /** |
||
15 | * {@inheritDoc} |
||
16 | */ |
||
17 | protected $backupGlobals = false; |
||
18 | |||
19 | /** |
||
20 | * Ensure that the Response class returned is a PSR-7 interface |
||
21 | */ |
||
22 | public function testReturnsPsr7CompliantClass() |
||
28 | |||
29 | /** |
||
30 | * Assert that the input can be retrieved again |
||
31 | */ |
||
32 | public function testBodyMatchesInputBody() |
||
44 | |||
45 | /** |
||
46 | * Test that without providing a status code, the default is 200 |
||
47 | */ |
||
48 | public function testSuccessfulByDefault() |
||
54 | |||
55 | /** |
||
56 | * Ensure that as per PSR-7 specifications the interfaces are immutable, and different instances returned |
||
57 | * when we add headers to it (for example) |
||
58 | */ |
||
59 | public function testImmutabilyAddHeaders() |
||
71 | |||
72 | /** |
||
73 | * Test that a PSR-7 interface can be imported (with multiple headers converted to a single line) to a |
||
74 | * HTTPResponse class |
||
75 | */ |
||
76 | public function testCanImportPsr7InterfaceToHttpResponse() |
||
89 | |||
90 | /** |
||
91 | * Create a mocked HTTP response for "adapting" |
||
92 | * |
||
93 | * @param string $body The body of the response |
||
94 | * @param int $statusCode The numeric status code - 200, 404, etc |
||
95 | * @param string $statusDescription The text to be given alongside the status code |
||
96 | * @return \Psr\Http\Message\ResponseInterface |
||
97 | */ |
||
98 | protected function getInterface($body = null, $statusCode = null, $statusDescription = null) |
||
104 | } |
||
105 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: