在laravel phpunit中测试阵列

在laravel phpunit中测试阵列,laravel,testing,phpunit,Laravel,Testing,Phpunit,我在laravel中有一个数组输出,结构如下所示: array:1 [ 0 => {#35 +"id": 152 +"user_id": 123 +"post_id": 456 +"content": "impedit" +"created_at": "04-09-2016 01:24" +"updated_at": "2016-09-04 01:24:51" } ] 如何测试包含键id、user\u id的数组结构 我尝试了ass

我在laravel中有一个数组输出,结构如下所示:

array:1 [
  0 => {#35
    +"id": 152
    +"user_id": 123
    +"post_id": 456
    +"content": "impedit"
    +"created_at": "04-09-2016 01:24"
    +"updated_at": "2016-09-04 01:24:51"
  }
]
如何测试包含键
id
user\u id
的数组结构

我尝试了assertArrayHasKey('user_id',$array),但它显示失败。
谢谢。

谢谢@linuxartisan。最后,我将value对象转换为数组进行测试

$this->assertArrayHasKey('user_id', (array)$comment[0]);

它失败,因为数组中的键是
0、1、2、…
。数组中的和值都是对象。@linuxartisan感谢您的回复。如果我得到了这些结构,是否可以通过PHPUnit进行测试?尝试使用
property\u exists
函数@linuxartisan非常感谢。我最终将对象转换为数组,效果很好。再次感谢!