InterNations / http-mock

Mock HTTP requests on the server side in your PHP unit tests
http://www.internations.org
MIT License
390 stars 62 forks source link

Check that server didn't receive any or particular request #23

Closed AlexMarlo closed 8 years ago

AlexMarlo commented 8 years ago

I have functionality when i need to know that part of the code which call remote server wasn't called. For now i don't see such functionality in library. Any ideas?

lstrojny commented 8 years ago

Can’t you check that requests are empty?

AlexMarlo commented 8 years ago

I don't see in RequestCollectionFacade public function to get request list.

lstrojny commented 8 years ago

True, let’s think about an API. What about saying $this->assertCount(2, $this->http->requests);?

lstrojny commented 8 years ago

PR is #24

AlexMarlo commented 8 years ago

great, but what about the case when i want to now that particular request wasn't received?

lstrojny commented 8 years ago

You can do something like this: $this->assertNotSame('/unexpected', $this->http->request->latest()->getRequestUri());

Alternatively we would need to match against all requests and say "assert that there hasn’t been a request matching the following criteria". But I am not sure that’s needed.

alexeyshockov commented 8 years ago

I think that the last part of this issue is similar to #25. With real mocks this checks will be created automatically (how many times particular request should be done).

lstrojny commented 8 years ago

Closing this for now, ok?