Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ranx99's avatar

Testing external API or not?

I am trying to integrate my app to work with Vimeo api ( video uploading - getting a video - deleting a video .. etc)

this is my first time trying to test an external API ..

How should I start testing the API ? what are your experiences in this ?

For example: should I test the deleting directly like this ?

protected function setUp() : void
{
    parent::setUp();
    $this->vimeo = new VimeoApiClient();
}

/** @test */
public function a_video_can_be_deleted()
{
    $video = $this->vimeo->upload($video);
    
    // make http request to delete the video 
    $result = $this->vimeo->delete($video['id']);
    
    $this->assertEquals('success', $result['status']);
}
0 likes
5 replies
jlrdw's avatar

Does a real World upload work? If so and you test, and test passes, all you've done is what?

I prefer real World test, I've seen where test pass but there are still real World issues. Just me.

tykus's avatar

I would be reluctant to be testing against a live API directly, from the point of view or (i) test execution speed, (ii) possible API rate limits, (iii) not putting testing artefacts on the API that are not subsequently cleaned up,.

What is VimeoApiClient; your own code or third-party? If it is a reliable third-party package, then it is most likely already tested. If not, then find a third party package that is tested. In any case, test your integration with that package, rather than testing what the package does.

1 like
Ranx99's avatar

Yes, VimeoApiClient is a reliable package with tests.

but, isn't more reliable to test this integration using a real requests to Vimeo servers than mocking that package?

I think execution speed is not a problem, since I can exclude these kind of tests whenever I want to using "groups". Is it really a bad idea to test integration this way?

1 like
Punksolid's avatar

I have the same issue, but in my case the service I'm using is de-standardized and also I'm using a library that was also done by my but the playground key doesn't permit all operations so yes Im testing the integration too.

But I mark it as a $this->markTestAsRisky() or $this->markTestAsSkiped() and it will skip that test and once in a while I reactivate them just to try it.

If the api you are using looks robuts you could mock it

Ranx99's avatar

I have came a cross php-vcr, which seems the solution I was looking for.

Please or to participate in this conversation.