Skip to content

Instantly share code, notes, and snippets.

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

  • Save devmsh/0e811de05d2e7a79bd3dad9c388e3353 to your computer and use it in GitHub Desktop.

Select an option

Save devmsh/0e811de05d2e7a79bd3dad9c388e3353 to your computer and use it in GitHub Desktop.
Write better Laravel tests 6
<?php
/**
* @depends test_user_have_a_copy_of_the_default_categories
*/
public function test_users_can_get_their_categories_list()
{
factory(Category::class, 5)->create();
$this->passportAs($user = factory(User::class)->create())
->get('api/categories')
->assertSuccessful()
->assertJsonCount(5)
->assertJsonPaths('*.user_id', $user->id)
->assertJsonStructure([
[
'id',
'name',
'type',
],
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment