小编mar*_*hyl的帖子

Laravel:assertDatabaseHas - 意外失败

我不明白为什么这个数据库测试失败。我知道我没有在 created_at 和 updated_at 列上断言,但是三列(id、user_id、thing_id)应该足够了,我确信我之前只测试了一些列,并且它工作了!

我错过了什么?

    Failed asserting that a row in the table [thing_history] matches the attributes [
            {
                "id": 1,
                "user_id": 1,
                "thing_id": 1
            },
            {
                "id": 2,
                "user_id": 1,
                "thing_id": 2
            },
            {
                "id": 3,
                "user_id": 1,
                "thing_id": 3
            }
        ].

        Found: [
            {
                "id": "1",
                "user_id": "1",
                "thing_id": "1",
                "created_at": "2019-02-01 21:18:17",
                "updated_at": "2019-02-01 21:18:17"
            },
            {
                "id": "2",
                "user_id": "1",
                "thing_id": "2",
                "created_at": "2019-02-01 21:18:17",
                "updated_at": "2019-02-01 21:18:17"
            },
            {
                "id": "3",
                "user_id": "1",
                "thing_id": …
Run Code Online (Sandbox Code Playgroud)

testing phpunit laravel

0
推荐指数
1
解决办法
3613
查看次数

标签 统计

laravel ×1

phpunit ×1

testing ×1