Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ResetAttemptForFrontendObserverTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 use Magento\Captcha\Model\ResourceModel\LogFactory;
13 use Magento\Customer\Model\CustomerFactory;
16 
22 class ResetAttemptForFrontendObserverTest extends \PHPUnit\Framework\TestCase
23 {
27  private $objectManager;
28 
29  public function setUp()
30  {
32  }
33 
37  public function testSuccesfulLoginRemovesFailedAttempts()
38  {
40  $customerFactory = $this->objectManager->get(CustomerFactory::class);
41  $captchaLogFactory = $this->objectManager->get(LogFactory::class);
42  $eventManager = $this->objectManager->get(ManagerInterface::class);
43 
45  $customer = $customerFactory->create();
46  $customer->setEmail($customerEmail);
47 
48  $eventManager->dispatch(
49  'customer_customer_authenticated',
50  ['model' => $customer, 'password' => 'some_password']
51  );
52 
56  $captchaLog = $captchaLogFactory->create();
57 
58  self::assertEquals(0, $captchaLog->countAttemptsByUserLogin($customerEmail));
59  }
60 }
$customer
Definition: customers.php:11