Skip to content

Commit 87ce321

Browse files
author
Volodymyr Kublytskyi
committed
Fixed static tests failure (refactoring to avoid very long lines)
1 parent c2ff321 commit 87ce321

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -531,17 +531,8 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
531531
$this->getEmailNotification()->passwordResetConfirmation($customer);
532532
break;
533533
default:
534-
throw new InputException(
535-
__(
536-
'Invalid value of "%value" provided for the %fieldName field. Possible values are %template1 or %template2.',
537-
[
538-
'value' => $template,
539-
'fieldName' => 'template',
540-
'template1' => AccountManagement::EMAIL_REMINDER,
541-
'template2' => AccountManagement::EMAIL_RESET
542-
]
543-
)
544-
);
534+
$this->handleUnknownTemplate($template);
535+
break;
545536
}
546537
return true;
547538
} catch (MailException $e) {
@@ -551,6 +542,25 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
551542
return false;
552543
}
553544

545+
/**
546+
* Handle not supported template
547+
*
548+
* @param string $template
549+
* @throws InputException
550+
*/
551+
private function handleUnknownTemplate($template)
552+
{
553+
throw new InputException(__(
554+
'Invalid value of "%value" provided for the %fieldName field. Possible values: %template1 or %template2.',
555+
[
556+
'value' => $template,
557+
'fieldName' => 'template',
558+
'template1' => AccountManagement::EMAIL_REMINDER,
559+
'template2' => AccountManagement::EMAIL_RESET
560+
]
561+
));
562+
}
563+
554564
/**
555565
* {@inheritdoc}
556566
*/

app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,10 +1173,6 @@ public function testInitiatePasswordResetEmailReset()
11731173
$this->assertTrue($this->accountManagement->initiatePasswordReset($email, $template));
11741174
}
11751175

1176-
/**
1177-
* @expectedException \Magento\Framework\Exception\InputException
1178-
* @expectedExceptionMessage Invalid value of "" provided for the template field. Possible values are email_reminder or email_reset.
1179-
*/
11801176
public function testInitiatePasswordResetNoTemplate()
11811177
{
11821178
$storeId = 1;
@@ -1192,6 +1188,10 @@ public function testInitiatePasswordResetNoTemplate()
11921188

11931189
$this->prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash);
11941190

1191+
$this->expectException(\Magento\Framework\Exception\InputException::class);
1192+
$this->expectExceptionMessage(
1193+
'Invalid value of "" provided for the template field. Possible values: email_reminder or email_reset.'
1194+
);
11951195
$this->accountManagement->initiatePasswordReset($email, $template);
11961196
}
11971197

0 commit comments

Comments
 (0)