簡體   English   中英

laravel 8 中的單元測試控制器

[英]Unit Testing controller in laravel 8

我對 Laravel 測試很陌生,我在 Laravel 8 中工作,我想測試的功能是:

當我運行我的測試時,我收到此錯誤:

ErrorException: 試圖獲取非對象的屬性“id”

感謝您的任何幫助!

通常,您甚至不需要在測試中使用Request類。

public function testStore()
{
    Sanctum::actingAs($this->user, ['*']);

    $response = $this->postJson('/order/store', [
        'doAssigned' => false,
        'doValidate' => false,
    ]);

    $response->assertJsonPath('status', 'draft');
} 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM