function it_advises_not_to_purge_other_versions($versionRepository, VersionInterface $version)
 {
     $version->getId()->willReturn(2);
     $version->getResourceName()->willReturn('Product');
     $version->getResourceId()->willReturn(1);
     $versionRepository->getNewestVersionIdForResource('Product', 1)->willReturn(3);
     $this->isPurgeable($version, [])->shouldReturn(true);
 }
 function it_purges_the_versions_according_to_an_advisor_and_returns_the_number_of_purged_versions(VersionRepositoryInterface $versionRepository, BulkRemoverInterface $versionRemover, BulkObjectDetacherInterface $objectDetacher, VersionPurgerAdvisorInterface $advisor, VersionInterface $versionToBePurged, VersionInterface $versionNotSupported, VersionInterface $versionToNotPurge)
 {
     $versionToBePurged->getResourceName()->willReturn('products');
     $versionToBePurged->getId()->willReturn(1);
     $versionNotSupported->getResourceName()->willReturn('products');
     $versionNotSupported->getId()->willReturn(2);
     $versionToNotPurge->getResourceName()->willReturn('products');
     $versionToNotPurge->getId()->willReturn(3);
     $versionRepository->findPotentiallyPurgeableBy(Argument::type('array'))->willReturn([$versionToBePurged, $versionNotSupported, $versionToNotPurge]);
     $advisor->supports($versionToBePurged)->shouldBeCalled()->willReturn(true);
     $advisor->isPurgeable($versionToBePurged, Argument::type('array'))->shouldBeCalled()->willReturn(true);
     $advisor->supports($versionNotSupported)->shouldBeCalled()->willReturn(false);
     $advisor->isPurgeable($versionNotSupported, Argument::type('array'))->shouldNotBeCalled();
     $advisor->supports($versionToNotPurge)->shouldBeCalled()->willReturn(true);
     $advisor->isPurgeable($versionToNotPurge, Argument::type('array'))->shouldBeCalled()->willReturn(false);
     $this->addVersionPurgerAdvisor($advisor);
     $versionRemover->removeAll([$versionToBePurged, $versionNotSupported])->shouldBeCalled();
     $objectDetacher->detachAll([$versionToBePurged, $versionNotSupported])->shouldBeCalled();
     $objectDetacher->detach($versionToNotPurge)->shouldBeCalled();
     $this->purge([])->shouldReturn(2);
 }
 /**
  * {@inheritdoc}
  */
 public function isPurgeable(VersionInterface $version, array $options)
 {
     $newVersionId = $this->versionRepository->getNewestVersionIdForResource($version->getResourceName(), $version->getResourceId());
     return null === $newVersionId || $newVersionId !== $version->getId();
 }