Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CaptchaOnAdminLoginTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Mtf\TestCase\Injectable;
11 use Magento\Mtf\TestStep\TestStepFactory;
14 use Magento\Captcha\Test\Page\Captcha\AdminAuthLoginWithCaptcha;
15 use Magento\Backend\Test\Page\Adminhtml\SystemConfigEdit;
16 
31 class CaptchaOnAdminLoginTest extends Injectable
32 {
38  private $adminAuthWithCaptcha;
39 
45  private $systemConfigEditPage;
46 
52  private $adminAuthLogin;
53 
59  private $stepFactory;
60 
66  private $assertCaptcha;
67 
78  public function __inject(
79  SystemConfigEdit $systemConfigEditPage,
80  AdminAuthLoginWithCaptcha $adminAuthWithCaptcha,
81  TestStepFactory $stepFactory,
82  AdminAuthLogin $adminAuthLogin,
83  AssertCaptchaFieldOnBackend $assertCaptcha
84  ) {
85  $this->systemConfigEditPage = $systemConfigEditPage;
86  $this->adminAuthWithCaptcha = $adminAuthWithCaptcha;
87  $this->stepFactory = $stepFactory;
88  $this->adminAuthLogin = $adminAuthLogin;
89  $this->assertCaptcha = $assertCaptcha;
90  }
91 
99  public function test(User $customAdmin, $configData)
100  {
101  $customAdmin->persist();
102 
103  // Preconditions
104  $this->stepFactory->create(
105  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
106  ['configData' => $configData]
107  )->run();
108  $this->adminAuthLogin->open();
109  $this->adminAuthWithCaptcha->getLoginBlockWithCaptcha()->fill($customAdmin);
110  $this->assertCaptcha->processAssert($this->adminAuthWithCaptcha);
111  $this->adminAuthWithCaptcha->getLoginBlockWithCaptcha()->submit();
112  }
113 
119  public function tearDown()
120  {
121  $this->systemConfigEditPage->open();
122  $this->systemConfigEditPage->getForm()
123  ->getGroup('admin', 'captcha')->setValue('admin', 'captcha', 'enable', 'No');
124  $this->systemConfigEditPage->getPageActions()->save();
125  }
126 }
__inject(SystemConfigEdit $systemConfigEditPage, AdminAuthLoginWithCaptcha $adminAuthWithCaptcha, TestStepFactory $stepFactory, AdminAuthLogin $adminAuthLogin, AssertCaptchaFieldOnBackend $assertCaptcha)