Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CaptchaOnContactUsTest.php
Go to the documentation of this file.
1 <?php
8 
11 use Magento\Contact\Test\Page\ContactIndex;
12 use Magento\Mtf\TestCase\Injectable;
13 use Magento\Mtf\TestStep\TestStepFactory;
14 
26 class CaptchaOnContactUsTest extends Injectable
27 {
33  private $stepFactory;
34 
40  private $assertCaptcha;
41 
47  private $contactIndex;
48 
54  private $configData;
55 
64  public function __inject(
65  TestStepFactory $stepFactory,
66  AssertCaptchaFieldOnContactUsForm $assertCaptcha,
67  ContactIndex $contactIndex
68  ) {
69  $this->stepFactory = $stepFactory;
70  $this->assertCaptcha = $assertCaptcha;
71  $this->contactIndex = $contactIndex;
72  }
73 
81  public function test(
82  Comment $comment,
83  $configData
84  ) {
85  $this->configData = $configData;
86 
87  // Preconditions
88  $this->stepFactory->create(
89  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
90  ['configData' => $this->configData]
91  )->run();
92 
93  $this->contactIndex->open();
94  $this->assertCaptcha->processAssertRegisterForm($this->contactIndex);
95  $this->contactIndex->getContactUs()->fill($comment);
96  $this->contactIndex->getContactUs()->reloadCaptcha();
97  $this->contactIndex->getContactUs()->sendComment();
98  }
99 
105  public function tearDown()
106  {
107  $this->stepFactory->create(
108  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
109  ['configData' => $this->configData, 'rollback' => true]
110  )->run();
111  }
112 }
__inject(TestStepFactory $stepFactory, AssertCaptchaFieldOnContactUsForm $assertCaptcha, ContactIndex $contactIndex)