Skip to content

Commit

Permalink
Merge pull request #2955 in SW/shopware from sw-12519/5.0/fix-mink-te…
Browse files Browse the repository at this point in the history
…st to 5.0

* commit 'f2cf6e61fd3b52feb80581333be1ae9ef76d2919':
  SW-12519 - Fixed failed mink test
  • Loading branch information
Marcel Schmäing committed Sep 11, 2015
2 parents 945009d + f2cf6e6 commit bb21f99
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
32 changes: 20 additions & 12 deletions tests/Mink/features/account_changeLoginData.feature
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,33 @@ Feature: Successful changes of login data

@forgot @login
Scenario: I can request a new password, if I forgot it
When I log in successful as "Max Mustermann" with email "test@example.com" and password "shopware"
And I log me out
And I follow "Mein Konto"
And I follow "Passwort vergessen?"
When I follow "Passwort vergessen?"

Then I should see "Passwort vergessen? Hier können Sie ein neues Passwort anfordern"
And I should see "Wir senden Ihnen ein neues, zufällig generiertes Passwort. Dieses können Sie dann im Kundenbereich ändern."
Then I should see "Passwort vergessen?"
And I should see "Wir senden Ihnen eine Bestätigungsmail. Klicken Sie auf den darin enthaltenen Link, um Ihr Passwort zu ändern."

When I fill in "email" with "test@example.info"
And I press "Passwort anfordern"
And I press "E-Mail senden"
Then I should see "Diese E-Mail-Adresse ist uns nicht bekannt"

When I fill in "email" with "test@example.com"
And I press "Passwort anfordern"
Then I should see "Ihr neues Passwort wurde Ihnen zugeschickt"
And I press "E-Mail senden"
Then I should see "Wir haben Ihnen eine Bestätigungsmail gesendet."

When I follow "Mein Konto"
And I log in successful as "Max Mustermann" with email "test@example.com" and password "shopware"
And I log me out
And I click the link in my latest email

Then I should see "Wenn Sie das Passwort für Ihr Konto vergessen haben, können Sie hier ein neues definieren. Wenn Sie das neue Passwort speichern, wird Ihr altes Passwort ungültig."

When I fill in "password" with "shopware5"
And I fill in "passwordConfirmation" with "shopware5"
And I press "Passwort ändern"
Then I should see "Ihr Passwort wurde erfolgreich geändert."
And I should be on the page "Account"

When I log me out
And I go to the page "Account"
And I log in with email "test@example.com" and password "shopware"
Then I should see "Ihre Zugangsdaten konnten keinem Benutzer zugeordnet werden"

When I log in with email "test@example.com" and password "shopware"
Then I should see "Zu viele fehlgeschlagene Versuche. Ihr Account wurde vorübergehend deaktivert - bitte probieren Sie es in einigen Minuten erneut!"
5 changes: 5 additions & 0 deletions tests/Mink/features/bootstrap/Page/Emotion/Homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,9 @@ public function checkArticle(Article $article, array $data)

Helper::throwException($message);
}

public function getShopUrl()
{
return $this->getUrl();
}
}
14 changes: 13 additions & 1 deletion tests/Mink/features/bootstrap/ShopwareContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,23 @@ public function iUnsubscribeTheNewsletter($email = null)
*/
public function iConfirmTheLinkInTheEmail($limit = 1)
{
$sql = 'SELECT hash FROM s_core_optin ORDER BY id DESC LIMIT ' . $limit;
$sql = 'SELECT `type`, `hash` FROM `s_core_optin` ORDER BY `id` DESC LIMIT ' . $limit;
$hashes = $this->getContainer()->get('db')->fetchAll($sql);

$session = $this->getSession();
$link = $session->getCurrentUrl();

foreach ($hashes as $optin) {
if ($optin['type'] === 'password') {
$mask = '%saccount/resetPassword/hash/%s';
$link = $this->getPage('Homepage')->getShopUrl();

$confirmationLink = sprintf($mask, $link, $optin['hash']);
$session->visit($confirmationLink);
return;
}
}

$query = parse_url($link, PHP_URL_QUERY);
$anchor = strpos($link, "#");

Expand Down

0 comments on commit bb21f99

Please sign in to comment.