[Laravel] Controllerをphpunitする時に使うassertion一覧

カテゴリ: 未分類

レスポンスステータスが正しいこと

use Illuminate\Http\Response;

$response = $this->getAjax($path);

$response->assertStatus(Response::HTTP_OK);

Jsonの構造が一致していること

$response = $this->getAjax($path);

$expected = [
    'status' => 'ok',
];
$response->assertExactJson($expected);
関連記事

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です