mardi 3 septembre 2019

How to test external APIs?

I am having a hard time on how to start testing the integration with an external API ( Vimeo API ) for things like ( deleting a video - uploading a video - etc..).

  • Should I hit the real Vimeo's server while testing?

Is it a bad idea to do this like:


use Tests\TestCase;
use Vimeo\Laravel\VimeoManager;

class VimeoApiTest extends TestCase
{
    protected function setUp() : void
    {
        parent::setUp();
        $this->vimeo = new VimeoManager();
    }

    /** @test */
    public function a_video_can_be_deleted()
    {
        $video = $this->vimeo->upload($fakeVideo);

        // make http request to delete the video
        $result = $this->vimeo->delete($video['id']);

        $this->assertEquals('success', $result['status']);
    }
}


Aucun commentaire:

Enregistrer un commentaire