Get started
Install Angular Install Motivation
Tutorial
Overview TDD Model setup API routes Angular Http Angular Auth
Response Macros
Overview Validations
JWT Authentication
Overview Install Usage

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

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

AltStyle によって変換されたページ (->オリジナル) /