ResetAttemptForFrontendAccountEditObserverTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Captcha\Observer;
  8. use Magento\Captcha\Model\ResourceModel\Log as CaptchaLog;
  9. use Magento\Captcha\Model\ResourceModel\LogFactory;
  10. use Magento\Framework\Event\ManagerInterface;
  11. use Magento\Framework\ObjectManagerInterface;
  12. /**
  13. * Class ResetAttemptForFrontendAccountEditObserverTest
  14. *
  15. * Test for checking that the customer login attempts are removed after account details edit
  16. */
  17. class ResetAttemptForFrontendAccountEditObserverTest extends \PHPUnit\Framework\TestCase
  18. {
  19. /**
  20. * @var ObjectManagerInterface
  21. */
  22. private $objectManager;
  23. public function setUp()
  24. {
  25. $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  26. }
  27. /**
  28. * @magentoDataFixture Magento/Captcha/_files/failed_logins_frontend.php
  29. */
  30. public function testAccountEditRemovesFailedAttempts()
  31. {
  32. $customerEmail = 'mageuser@dummy.com';
  33. $captchaLogFactory = $this->objectManager->get(LogFactory::class);
  34. $eventManager = $this->objectManager->get(ManagerInterface::class);
  35. $eventManager->dispatch(
  36. 'customer_account_edited',
  37. ['email' => $customerEmail]
  38. );
  39. /**
  40. * @var CaptchaLog $captchaLog
  41. */
  42. $captchaLog = $captchaLogFactory->create();
  43. self::assertEquals(0, $captchaLog->countAttemptsByUserLogin($customerEmail));
  44. }
  45. }