/**
  * Determine if $reference satisfies this Criteria.
  *
  * @param RentRecoveryPlusReference $reference
  * @return bool
  */
 public function isSatisfiedBy(RentRecoveryPlusReference $reference)
 {
     $reference = $this->rrpGuarantorReferenceCreator->getGuarantor($reference);
     $recommendationStatus = $reference->getDecisionDetails()->getRecommendation()->getStatus();
     if (RecommendationStatuses::ACCEPTABLE != $recommendationStatus && RecommendationStatuses::ACCEPTABLE_WITH_CONDITION != $recommendationStatus) {
         $this->setNotSatisfiedText(sprintf('Reference %s has the following outcome: %s', $reference->getParent()->getReferenceNumber(), $recommendationStatus))->setIsSatisfied(false);
         return false;
     }
     return true;
 }
 /**
  * @test
  * @covers RrpGuarantorReferenceCreator::getGuarantor
  * @covers RrpGuarantorReferenceCreator::createGuarantor
  */
 public function guarantor_is_only_retrieved_from_web_service_once_on_consecutive_calls()
 {
     $reference = new ReferencingApplication();
     $rrpReference = new RentRecoveryPlusReference();
     $rrpReference->setParent($reference);
     // Prepare the first call which will talk to web service
     $mockResult = new Collection(array(new ReferencingApplication()));
     $this->mockReferencingApplicationClient->expects($this->once())->method('getReferencingApplicationGuarantors')->willReturn($mockResult);
     $rrpGuarantorReferenceCreator = new RrpGuarantorReferenceCreator($this->mockClientRegistry, $this->mockDecisionDetailsRetriever);
     $rrpGuarantorReferenceCreator->getGuarantor($rrpReference);
     // Second time around, assert that we don't talk to web service, and still return a RentRecoveryPlusReference
     $this->mockClientRegistry->expects($this->never())->method($this->anything());
     $this->assertInstanceOf('RRP\\Model\\RentRecoveryPlusReference', $rrpGuarantorReferenceCreator->getGuarantor($rrpReference));
 }