1
0

More than 1 year has passed since last update.

PHP Laravel データがViewに含まれているかテストする

Posted at

この記事はmiriwoお一人様 Advent Calendar 2022の16日目の記事です

概要

  • Viewに指定したキーと値が含まれることをテストする方法をまとめる

方法

  • レスポンスに対してassertViewHasを使ってチェックする。

    $response->assertViewHas(キー名, );
    
  • 例えばキー名がidで値が10の情報がViewに含まれていることをチェックしたい場合下記の様に記載する。

    $response->assertViewHas('id', 10);
    
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0