function it_builds_pending_versions_for_a_given_entity(ProductInterface $product, $builder, $versionRepository) { $product->getId()->willReturn(1); $pending1 = new Version('Product', 1, 'julia'); $pending1->setChangeset(['foo' => 'bar']); $pending2 = new Version('Product', 1, 'julia'); $pending2->setChangeset(['foo' => 'fubar']); $versionRepository->findBy(Argument::cetera())->willReturn([$pending1, $pending2]); $builder->buildPendingVersion($pending1, null)->willReturn($pending1)->shouldBeCalled(); $builder->buildPendingVersion($pending2, $pending1)->willReturn($pending2)->shouldBeCalled(); $versions = $this->buildPendingVersions($product); $versions->shouldHaveCount(2); }