Why not work out a simple Feature test in laravel?

Hi, guys.

Why Test returns empty $article->id?
-------------------------------
Array ([$article->id] => )
-------------------------------

class ArticlesController extends Controller
{
 public function update(ArticleRequest $request, Article $article)
{
 throw new Exception(print_r([
 '$article->id' => $article->id
]));
}
}


class ArticleTest extends TestCase
{
 public function test_article_update_success(): void
{
$this->withoutMiddleware();
 $article = factory(Article::class)->create();

 $putArr = [
 'name' => $this->faker->name,
 'body' => $this->faker->sentence,
];

 $response = $this->put(route('admin.articles.update', $article), $putArr);

 throw $response->exception;
}
}
April 3rd 20 at 18:29
1 answer
April 3rd 20 at 18:31
Solution
$this->withoutMiddleware(VerifyCsrfToken::class);

Find more questions by tags PHPUnitLaravel