如何使用 phpspec 测试是否正确创建了父子双向关系?
类 ParentSpec 扩展 ObjectBehavior
{
函数 it_adds_a_reference_to_self_while_(Child $child)
{
$this->addChild($child);
$child->setParent($this)->shouldBeCalled();
}
}
第 7 行抛出一个错误,这很糟糕,因为$thisis a ParentSpecobject not Parent。但我没有其他想法如何测试该setParent方法已被调用。