Open toby-griffiths opened 10 months ago
Actually, I've just realised it doesn't matter whehter I update the constructor args in a example or not, it gives the same error. I this I may have been mislead by my assuption that the it_is_initializable()
example would instantiate the object?!
So this example also gives the Return value must be of type Double\HttpClientInterface\P1, Double\HttpClientInterface\HttpClientInterface\P3 returned
error as well…
public function it_should_send_get_requests(
HttpClientInterface $httpClient,
ResponseInterface $response,
): void {
$response->getContent()->willReturn('{"id": 123, "name": "Bob Bobbins"}');
$this
->get('people/123')
->shouldReturn(['id' => 123, 'name' => 'Bob Bobbins']);
$httpClient->request('GET', 'people/123')->shouldBeCalledOnce();
}
Yes there is some semi-complex logic around when an object is instantiated, it may not be if the only assertion is about its type
I don't think this is a known issue
Ah, OK. Thanks @ciaranmcnulty. Would yo like me to leave this open for review then? I'm working OK by storing the initial collaborator instances in properties and using them in the examples.
I am configuring Symfony's immutable
HttpClient
in the constructor of a service. I have the spec set up to return a new instance of the client in thelet()
method, which works fine in spec that don't reconfigure the constructor.However, if I attempt to reconfigure the constructor in an example then I get an error about the return type…
… results in …
… however, if I inject the resulting client into the example, even if it's not used, it works just fine…
Is this a known limitation?