/home/alixis5/integrate.sellofinance.com/tests/Unit
NameSizeModeActions
Controllers/-0755rm
Models/-0755rm
Repositories/-0755rm
Services/-0755rm
AuthServiceResponseTest.php7500644editdlrm
OnboardingServiceTest.php50710644editdlrm
Edit: /home/alixis5/integrate.sellofinance.com/tests/Unit/OnboardingServiceTest.php (5071B)
profileRepo = $this->createMock(CustomerProfileRepository::class); $this->employmentRepo = $this->createMock(CustomerEmploymentRepository::class); $this->financialRepo = $this->createMock(CustomerFinancialProfileRepository::class); $this->addressRepo = $this->createMock(CustomerAddressRepository::class); $this->consentRepo = $this->createMock(CustomerConsentRepository::class); $this->preferenceRepo = $this->createMock(CustomerPreferenceRepository::class); $this->appUserRepo = $this->createMock(AppUserRepository::class); $this->service = new OnboardingService( $this->profileRepo, $this->employmentRepo, $this->financialRepo, $this->addressRepo, $this->consentRepo, $this->preferenceRepo, $this->appUserRepo, ); } public function test_step1_patches_customer_profile(): void { $this->profileRepo ->expects($this->once()) ->method('update') ->with('prof-001', $this->callback(function (array $data): bool { return $data['profileType'] === 'individual' && $data['nationality'] === 'AE' && $data['dependentsCount'] === 2 && $data['onboardingStep'] === 1; })); $this->service->saveStep('prof-001', 'user-001', 1, [ 'profileType' => 'individual', 'nationality' => 'AE', 'residencyCountry' => 'AE', 'dateOfBirth' => '1990-05-15', 'gender' => 'male', 'maritalStatus' => 'married', 'dependentsCount' => 2, ]); } public function test_step2_upserts_employment_and_mirrors_profile(): void { $this->employmentRepo ->expects($this->once()) ->method('upsertByProfileId') ->with('prof-001', $this->callback(function (array $data): bool { return $data['employmentType'] === 'privateSector' && $data['salaryTransfer'] === true; })); $this->profileRepo ->expects($this->once()) ->method('update') ->with('prof-001', $this->callback(function (array $data): bool { return $data['employmentStatus'] === 'salaried' && $data['onboardingStep'] === 2; })); $this->service->saveStep('prof-001', 'user-001', 2, [ 'employmentStatus' => 'salaried', 'employmentType' => 'privateSector', 'salaryTransfer' => true, 'employerName' => 'ADNOC', 'jobTitle' => 'Engineer', 'employerCategory' => 'listed', 'workSinceDate' => '2018-01-01', ]); } public function test_step3_upserts_financial_profile_and_consent(): void { $this->financialRepo ->expects($this->once()) ->method('upsertByProfileId') ->with('prof-001', $this->anything()); $this->consentRepo ->expects($this->once()) ->method('upsertByProfileIdAndType') ->with('prof-001', 'creditBureau', $this->anything()); $this->profileRepo ->expects($this->once()) ->method('update') ->with('prof-001', $this->callback(function (array $data): bool { return isset($data['monthlyIncome']) && $data['onboardingStep'] === 3; })); $this->service->saveStep('prof-001', 'user-001', 3, [ 'declaredMonthlyIncome' => 15000, 'monthlyIncomeCurrency' => 'AED', 'fixedObligations' => 2000, 'existingInstallments' => 1500, 'existingBankCustomer' => true, 'creditConsentGiven' => true, ]); } public function test_invalid_step_throws(): void { $this->expectException(\InvalidArgumentException::class); $this->service->saveStep('prof-001', 'user-001', 6, []); } }