Skip to content
Snippets Groups Projects
Commit b3abba05 authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #3138611: Fix Notice: Undefined index: NOT_EXISTED_USER in...

Issue #3138611: Fix Notice: Undefined index: NOT_EXISTED_USER in VarbaseContext by replacing the captured notice with an exception lookup message for better automated testing reports
parent 233d6461
No related branches found
No related tags found
No related merge requests found
......@@ -72,21 +72,28 @@ class VarbaseContext extends RawDrupalContext implements SnippetAcceptingContext
*/
public function iAmloggedInUserWithTheUser($username) {
try {
$password = $this->users[$username];
}
catch (Exception $e) {
throw new \Exception("Password not found for '$username'.");
if (isset($this->users[$username])) {
try {
$password = $this->users[$username];
}
catch (Exception $e) {
throw new \Exception("Password not found for '$username'.");
}
if ($this->loggedIn()) {
$this->logout();
}
$element = $this->getSession()->getPage();
$this->getSession()->visit($this->locatePath('/user'));
$element->fillField('edit-name', $username);
$element->fillField('edit-pass', $password);
$submit = $element->findButton('op');
$submit->click();
}
if ($this->loggedIn()) {
$this->logout();
else {
throw new \Exception("The '$username' user name is wrong or it was not listed in the list of default testing users.");
}
$element = $this->getSession()->getPage();
$this->getSession()->visit($this->locatePath('/user'));
$element->fillField('edit-name', $username);
$element->fillField('edit-pass', $password);
$submit = $element->findButton('op');
$submit->click();
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment