LoginSignup
0
0

More than 1 year has passed since last update.

laravel テストアサーション テーブルのレコード数を確認する

Last updated at Posted at 2022-07-21

概要

  • laravelのテストコードのアサーションにて特定のテーブルのレコード数を確認するアサーションをまとめる。

チェック方法

  • assertDatabaseCountアサーションを用いてチェックを行う。

  • 「テストコードの処理の結果usersテーブルに1レコードが存在すること」を確認したい場合下記のように記載する。

    $this->assertDatabaseCount(table: 'users', count: 1);
    
  • 満たしていればテストが通る。

参考文献

0
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
0
0