Skip to content

Commit

Permalink
#21394: Static test fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
p-bystritsky committed May 30, 2019
1 parent 1e55b13 commit 1ff6e0f
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 64 deletions.
39 changes: 24 additions & 15 deletions app/code/Magento/Customer/Model/AccountManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,15 +652,17 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
*/
private function handleUnknownTemplate($template)
{
throw new InputException(__(
'Invalid value of "%value" provided for the %fieldName field. Possible values: %template1 or %template2.',
[
'value' => $template,
'fieldName' => 'template',
'template1' => AccountManagement::EMAIL_REMINDER,
'template2' => AccountManagement::EMAIL_RESET
]
));
throw new InputException(
__(
'Invalid value of "%value" provided for the %fieldName field. Possible values: %template1 or %template2.',
[
'value' => $template,
'fieldName' => 'template',
'template1' => AccountManagement::EMAIL_REMINDER,
'template2' => AccountManagement::EMAIL_RESET
]
)
);
}

/**
Expand Down Expand Up @@ -1314,13 +1316,20 @@ protected function sendEmailTemplate(
}

$transport = $this->transportBuilder->setTemplateIdentifier($templateId)
->setTemplateOptions(['area' => Area::AREA_FRONTEND, 'store' => $storeId])
->setTemplateOptions(
[
'area' => Area::AREA_FRONTEND,
'store' => $storeId
]
)
->setTemplateVars($templateParams)
->setFrom($this->scopeConfig->getValue(
$sender,
ScopeInterface::SCOPE_STORE,
$storeId
))
->setFrom(
$this->scopeConfig->getValue(
$sender,
ScopeInterface::SCOPE_STORE,
$storeId
)
)
->addTo($email, $this->customerViewHelper->getCustomerName($customer))
->getTransport();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,13 @@ public function testWithConfirmCreatePostAction()
$this->dispatch('customer/account/createPost');
$this->assertRedirect($this->stringContains('customer/account/index/'));
$this->assertSessionMessages(
$this->equalTo([
'You must confirm your account. Please check your email for the confirmation link or '
$this->equalTo(
[
'You must confirm your account. Please check your email for the confirmation link or '
. '<a href="http://localhost/index.php/customer/account/confirmation/'
. '?email=test2%40email.com">click here</a> for a new link.'
]),
]
),
MessageInterface::TYPE_SUCCESS
);
}
Expand All @@ -333,10 +335,14 @@ public function testExistingEmailCreatePostAction()
$this->dispatch('customer/account/createPost');
$this->assertRedirect($this->stringContains('customer/account/create/'));
$this->assertSessionMessages(
$this->equalTo(['There is already an account with this email address. ' .
'If you are sure that it is your email address, ' .
'<a href="http://localhost/index.php/customer/account/forgotpassword/">click here</a>' .
' to get your password and access your account.', ]),
$this->equalTo(
[
'There is already an account with this email address. ' .
'If you are sure that it is your email address, ' .
'<a href="http://localhost/index.php/customer/account/forgotpassword/">click here</a>' .
' to get your password and access your account.',
]
),
MessageInterface::TYPE_ERROR
);
}
Expand All @@ -348,7 +354,11 @@ public function testInactiveUserConfirmationAction()
{
$this->getRequest()
->setMethod('POST')
->setPostValue(['email' => '[email protected]']);
->setPostValue(
[
'email' => '[email protected]',
]
);

$this->dispatch('customer/account/confirmation');
$this->assertRedirect($this->stringContains('customer/account/index'));
Expand All @@ -365,14 +375,20 @@ public function testActiveUserConfirmationAction()
{
$this->getRequest()
->setMethod('POST')
->setPostValue([
'email' => '[email protected]',
]);
->setPostValue(
[
'email' => '[email protected]',
]
);

$this->dispatch('customer/account/confirmation');
$this->assertRedirect($this->stringContains('customer/account/index'));
$this->assertSessionMessages(
$this->equalTo(['This email does not require confirmation.']),
$this->equalTo(
[
'This email does not require confirmation.',
]
),
MessageInterface::TYPE_SUCCESS
);
}
Expand Down Expand Up @@ -413,9 +429,11 @@ public function testForgotPasswordPostWithBadEmailAction()
{
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()
->setPostValue([
'email' => 'bad@email',
]);
->setPostValue(
[
'email' => 'bad@email',
]
);

$this->dispatch('customer/account/forgotPasswordPost');
$this->assertRedirect($this->stringContains('customer/account/forgotpassword'));
Expand All @@ -434,10 +452,12 @@ public function testResetPasswordPostNoTokenAction()
->setParam('id', 1)
->setParam('token', '8ed8677e6c79e68b94e61658bd756ea5')
->setMethod('POST')
->setPostValue([
'password' => 'new-password',
'password_confirmation' => 'new-password',
]);
->setPostValue(
[
'password' => 'new-password',
'password_confirmation' => 'new-password',
]
);

$this->dispatch('customer/account/resetPasswordPost');
$this->assertRedirect($this->stringContains('customer/account/'));
Expand All @@ -457,10 +477,12 @@ public function testResetPasswordPostAction()
->setQueryValue('id', 1)
->setQueryValue('token', '8ed8677e6c79e68b94e61658bd756ea5')
->setMethod('POST')
->setPostValue([
'password' => 'new-Password1',
'password_confirmation' => 'new-Password1',
]);
->setPostValue(
[
'password' => 'new-Password1',
'password_confirmation' => 'new-Password1',
]
);

$this->dispatch('customer/account/resetPasswordPost');
$this->assertRedirect($this->stringContains('customer/account/login'));
Expand All @@ -483,8 +505,11 @@ public function testEditAction()
$this->assertEquals(200, $this->getResponse()->getHttpResponseCode(), $body);
$this->assertContains('<div class="field field-name-firstname required">', $body);
// Verify the password check box is not checked
$this->assertContains('<input type="checkbox" name="change_password" id="change-password" '
. 'data-role="change-password" value="1" title="Change&#x20;Password" class="checkbox" />', $body);
$this->assertContains(
'<input type="checkbox" name="change_password" id="change-password" '
. 'data-role="change-password" value="1" title="Change&#x20;Password" class="checkbox" />',
$body
);
}

/**
Expand Down Expand Up @@ -528,14 +553,16 @@ public function testEditPostAction()
$this->login(1);
$this->getRequest()
->setMethod('POST')
->setPostValue([
'form_key' => $this->_objectManager->get(FormKey::class)->getFormKey(),
'firstname' => 'John',
'lastname' => 'Doe',
'email' => '[email protected]',
'change_email' => 1,
'current_password' => 'password'
]);
->setPostValue(
[
'form_key' => $this->_objectManager->get(FormKey::class)->getFormKey(),
'firstname' => 'John',
'lastname' => 'Doe',
'email' => '[email protected]',
'change_email' => 1,
'current_password' => 'password'
]
);

$this->dispatch('customer/account/editPost');

Expand Down Expand Up @@ -666,16 +693,18 @@ public function testWrongConfirmationEditPostAction()
$this->login(1);
$this->getRequest()
->setMethod('POST')
->setPostValue([
'form_key' => $this->_objectManager->get(FormKey::class)->getFormKey(),
'firstname' => 'John',
'lastname' => 'Doe',
'email' => '[email protected]',
'change_password' => 1,
'current_password' => 'password',
'password' => 'new-password',
'password_confirmation' => 'new-password-no-match',
]);
->setPostValue(
[
'form_key' => $this->_objectManager->get(FormKey::class)->getFormKey(),
'firstname' => 'John',
'lastname' => 'Doe',
'email' => '[email protected]',
'change_password' => 1,
'current_password' => 'password',
'password' => 'new-password',
'password_confirmation' => 'new-password-no-match',
]
);

$this->dispatch('customer/account/editPost');

Expand Down Expand Up @@ -859,13 +888,15 @@ private function getCustomerByEmail($email)
*/
private function prepareRequest()
{
$post = new Parameters([
'form_key' => $this->_objectManager->get(FormKey::class)->getFormKey(),
'login' => [
'username' => '[email protected]',
'password' => 'password'
$post = new Parameters(
[
'form_key' => $this->_objectManager->get(FormKey::class)->getFormKey(),
'login' => [
'username' => '[email protected]',
'password' => 'password'
]
]
]);
);
$request = $this->getRequest();
$formKey = $this->_objectManager->get(FormKey::class);
$request->setParam('form_key', $formKey->getFormKey());
Expand Down

0 comments on commit 1ff6e0f

Please sign in to comment.