File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
app/code/Magento/Customer/Model/Validator
dev/tests/api-functional/testsuite/Magento/Customer/Api Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 1212use Magento \Store \Model \StoreManagerInterface ;
1313
1414/**
15- * Customer name fields validator.
15+ * Customer dob field validator.
1616 */
1717class 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
Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments