From ff32ee6154a8765d4d17a0674cc3ae7d327f9948 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 13 Jan 2023 08:09:23 +0000 Subject: [PATCH] Fix issues found during abnormal scenario testing. #727 --- src/Command/TestInsuranceConnectorCommand.php | 5 ++--- src/Service/InsuranceClientDataValidator.php | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Command/TestInsuranceConnectorCommand.php b/src/Command/TestInsuranceConnectorCommand.php index f8ac2d7f..6cdb8f8c 100644 --- a/src/Command/TestInsuranceConnectorCommand.php +++ b/src/Command/TestInsuranceConnectorCommand.php @@ -23,7 +23,7 @@ class TestInsuranceConnectorCommand extends Command { $this->setName('test:create-insurance-application') ->setDescription('Test create insurance application service.') - ->setHelp('Test the create insuranace application service.'); + ->setHelp('Test the create insurance application service.'); } public function __construct(InsuranceConnector $insurance, InsuranceDataValidator $ins_validator) @@ -52,7 +52,7 @@ class TestInsuranceConnectorCommand extends Command ->setAddressBarangay('Legaspi Village') ->setAddressCity('Makati City') ->setAddressProvince('Metro Manila') - ->setZipcode('1200') + ->setZipcode(1200) ->setMobileNumber('09171234567') ->setEmailAddress('test.resq@gmail.com'); @@ -83,5 +83,4 @@ class TestInsuranceConnectorCommand extends Command return 0; } - } diff --git a/src/Service/InsuranceClientDataValidator.php b/src/Service/InsuranceClientDataValidator.php index 501e311d..33a01ddd 100644 --- a/src/Service/InsuranceClientDataValidator.php +++ b/src/Service/InsuranceClientDataValidator.php @@ -86,7 +86,7 @@ class InsuranceDataValidator } // zipcode is required - if (empty($client_data->getZipcode())) + if ($client_data->getZipcode() == 0) { $error = 'Zipcode is required.'; return $error; @@ -141,6 +141,8 @@ class InsuranceDataValidator return $error; } + // TODO: the insurance api doesn't care if the plate number is valid. + // do we still check for valid plate number? // plate number is correct format $is_valid_plate = $this->checkPlateNumber($client_data->getPlateNumber()); if (!($is_valid_plate)) @@ -180,7 +182,7 @@ class InsuranceDataValidator // motor vehicle type id is required if ($client_data->getMvTypeID() == 0) { - $error = 'Motor vehicle type must be set.'; + $error = 'Motor vehicle type is required.'; return $error; } @@ -220,7 +222,7 @@ class InsuranceDataValidator // check line type and flag_public combination // if line type is MCOC/private motorcycle, flag_public should be false // if line type is LCOC/public motorcycle, flag_public should be true - if ($client_data->getLine() == LineType::PRIVATE_MOTORCYCLE) + if ($client_data->getLine() == LineType::PRIVATE_MOTORCYCLE) { if ($client_data->isPublic()) { @@ -229,7 +231,8 @@ class InsuranceDataValidator } } - if ($client_data->getLine() == LineType::PUBLIC_MOTORCYCLE) + if (($client_data->getLine() == LineType::PUBLIC_MOTORCYCLE) || + ($client_data->getLine() == LineType::COMMERCIAL_VEHICLE)) { if (!($client_data->isPublic())) {