Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CaptchaOnStoreFrontLoginTest.php
Go to the documentation of this file.
1 <?php
8 
11 use Magento\Customer\Test\Page\CustomerAccountLogin;
12 use Magento\Mtf\Fixture\FixtureFactory;
13 use Magento\Mtf\TestCase\Injectable;
14 use Magento\Mtf\TestStep\TestStepFactory;
15 
29 class CaptchaOnStoreFrontLoginTest extends Injectable
30 {
36  private $stepFactory;
37 
43  private $assertCaptcha;
44 
50  private $customerAccountLogin;
51 
57  private $fixtureFactory;
58 
64  private $configData;
65 
75  public function __inject(
76  TestStepFactory $stepFactory,
77  AssertCaptchaFieldOnStorefront $assertCaptcha,
78  CustomerAccountLogin $customerAccountLogin,
79  FixtureFactory $fixtureFactory
80  ) {
81  $this->stepFactory = $stepFactory;
82  $this->assertCaptcha = $assertCaptcha;
83  $this->customerAccountLogin = $customerAccountLogin;
84  $this->fixtureFactory = $fixtureFactory;
85  }
86 
95  public function test(
97  $configData,
98  $captcha
99  ) {
100  $this->configData = $configData;
101 
102  // Preconditions
103  $this->stepFactory->create(
104  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
105  ['configData' => $this->configData]
106  )->run();
107  $customer->persist();
108 
109  $customerData = $customer->getData();
110  $customerData['group_id'] = [
111  'customerGroup' => $customer->getDataFieldConfig('group_id')['source']->getCustomerGroup()
112  ];
113  $customerData['captcha'] = $captcha;
114 
115  $customer = $this->fixtureFactory->createByCode('customer', ['data' => $customerData]);
116 
117  $this->customerAccountLogin->open();
118  $this->assertCaptcha->processAssert($this->customerAccountLogin);
119  $this->customerAccountLogin->getLoginBlockWithCaptcha()->reloadCaptcha();
120  $this->customerAccountLogin->getLoginBlockWithCaptcha()->login($customer);
121  }
122 
128  public function tearDown()
129  {
130  $this->stepFactory->create(
131  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
132  ['configData' => $this->configData, 'rollback' => true]
133  )->run();
134  }
135 }
$customerData
$customer
Definition: customers.php:11
__inject(TestStepFactory $stepFactory, AssertCaptchaFieldOnStorefront $assertCaptcha, CustomerAccountLogin $customerAccountLogin, FixtureFactory $fixtureFactory)
$captcha
Definition: default.phtml:12