jeudi 13 septembre 2018

How to mock external APIs in laravel testing?

This is my code so far. the method is not getting changed after the binding. What did I do wrong?

$this->app->bind(HelperClassHelper::class, function ($app) {
        $id = 1234;
        $mock = $this->createMock(InfusionsoftHelper::class);
        $mock->method('getFunction1')->willReturn(123);
        $mock->method('getFunction2')->with($this->identicalTo($id))->willReturn(4);
        return $mock;

    });
        \App::Make('App\Http\Helpers\HelperClassHelper');
        $this->json('POST', 'api/endpoint');
        $response
             ->assertStatus(200)
             ->assertJson([
                'id' => 154,
                ]);



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2xafTdS
via IFTTT

Aucun commentaire:

Enregistrer un commentaire