Skip to content

Instantly share code, notes, and snippets.

@devmsh
Created February 10, 2020 08:04
Show Gist options
  • Select an option

  • Save devmsh/2f7ebd8bf033f1712ace73a994fa90cd to your computer and use it in GitHub Desktop.

Select an option

Save devmsh/2f7ebd8bf033f1712ace73a994fa90cd to your computer and use it in GitHub Desktop.
Write better Laravel tests 2
<?php
public function test_users_can_get_their_categories_list()
{
// ...
$response = $this->get('api/categories')
->assertSuccessful()
->dump()
->assertJsonCount(5)
->assertJsonStructure([
[
'id',
'name',
'type',
],
]);
foreach ($response->json() as $category) {
$this->assertEquals($user->id,$category['user_id']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment