Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CaseCaptchaIsRequiredAfterFailedLoginAttemptsTest.php
Go to the documentation of this file.
1 <?php
7 
9 
16 {
22  public function testBackendLoginActionWithInvalidCaptchaReturnsError()
23  {
25  \Magento\Backend\Model\UrlInterface::class
26  )->turnOffSecretKey();
27 
29  $formKey = $this->_objectManager->get(\Magento\Framework\Data\Form\FormKey::class);
30  $post = [
31  'login' => [
34  ],
35  'captcha' => ['backend_login' => 'some_unrealistic_captcha_value'],
36  'form_key' => $formKey->getFormKey(),
37  ];
38  $this->getRequest()->setPostValue($post);
39  $this->dispatch('backend/admin');
40  $this->assertSessionMessages($this->equalTo([(string)__('Incorrect CAPTCHA.')]), MessageInterface::TYPE_ERROR);
42  \Magento\Backend\Model\UrlInterface::class
43  );
44  $backendUrlModel->turnOffSecretKey();
45  $url = $backendUrlModel->getUrl('admin');
46  $this->assertRedirect($this->stringStartsWith($url));
47  }
48 }
assertRedirect(\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)
__()
Definition: __.php:13