Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
ResetPasswordTest Class Reference
Inheritance diagram for ResetPasswordTest:
AbstractBackendController AbstractController

Public Member Functions

 testResetPasswordSuccess ()
 
 testResetPasswordWithPost ()
 
 testResetPasswordMinTimeError ()
 
 testResetPasswordLimitError ()
 
 testResetPasswordWithSecurityViolationException ()
 
- Public Member Functions inherited from AbstractBackendController
 assertSessionMessages (\PHPUnit\Framework\Constraint\Constraint $constraint, $messageType=null, $messageManagerClass=\Magento\Framework\Message\Manager::class)
 
 testAclHasAccess ()
 
 testAclNoAccess ()
 
- Public Member Functions inherited from AbstractController
 getRequest ()
 
 getResponse ()
 
 assert404NotFound ()
 
 assertHeaderPcre ($headerName, $valueRegex)
 
 assertRedirect (\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)
 

Protected Attributes

 $baseControllerUrl = 'http://localhost/index.php/backend/customer/index/'
 
- Protected Attributes inherited from AbstractBackendController
 $_session
 
 $_auth
 
 $resource = null
 
 $uri = null
 
 $httpMethod
 
- Protected Attributes inherited from AbstractController
 $_runCode = ''
 
 $_runScope = 'store'
 
 $_runOptions = []
 
 $_request
 
 $_response
 
 $_objectManager
 
 $_assertSessionErrors = false
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractBackendController
 setUp ()
 
 _getAdminCredentials ()
 
 tearDown ()
 
- Protected Member Functions inherited from AbstractController
 _getBootstrap ()
 
 setUp ()
 
 tearDown ()
 
 assertPostConditions ()
 
 getMessages ( $messageType=null, $messageManagerClass=\Magento\Framework\Message\Manager::class)
 

Detailed Description

ResetPassword controller test.

@magentoAppArea adminhtml

Definition at line 15 of file ResetPasswordTest.php.

Member Function Documentation

◆ testResetPasswordLimitError()

testResetPasswordLimitError ( )

Checks reset password functionality with default restrictive limited number password reset requests and customer reset request event. Admin is not affected by this security check, so reset password email must be sent.

@magentoConfigFixture current_store customer/password/max_number_password_reset_requests 1 @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 0 @magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 95 of file ResetPasswordTest.php.

96  {
97  $this->passwordResetRequestEventCreate(
98  \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
99  );
100  $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET);
101  $this->dispatch('backend/customer/index/resetPassword');
102  $this->assertSessionMessages(
103  $this->equalTo(['The customer will receive an email with a link to reset password.']),
104  \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
105  );
106  $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl . 'edit'));
107  }
assertRedirect(\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)
dispatch(\Magento\Framework\App\RequestInterface $request)
assertSessionMessages(\PHPUnit\Framework\Constraint\Constraint $constraint, $messageType=null, $messageManagerClass=\Magento\Framework\Message\Manager::class)

◆ testResetPasswordMinTimeError()

testResetPasswordMinTimeError ( )

Checks reset password functionality with default restrictive min time between password reset requests and customer reset request event. Admin is not affected by this security check, so reset password email must be sent.

@magentoConfigFixture current_store customer/password/max_number_password_reset_requests 0 @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 10 @magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 72 of file ResetPasswordTest.php.

73  {
74  $this->passwordResetRequestEventCreate(
75  \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
76  );
77  $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET);
78  $this->dispatch('backend/customer/index/resetPassword');
79  $this->assertSessionMessages(
80  $this->equalTo(['The customer will receive an email with a link to reset password.']),
81  \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
82  );
83  $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl . 'edit'));
84  }
assertRedirect(\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)
dispatch(\Magento\Framework\App\RequestInterface $request)
assertSessionMessages(\PHPUnit\Framework\Constraint\Constraint $constraint, $messageType=null, $messageManagerClass=\Magento\Framework\Message\Manager::class)

◆ testResetPasswordSuccess()

testResetPasswordSuccess ( )

Checks reset password functionality with no restrictive settings and customer reset request event. Admin is not affected by this security check, so reset password email must be sent.

@magentoConfigFixture current_store customer/password/limit_password_reset_requests_method 0 @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 0 @magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 32 of file ResetPasswordTest.php.

33  {
34  $this->passwordResetRequestEventCreate(
35  \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
36  );
37  $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET);
38  $this->dispatch('backend/customer/index/resetPassword');
39  $this->assertSessionMessages(
40  $this->equalTo(['The customer will receive an email with a link to reset password.']),
41  \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
42  );
43  $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl . 'edit'));
44  }
assertRedirect(\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)
dispatch(\Magento\Framework\App\RequestInterface $request)
assertSessionMessages(\PHPUnit\Framework\Constraint\Constraint $constraint, $messageType=null, $messageManagerClass=\Magento\Framework\Message\Manager::class)

◆ testResetPasswordWithPost()

testResetPasswordWithPost ( )

Checks reset password functionality cannot be performed with POST request

@magentoConfigFixture current_store customer/password/limit_password_reset_requests_method 0 @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 0 @magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 53 of file ResetPasswordTest.php.

54  {
55  $this->passwordResetRequestEventCreate(
56  \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
57  );
58  $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST);
59  $this->dispatch('backend/customer/index/resetPassword');
60  $this->assertEquals('noroute', $this->getRequest()->getControllerName());
61  }
dispatch(\Magento\Framework\App\RequestInterface $request)

◆ testResetPasswordWithSecurityViolationException()

testResetPasswordWithSecurityViolationException ( )

Checks reset password functionality with default settings, customer and admin reset request events.

@magentoConfigFixture current_store customer/password/limit_password_reset_requests_method 1 @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 10 @magentoConfigFixture current_store contact/email/recipient_email hello.nosp@m.@exa.nosp@m.mple..nosp@m.com @magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 117 of file ResetPasswordTest.php.

118  {
119  $this->passwordResetRequestEventCreate(
120  \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
121  );
122  $this->passwordResetRequestEventCreate(
123  \Magento\Security\Model\PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST
124  );
125  $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET);
126  $this->dispatch('backend/customer/index/resetPassword');
127  $this->assertSessionMessages(
128  $this->equalTo(['The customer will receive an email with a link to reset password.']),
129  \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
130  );
131  $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl . 'edit'));
132  }
assertRedirect(\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)
dispatch(\Magento\Framework\App\RequestInterface $request)
assertSessionMessages(\PHPUnit\Framework\Constraint\Constraint $constraint, $messageType=null, $messageManagerClass=\Magento\Framework\Message\Manager::class)

Field Documentation

◆ $baseControllerUrl

$baseControllerUrl = 'http://localhost/index.php/backend/customer/index/'
protected

Definition at line 22 of file ResetPasswordTest.php.


The documentation for this class was generated from the following file: