Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
LoginUser.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Mtf\Factory\Factory;
11 use Magento\Mtf\Fixture\FixtureInterface;
12 use Magento\Mtf\Handler\Ui;
13 
19 class LoginUser extends Ui
20 {
27  public function persist(FixtureInterface $fixture = null)
28  {
29  if (null === $fixture) {
30  $fixture = Factory::getFixtureFactory()->getMagentoBackendAdminSuperAdmin();
31  }
32 
34  $loginPage = Factory::getPageFactory()->getAdminAuthLogin();
35  $loginForm = $loginPage->getLoginBlock();
36  $adminHeaderPanel = $loginPage->getHeaderBlock();
37  if (!$loginForm->isVisible() && !$adminHeaderPanel->isVisible()) {
38  //We are currently not in the admin area.
39  $loginPage->open();
40  }
41 
42  if (!$adminHeaderPanel || !$adminHeaderPanel->isVisible()) {
43  $loginPage->open();
44  if ($adminHeaderPanel->isVisible()) {
45  return;
46  }
47  $loginForm->fill($fixture);
48  $loginForm->submit();
49  $loginPage->waitForHeaderBlock();
50  }
51  }
52 }