vendredi 13 mars 2020

Codeception and Laravel

I'm starting to use Codeception for my Laravel app. I'm quite confused about it. I'm trying to write a test method that can check for something. So my Database has the following two tables:

  • Authors
  • Books

They are linked in one-to-many relationship where an Author can have more than one book, but each book can only be written by one author. I want to create a method to test an API which brings all the books of a specific Author.

My API is /authors/{author}/books

Could someone please explain to me how i could write such test. What data I should be expecting? I think I need to check for the data itself and not just the response code returned from the API. I want to make sure that the API brings only the books of the specified author and not just random books or all the books available in the DB.

Maybe some pseudo code or even an actual code with a bit of explanation could be helpful.

Thanks

Aucun commentaire:

Enregistrer un commentaire