/** * @test */ public function an_unacceptable_reference_logs_its_failure_reasons() { $this->reference->setProductId(ProductIds::INSIGHT)->setStatus(ApplicationStatuses::INCOMPLETE)->setHasCCJ(true)->setEmploymentStatus(EmploymentStatuses::UNEMPLOYED); $this->mockCreditReference->expects($this->any())->method('getScore')->willReturn(CreditScoreCriteriaLimits::MINIMUM_INSIGHT_CREDIT_SCORE - 1); // The reference has 4 reasons to fail acceptance. $this->insightCriteria->isSatisfiedBy($this->mockRrpReference); // 4 failing criteria tests should result in 4 logged failure messages. $this->assertEquals(4, count($this->insightCriteria->getNotSatisfiedText())); }
/** * @test */ public function criteria_is_not_satisfied_when_credit_score_is_unsatisfactory_for_insight() { $this->reference->setProductId(ProductIds::INSIGHT); $this->creditReference->setScore(CreditScoreCriteriaLimits::MINIMUM_INSIGHT_CREDIT_SCORE - 1); $this->assertFalse($this->criteria->isSatisfiedBy($this->rrpReference)); }
/** * Index action * * @return void */ public function indexAction() { if ($this->getSymfonyRequest()->query->has('uuid')) { $applicationUuId = $this->getSymfonyRequest()->query->get('uuid', null); // Get referencing case. Needed for the summary page $applicant = $this->getIrisAgentContext()->getReferencingApplicationClient()->getReferencingApplication(array('referencingApplicationUuId' => $applicationUuId)); $case = $this->getIrisAgentContext()->getReferencingCaseClient()->getReferencingCase(array('referencingCaseUuId' => $applicant->getReferencingCaseUuId())); $referencingApplication = new ReferencingApplication(); $referencingApplication->setProductId($applicant->getProductId())->setPolicyLength($applicant->getPolicyLength()); $this->getAgentGuarantorProgressiveStore()->setApplicantUuId($applicationUuId)->clearPrototypes()->addPrototype($case)->addPrototype($referencingApplication)->storePrototypes(); } $form = $this->getFormFactory()->create(new RootStepType(new ProductType($this->getAgentGuarantorProgressiveStore())), $this->getAgentGuarantorProgressiveStore()->fetch(self::MODEL_APPLICATION_CLASS), array('removeBack' => true, 'stepTypeOptions' => array('userLabel' => 'Guarantor'))); // Don't need productId for guarantors $form->get('step')->remove('productId')->remove('update'); if ($this->getSymfonyRequest()->isMethod('POST')) { $form->submit($this->getSymfonyRequest()); $this->getFormFlow()->setForm($form); if ($form->isValid()) { $object = null; try { $object = $this->getAgentGuarantorProgressiveStore()->store($form->getData()); } catch (ValidationException $e) { $this->getFormValidationErrorBinder()->bind($form, $e); $this->renderTwigView('/iris-add-guarantor/generic-step.html.twig', array('bodyTitle' => 'Guarantor Details', 'form' => $form->createView())); return; } // If we're completing by email if (CompletionMethodsOptions::COMPLETE_BY_EMAIL == $object->getCompletionMethod()) { /** @var \Barbondev\IRISSDK\IndividualApplication\ReferencingCase\Model\ReferencingCase $case */ $case = $this->getAgentGuarantorProgressiveStore()->getPrototypeByClass(self::MODEL_CASE_CLASS); /** @var \Barbondev\IRISSDK\IndividualApplication\ReferencingApplication\Model\ReferencingApplication $case */ $application = $this->getAgentGuarantorProgressiveStore()->getPrototypeByClass(self::MODEL_APPLICATION_CLASS); // Submit application $submitSuccess = $this->getContainer()->get('iris.referencing.application.submission.application_submitter')->submit($application->getReferencingApplicationUuId(), '/iris-referencing/submission-error?errorCode={error_code}'); // Was the submission a success? if ($submitSuccess) { // Do we need to collect another tenant? $difference = $this->getContainer()->get('iris.referencing.application.application_counter')->getApplicantCountDifference($application->getReferencingApplicationUuId(), $case->getNumberOfTenants()); // Check the difference if ($difference > 0) { // Clear and add existing prototypes $this->getAgentGuarantorProgressiveStore()->clearPrototypes()->initialisePrototypes()->storePrototypes(); // Yes, we need to collect another tenant, redirect $this->_helper->redirector->gotoUrlAndExit(sprintf('/iris-add-tenant?uuid=%s&difference=%d&numberOfTenants=%d', $case->getReferencingCaseUuId(), $difference, $case->getNumberOfTenants())); } // Redirect to success $this->_helper->redirector->gotoUrlAndExit('/iris-add-guarantor/email-to-guarantor-success'); } else { // Something went wrong $this->_helper->redirector->gotoUrlAndExit(sprintf('/iris-referencing/failed-to-submit-application?uuid=%s', $application->getReferencingApplicationUuId())); } } if ($object) { if ($form->get('next')->isClicked()) { $this->_helper->redirector->gotoUrlAndExit($this->getFormFlow()->getNextUrl()); } } } } $this->renderTwigView('/iris-add-guarantor/generic-step.html.twig', array('bodyTitle' => 'Guarantor Details', 'form' => $form->createView())); }
/** * Return combinations containing invalid insight, invalid enhance and valid optimum references. * * @return array */ public function getInvalidInsightInvalidEnhanceValidOptimumCombinations() { $insightProduct = new Product(); $insightProduct->setName('Insight'); $insight = new ReferencingApplication(); $insight->setProduct($insightProduct); $insight->setProductId(ProductIds::INSIGHT); $insight->setRentShare(0); $enhanceProduct = new Product(); $enhanceProduct->setName('Enhance'); $enhance = new ReferencingApplication(); $enhance->setProduct($enhanceProduct); $enhance->setProductId(ProductIds::ENHANCE); $enhance->setRentShare(0); $optimumProduct = new Product(); $optimumProduct->setName('Optimum'); $optimum = new ReferencingApplication(); $optimum->setProduct($optimumProduct); $optimum->setProductId(ProductIds::OPTIMUM); $optimum->setRentShare(1); return array(array(array($insight, $optimum)), array(array($enhance, $optimum)), array(array($insight, $enhance, $optimum))); }