Skip to content

Commit 5f45aa0

Browse files
committed
ACP2E-3501: VAPT: Business Logic Error - future date as customer date of birth
1 parent 838a448 commit 5f45aa0

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

app/code/Magento/Customer/Model/Validator/Dob.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
use Magento\Store\Model\StoreManagerInterface;
1313

1414
/**
15-
* Customer name fields validator.
15+
* Customer dob field validator.
1616
*/
1717
class Dob extends AbstractValidator
1818
{
1919
/**
2020
* @var \DateTime
2121
*/
22-
private $currentDate;
22+
private \DateTime $currentDate;
2323

2424
/**
2525
* @var StoreManagerInterface
2626
*/
27-
private $storeManager;
27+
private StoreManagerInterface $storeManager;
2828

2929
/**
3030
* @param StoreManagerInterface $storeManager
@@ -41,7 +41,7 @@ public function __construct(StoreManagerInterface $storeManager)
4141
* @param Customer $customer
4242
* @return bool
4343
*/
44-
public function isValid($customer)
44+
public function isValid($customer): bool
4545
{
4646
if (!$this->isValidDob($customer->getDob(), $customer->getStoreId())) {
4747
parent::_addMessages([['dob' => 'The Date of Birth should not be greater than today.']]);
@@ -57,7 +57,7 @@ public function isValid($customer)
5757
* @param int $storeId
5858
* @return bool
5959
*/
60-
private function isValidDob($dobValue, $storeId)
60+
private function isValidDob(?string $dobValue, int $storeId): bool
6161
{
6262
if ($dobValue != null) {
6363

dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,9 @@ public function testCreateCustomerWithDateOfBirthInFuture()
240240
$this->customerHelper->createSampleCustomerDataObject(),
241241
\Magento\Customer\Api\Data\CustomerInterface::class
242242
);
243-
$futureDob = '14-12-2044';
243+
$date = new \DateTime();
244+
$date->modify('+1 month');
245+
$futureDob = $date->format('Y-m-d');
244246
$customerDataArray['dob'] = $futureDob;
245247
$requestData = ['customer' => $customerDataArray, 'password' => CustomerHelper::PASSWORD];
246248
try {

0 commit comments

Comments
 (0)