get('Magento\Framework\Registry'); $registry->unregister('isSecureArea'); $registry->register('isSecureArea', true); /** @var $customer \Magento\Customer\Model\Customer*/ $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Customer\Model\Customer'); $customer->load(1); if ($customer->getId()) { $customer->delete(); } $registry->unregister('isSecureArea'); $registry->register('isSecureArea', false); /* Unlock account if it was locked for tokens retrieval */ /** @var RequestThrottler $throttler */ $throttler = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(RequestThrottler::class); $throttler->resetAuthenticationFailuresCount('customer@example.com', RequestThrottler::USER_TYPE_CUSTOMER);