LoginSignup
2
0

More than 1 year has passed since last update.

laravel テストアサーション 論理削除されているか確認する(要点のみ)

Last updated at Posted at 2022-08-07

概要

  • DB系テストアサーションで論理削除されていることを確認するアサーションとその使い方を要点のみまとめる。

方法1 - モデルを使う

  • assertSoftDeleted()の引数に論理削除されたことを期待するモデルを渡すことでチェック可能である。

    $this->assertSoftDeleted($fooModel);
    

方法2 - テーブル名と一意の値を使う

  • assertSoftDeleted()の引数にテーブル名とレコード絞り込みデータを渡すことでチェック可能である。

    $this->assertSoftDeleted(
        table: 'テーブル名', 
        data: [
            'id' => 1,
        ],
    );
    

参考文献

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