簡體   English   中英

如何在 laravel 中創建測試以檢查負載關系

[英]How can create a test in laravel for check load relationships

 public function test_show_role_should_return_actions()
    {
        $this->actingAs($this->user, 'api');
        $this->withHeaders(['Accept' => 'application/json',])
            ->get(route('roles.show', ['role' => $this->role->id]))
            ->assertJsonStructure([
                "data" => [
                    "name",
                    "actions" => [
                        "name",
                        "code"
                    ]
                ]
            ]);
    }

當我運行測試時,我有這個錯誤:

  1. Tests\Feature\Role\RoleTest::test_show_role_should_return_actions 斷言數組具有鍵“名稱”失敗。 即使刪除“名稱”,“操作”鍵也會出現錯誤。

這是我從郵遞員那里得到的數據

 public function test_show_role_should_return_actions()
    {
        $this->actingAs($this->user, 'api');
        $this->withHeaders(['Accept' => 'application/json',])
            ->get(route('roles.show', ['role' => $this->role->id]))
            ->assertJsonStructure([
            'data' => [
                '*' => [
                    'name',
                    'actions' => [
                        '*' => [
                            'name',
                            'code'
                        ]
                    ]
                ]
            ]
        ]);
    }

暫無
暫無

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

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