yoanbernabeu / Airtable-Client-Bundle

Simple Client for Airtable API
MIT License
33 stars 12 forks source link

Feature/create news records #12

Closed yoanbernabeu closed 3 years ago

yoanbernabeu commented 3 years ago
ismail1432 commented 3 years ago

Hey :wave:

Thanks for this one :+1:

(I need help writing the tests)

You just have to mock the response, you told what response should be return by the request, then you service AirtableClient will transform this response to an Object so you can assert the value of the object, let me add a small example


public function testAddRecordReturnARecord()
      {
      $httpClient = new MockHttpClient(
      new MockResponse(json_encode(['id' => '42'],),'https://api.github.com'));

      $airTableClient = new AirtableClient('key', 'id', $httpClient, new ObjectNormalizer());
      $record = $airTableClient->addRecord(...);

      assertInstanceOf()
      assertEquals($record->getId(), 42);
}
....

Don't forget to check wrong scenario ...