This project has been archived. If you're curious, check out one of my latest courses:
If you work with JavaScript, check out the fetch use cases and JavaScript projects.
Thank you! — Jad Joubran
ModelFactory.php
$factory->define(App\Post::class, function (Faker\Generator $faker) {
return [
'title' => $faker->word,
'description' => $faker->text,
];
});
php artisan make:test GetAllPostsTest
GetPostsTests.php
<?php
namespace Tests\Feature;
use Tests\TestCase;
class GetAllPostsTest extends TestCase
{
public function testGetAllPosts()
{
$post = factory(\App\Post::class)->create();
$this->get('api/posts')
->assertJsonFragment([
'id' => $post->id,
'title' => $post->title,
]);
}
}