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 12
12
use Magento \Store \Model \StoreManagerInterface ;
13
13
14
14
/**
15
- * Customer name fields validator.
15
+ * Customer dob field validator.
16
16
*/
17
17
class Dob extends AbstractValidator
18
18
{
19
19
/**
20
20
* @var \DateTime
21
21
*/
22
- private $ currentDate ;
22
+ private \ DateTime $ currentDate ;
23
23
24
24
/**
25
25
* @var StoreManagerInterface
26
26
*/
27
- private $ storeManager ;
27
+ private StoreManagerInterface $ storeManager ;
28
28
29
29
/**
30
30
* @param StoreManagerInterface $storeManager
@@ -41,7 +41,7 @@ public function __construct(StoreManagerInterface $storeManager)
41
41
* @param Customer $customer
42
42
* @return bool
43
43
*/
44
- public function isValid ($ customer )
44
+ public function isValid ($ customer ): bool
45
45
{
46
46
if (!$ this ->isValidDob ($ customer ->getDob (), $ customer ->getStoreId ())) {
47
47
parent ::_addMessages ([['dob ' => 'The Date of Birth should not be greater than today. ' ]]);
@@ -57,7 +57,7 @@ public function isValid($customer)
57
57
* @param int $storeId
58
58
* @return bool
59
59
*/
60
- private function isValidDob ($ dobValue , $ storeId )
60
+ private function isValidDob (? string $ dobValue , int $ storeId ): bool
61
61
{
62
62
if ($ dobValue != null ) {
63
63
Original file line number Diff line number Diff line change @@ -240,7 +240,9 @@ public function testCreateCustomerWithDateOfBirthInFuture()
240
240
$ this ->customerHelper ->createSampleCustomerDataObject (),
241
241
\Magento \Customer \Api \Data \CustomerInterface::class
242
242
);
243
- $ futureDob = '14-12-2044 ' ;
243
+ $ date = new \DateTime ();
244
+ $ date ->modify ('+1 month ' );
245
+ $ futureDob = $ date ->format ('Y-m-d ' );
244
246
$ customerDataArray ['dob ' ] = $ futureDob ;
245
247
$ requestData = ['customer ' => $ customerDataArray , 'password ' => CustomerHelper::PASSWORD ];
246
248
try {
You can’t perform that action at this time.
0 commit comments