dousi1961 2015-03-04 21:12
浏览 148

phpunit无法断言两个数组相等,但没有显示出差异

Here is what phpunit says:

1) Asgard\Entity\Tests\EntityTest::testToArray
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
     'id' => null
     'title' => 'Test Title'
     'content' => 'Test Content'
     'published' => 2015-03-04T11:19:50+0000
     'comments' => Array (
         0 => Array (
             'id' => null
             'content' => 'foo'
             'published' => 2015-03-04T11:19:50+0000
             'another_property' => null
             'news' => null
         )
         1 => Array (
             'id' => null
             'content' => 'bar'
             'published' => 2015-03-04T11:19:50+0000
             'another_property' => null
             'news' => null
         )
         2 => Array (
             'id' => null
             'content' => 'baz'
             'published' => 2015-03-04T11:19:50+0000
             'another_property' => null
             'news' => null
         )
     )
     'another_property' => null
 )

https://travis-ci.org/asgardphp/asgard/jobs/53029084

There is no difference between "expected" and "actual". The tests usually pass, but sometimes would fail on this.

  • 写回答

3条回答 默认 最新

  • dongnaigu2052 2015-03-16 14:46
    关注

    Since you're using DateTime in your tests - Are you sure you aren't getting test that start in one second, and finish in another so there is a second difference in the timestamps depending on which stage you look at them? - Using dynamic dates and time in tests is a pretty common reason for occasional failed tests.

    评论

报告相同问题?

悬赏问题

  • ¥15 有人能看一下我宿舍管理系统的报修功能该怎么改啊?链表那里总是越界
  • ¥15 cs loadimage运行不了,easyx也下了,没有用
  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析