/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
dev/tests/integration/testsuite/Magento/Captcha/Observer/ResetAttemptForFrontendObserverTest.php
60 строк
2 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 10:44
22 окт 2025, 10:44
264bea2
Код
Авторство
О чём код?
<?php /** * Copyright 2018 Adobe * All Rights Reserved. */ declare(strict_types=1); namespace Magento\Captcha\Observer; use Magento\Captcha\Model\ResourceModel\Log as CaptchaLog; use Magento\Captcha\Model\ResourceModel\LogFactory; use Magento\Customer\Model\Customer; use Magento\Customer\Model\CustomerFactory; use Magento\Framework\Event\ManagerInterface; use Magento\Framework\ObjectManagerInterface; /** * Class ResetAttemptForFrontendObserverTest * * Test for checking that the customer login attempts are removed after a successful login */ class ResetAttemptForFrontendObserverTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerInterface */ private $objectManager; protected function setUp(): void { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); } /** * @magentoDataFixture Magento/Captcha/_files/failed_logins_frontend.php */ public function testSuccessfulLoginRemovesFailedAttempts() { $customerEmail = 'mageuser@dummy.com'; $customerFactory = $this->objectManager->get(CustomerFactory::class); $captchaLogFactory = $this->objectManager->get(LogFactory::class); $eventManager = $this->objectManager->get(ManagerInterface::class); /** @var Customer $customer */ $customer = $customerFactory->create(); $customer->setEmail($customerEmail); $eventManager->dispatch( 'customer_customer_authenticated', ['model' => $customer, 'password' => 'some_password'] ); /** * @var CaptchaLog $captchaLog */ $captchaLog = $captchaLogFactory->create(); self::assertEquals(0, $captchaLog->countAttemptsByUserLogin($customerEmail)); } }