我有一个方法,我正在测试输出XML。在我的测试中,我有以下断言(由于NDA而更改了名称):
// arrange
$service = new Service($entityManager);
// act
$results = $service->doThing();
$xml = simplexml_load_string($results);
// assert
$this->assertContains('Bitcoin', $xml->item[0]->paymentStatus);
$this->assertContains('Credit Card', $xml->item[1]->paymentStatus);
paymentStatus
在这两种情况下都是字符串。一个很简单:
<paymentStatus>Paid with Bitcoin</paymentStatus>
另一个是
<paymentStatus>Paid with Credit Card</paymentStatus>
因为paymentStatus
包含一个字符串,应该被认为是可遍历的,对吗?那么为什么它不能"看到"这些字符串中的比特币/信用卡部分呢?我已经手动验证了输出。具有这些值的字符串是结果XML的一部分。
原来是一个十年未解决的已知错误/预期行为:https://bugs.php.net/bug.php?id=29500
: facepalm指: