我想要实现的目标是:
问题:
我正在使用带有phpspec扩展名的laravel:https://github.com/BenConstable/phpspec-laravel
问题是 - >未在执行phpspec返回的Collection协作者的push方法。
/
上下文类:
class ContextSpec extends ObjectBehavior
{
function it_builds_a_collection_of_context_items(ContextItem $contextItem, Collection $collector)
{
$item = ContextItem::factory(1,2);
$items = [1, 2, 3];
$collector->push($contextItem)->shouldBeCalledTimes(3);
$this->beConstructedThrough("factory", [$items]);
// $collector->push($contextItem)->willReturn($item);
// $contextItem->beConstructedThrough("factory", [0,1])->shouldBeCalled();
// $contextItem::factory(1,2)->shouldBeCalledTimes(3);
// $contextItem->factory()->shouldBeCalledTimes(3);
$this->items()->shouldHaveCount(3);
$this->items()->shouldContain($item);
}
}