phpunit assertNull损坏了zend_mm_heap [英] phpunit assertNull gets zend_mm_heap corrupted

查看:98
本文介绍了phpunit assertNull损坏了zend_mm_heap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用标量时:

$null = null;
$this->assertNull($null);

测试正常

$null = 'not null';
$this->assertNull($null);

测试失败

使用对象时:

$this->assertEquals(null, $menu->getChild('Projects'));

关于$ menu-> getChild('Projects')是否为空,测试OK或Fail

Test OK or Fail regarding if $menu->getChild('Projects') is null or not

$this->assertNull($menu->getChild('Projects'));

我一直挂着错误消息: zend_mm_heap损坏

Hangs and I get the error: zend_mm_heap corrupted

使用 AssertNull 时,我没有得到与 AssertEquals(null,$ var)相同的行为; 目前,我禁止使用AssertNull,但我想知道是否有人可以解释发生了什么事情……

When using AssertNull, I do not get the same behavior as AssertEquals(null, $var); For the moment, I ban the use of AssertNull, but I was wondering if one of you could explain what's going on...

推荐答案

对象的类型为: Knp \ Menu \ MenuItem (来自knpmenu php库的对象)

The object is of type : Knp\Menu\MenuItem (An object from the knpmenu php library)

问题是与phpunit库中的函数链接的递归问题.

The problem is a recursivity problem linked with a function from the phpunit library.

class: PHPUnit/Util/Type

功能: recursiveExport

preg_match_all('/\n            \[(\w+)\] => Array\s+\*RECURSION\*/', print_r($value, TRUE), $matches);

如您所见,子级有对父级对象的引用,这就是导致死锁的原因.

As you see, the child has a reference to the parent object, that is the reason for the deadlock.

但是,当我阅读 print_r 的文档时,会说:

But when I read the documentation of print_r, it is stated:

在PHP 4.0.4之前,如果给定包含直接或间接引用其自身的数组或对象,print_r()将永远继续.一个示例是print_r($ GLOBALS),因为$ GLOBALS本身是一个包含对自身的引用的全局变量.

Prior to PHP 4.0.4, print_r() will continue forever if given an array or object that contains a direct or indirect reference to itself. An example is print_r($GLOBALS) because $GLOBALS is itself a global variable that contains a reference to itself.

我正在使用:

塞巴斯蒂安·伯格曼(Sebastian Bergmann)的PHPUnit 3.7.10.

PHPUnit 3.7.10 by Sebastian Bergmann.

PHP 5.4.7(cli)(内置:2012年9月12日23:48:31)

PHP 5.4.7 (cli) (built: Sep 12 2012 23:48:31)

我目前的结论是使用 assertNull ,但使用 AssertEquals

My conclusion for the moment, is NOT to use assertNull but AssertEquals

这篇关于phpunit assertNull损坏了zend_mm_heap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆