Unfortunately, this project has been discontinued

TDD

We'll be following the Test Driven Development process

Define the model factory

ModelFactory.php

$factory->define(App\Post::class, function (Faker\Generator $faker) {
    return [
        'title' => $faker->word,
        'description' => $faker->text,
    ];
});

Writing the test

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,
        ]);
    }
}