Skip to content

Commit

Permalink
Use WordHat login method
Browse files Browse the repository at this point in the history
  • Loading branch information
composer-lock-update committed Jul 5, 2019
1 parent 6ca4b7b commit 7894a43
Showing 1 changed file with 6 additions and 32 deletions.
38 changes: 6 additions & 32 deletions tests/behat/helper_classes/Contexts/PantheonContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private function getAdminURL()
{
return $this->getWordpressParameter('site_url') . ('/wp-admin/index.php');
}

private function getFrontendURL()
{
return $this->getMinkParameter('base_url');
Expand Down Expand Up @@ -131,7 +131,7 @@ private function setPreviousURL()
// Set previous URL to the current URL
$this->previous_url = $session->getCurrentUrl();
}

private function goToPreviousURL()
{
// Verify the session
Expand Down Expand Up @@ -200,37 +200,11 @@ protected function loginAsWordPressAdmin()
{
// Get the admin user
$found_user = $this->getAdminUser();

// Verify the session
$session = $this->verifySession();

// Stash the current URL to redirect back to
$this->setPreviousURL();

// Log out if currently logged in
if( $this->loggedIn() ) {
$this->logOut();
}

// Go to the login page
$this->visitPath('wp-login.php');

// Fill in login form details
$this->login_page->setUserName($found_user['username']);
$this->login_page->setUserPassword($found_user['password']);
$this->login_page->setRememberMe();

// Submit the login form
$this->login_page->submitLoginForm();
// Login to WordPress with the admin user details
$this->logIn($found_user['username'], $found_user['password']);

FailureContext::addState('username', $found_user['username']);

if (! $this->loggedIn()) {
throw new ExpectationException('[W803] The user ' . $found_user['username'] . ' could not be logged-in.', $this->getSession()->getDriver());
}

// Go back to the previous URL
$this->goToPreviousURL();
}

/**
Expand All @@ -249,10 +223,10 @@ public function clearPantheonCache()

// Verify the session
$session = $this->verifySession();

// Get the current page from the session
$page = $session->getPage();

// Are we currently logged in?
$logged_in = $this->loggedIn();

Expand Down

0 comments on commit 7894a43

Please sign in to comment.