Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AccountManagementTest.php
Go to the documentation of this file.
1 <?php
8 
14 
18 class AccountManagementTest extends \PHPUnit\Framework\TestCase
19 {
23  protected $model;
24 
28  protected $request;
29 
33  protected $securityManager;
34 
38  protected $accountManagement;
39 
43  private $scope;
44 
48  protected $objectManager;
49 
54  public function setUp()
55  {
56  $this->objectManager = new ObjectManager($this);
57 
58  $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class);
59 
60  $this->securityManager = $this->createPartialMock(
61  \Magento\Security\Model\SecurityManager::class,
62  ['performSecurityCheck']
63  );
64 
65  $this->accountManagement = $this->createMock(AccountManagement::class);
66  $this->scope = $this->createMock(ScopeInterface::class);
67  }
68 
75  public function testBeforeInitiatePasswordReset($area, $passwordRequestEvent, $expectedTimes)
76  {
79 
80  $this->model = $this->objectManager->getObject(
81  \Magento\Security\Model\Plugin\AccountManagement::class,
82  [
83  'passwordRequestEvent' => $passwordRequestEvent,
84  'request' => $this->request,
85  'securityManager' => $this->securityManager,
86  'scope' => $this->scope
87  ]
88  );
89 
90  $this->scope->expects($this->once())
91  ->method('getCurrentScope')
92  ->willReturn($area);
93 
94  $this->securityManager->expects($this->exactly($expectedTimes))
95  ->method('performSecurityCheck')
96  ->with($passwordRequestEvent, $email)
97  ->willReturnSelf();
98 
99  $this->model->beforeInitiatePasswordReset(
100  $this->accountManagement,
101  $email,
102  $template
103  );
104  }
105 
110  {
111  return [
115  // This should never happen, but let's cover it with tests
117  ];
118  }
119 }
testBeforeInitiatePasswordReset($area, $passwordRequestEvent, $expectedTimes)
$email
Definition: details.phtml:13
$template
Definition: export.php:12