customer_rollback.php 1.0 KB

1234567891011121314151617181920212223242526272829
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. use Magento\Integration\Model\Oauth\Token\RequestThrottler;
  7. /** @var \Magento\Framework\Registry $registry */
  8. $registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
  9. $registry->unregister('isSecureArea');
  10. $registry->register('isSecureArea', true);
  11. /** @var $customer \Magento\Customer\Model\Customer*/
  12. $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  13. \Magento\Customer\Model\Customer::class
  14. );
  15. $customer->load(1);
  16. if ($customer->getId()) {
  17. $customer->delete();
  18. }
  19. $registry->unregister('isSecureArea');
  20. $registry->register('isSecureArea', false);
  21. /* Unlock account if it was locked for tokens retrieval */
  22. /** @var RequestThrottler $throttler */
  23. $throttler = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(RequestThrottler::class);
  24. $throttler->resetAuthenticationFailuresCount('customer@example.com', RequestThrottler::USER_TYPE_CUSTOMER);