LoginSignup
1
1

More than 1 year has passed since last update.

PHP laravel セッションに値が入っているかテストする

Last updated at Posted at 2022-12-11

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

概要

  • セッションに任意の値が格納されていることをチェックするテストを記載する方法をまとめる

方法

  • 下記の様に記載することでセッションに値が格納されているか否かをチェックする事ができる。

    $response->assertSessionHas(キー名, );
    
  • 例えば、キー名が「name」の値が「テストユーザー名」がセッションに入っているかチェックする場合下記の様に記載する。

    $response->assertSessionHas('name', 'テストユーザー名');
    
1
1
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
1