/** * Mock the web service call to IRIS. Doing so involves mocking the chained outcomes, beginning at the \ClientRegistry. */ public function setUp() { // Mock the chain: $clientRegistry->getAgentContext()->getReferencingApplicationClient()->getReferencingApplicationGuarantors() $this->mockClientRegistry = $this->getMockBuilder('Barbondev\\IRISSDK\\Common\\ClientRegistry\\ClientRegistry')->setMethods(array('getAgentContext'))->getMock(); $mockAgentContext = $this->getMockBuilder('Barbondev\\IRISSDK\\Common\\ClientRegistry\\Context\\AgentContext')->setMethods(array('getReferencingApplicationClient'))->getMock(); $this->mockReferencingApplicationClient = $this->getMockBuilder('Barbondev\\IRISSDK\\IndividualApplication\\ReferencingApplication\\ReferencingApplicationClient')->disableOriginalConstructor()->setMethods(array('getReferencingApplicationGuarantors'))->getMock(); $this->mockClientRegistry->expects($this->once())->method('getAgentContext')->willReturn($mockAgentContext); $mockAgentContext->expects($this->once())->method('getReferencingApplicationClient')->willReturn($this->mockReferencingApplicationClient); // Mock the chain: $decisionDetailsRetriever->getDecisionDetails() $this->mockDecisionDetailsRetriever = $this->getMockBuilder('RRP\\Utility\\DecisionDetailsRetriever')->disableOriginalConstructor()->setMethods(array('getDecisionDetails'))->getMock(); $this->mockDecisionDetailsRetriever->expects($this->once())->method('getDecisionDetails')->willReturn(new ReferencingDecisionDetails()); }
/** * @test */ public function gets_and_sets_the_decision_details_on_the_new_object() { $referenceFoundInSession = new ReferencingApplication(); // Set up the necessary scenarios for finding a valid reference in the session... $this->mockSessionHolder->expects($this->once())->method('getReferenceFromSession')->willReturn($referenceFoundInSession); // And assert that 'getDecisionDetails' will be called on the $decisionDetailsRetriever... $this->mockDecisionDetailsRetriever->expects($this->once())->method('getDecisionDetails')->with($referenceFoundInSession)->willReturn(new ReferencingDecisionDetails()); // And also assert that 'setDecisionDetails' will be called on the RentRecoveryPlusReference object. $this->mockRentRecoveryPlusReference->method('setParent')->will($this->returnSelf()); $this->mockRentRecoveryPlusReference->expects($this->once())->method('setDecisionDetails'); // Trigger the test $transformer = new ReferenceNumberToReferenceObjectTransformer($this->mockDecisionDetailsRetriever, $this->mockSessionHolder, $this->mockRentRecoveryPlusReference); $transformer->reverseTransform('HLT999'); }