nhance/tests/unit/ICICILombardControllerTest.php

77 lines
3.1 KiB
PHP

<?php
namespace Tests\unit;
use App\Controllers\ICICILombardController;
use CodeIgniter\Test\CIUnitTestCase;
class ICICILombardControllerTest extends CIUnitTestCase
{
public function testFormatPolicyDataBuildsExpectedBatchPayload(): void
{
$controller = new ICICILombardController();
// Sample rows matching createEnrollmentBatch query output shape.
$input = [
[
'policyNumber' => '4016/PPN/A/O/53185987/00/000',
'CDBGAccountNumber' => 'CD-MUM-0026',
'MemberEmpId' => 'EMPID3625567',
'DOJ' => '2019-03-21',
'InsuredName' => 'sanjeev',
'DOB' => '1993-07-07',
'Relationship' => 'SELF',
'Gender' => 'male',
'DOC' => '25-Jan-2026',
'SumInsured' => '500000',
'EmailId' => 'sanjeev@GMAIL.COM',
],
[
'policyNumber' => '4016/PPN/A/O/53185987/00/000',
'CDBGAccountNumber' => 'CD-MUM-0026',
'MemberEmpId' => 'EMPID3625567',
'DOJ' => '2019-03-21',
'InsuredName' => 'bhavya',
'DOB' => '1970-08-08',
'Relationship' => 'MOTHER',
'Gender' => 'female',
'DOC' => '25-Jan-2026',
'SumInsured' => null,
'EmailId' => 'bhavya@GMAIL.COM',
],
];
$result = $controller->formatPolicyData($input);
$this->assertIsArray($result);
$this->assertSame('4016/PPN/A/O/53185987/00/000', $result['PolicyNumber']);
$this->assertSame('CD-MUM-0026', $result['CDBGAccountNumber']);
$this->assertMatchesRegularExpression(
'/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i',
$result['CorrelationId']
);
$this->assertCount(2, $result['MemberDetails']);
$first = $result['MemberDetails'][0];
$this->assertSame('EMPID3625567', $first['EmployeeMemberId']);
$this->assertSame('21-MAR-2019', $first['DOJ']);
$this->assertSame('sanjeev', $first['InsuredName']);
$this->assertSame('7-JUL-1993', $first['DOB']);
$this->assertSame('SELF', $first['Relationship']);
$this->assertSame('MALE', $first['Gender']);
$this->assertSame('25-JAN-2026', $first['DOC']);
$this->assertSame('500000', $first['SumInsured']);
$this->assertSame('sanjeev@GMAIL.COM', $first['EmailId']);
$this->assertSame('A', $first['FlagStatus']);
$second = $result['MemberDetails'][1];
$this->assertSame('bhavya', $second['InsuredName']);
$this->assertSame('8-AUG-1970', $second['DOB']);
$this->assertSame('MOTHER', $second['Relationship']);
$this->assertSame('FEMALE', $second['Gender']);
$this->assertSame('25-JAN-2026', $second['DOC']);
$this->assertNull($second['SumInsured']);
}
}