From 987a029b51f747af1f9fd65b1d61c4b412e01d7c Mon Sep 17 00:00:00 2001 From: Loz Calver Date: Wed, 21 Jun 2017 14:57:12 +0100 Subject: [PATCH] Update logout step to use new logout form --- src/Context/LoginContext.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Context/LoginContext.php b/src/Context/LoginContext.php index dcf3f65..8d1f6a7 100644 --- a/src/Context/LoginContext.php +++ b/src/Context/LoginContext.php @@ -57,7 +57,21 @@ class LoginContext implements Context public function stepIAmNotLoggedIn() { $c = $this->getMainContext(); - $this->getMainContext()->getSession()->visit($c->joinUrlParts($c->getBaseUrl(), Security::logout_url())); + + // We're missing a security token, so we'll be presented with a form + $this->getMainContext()->getSession()->visit($c->joinUrlParts($c->getBaseUrl(), 'Security/logout/')); + + $page = $this->getMainContext()->getSession()->getPage(); + $form = $page->findById('LogoutForm_Form'); + assertNotNull($form, 'Logout form not found'); + + $submitButton = $form->find('css', '[type=submit]'); + $securityID = $form->find('css', '[name=SecurityID]'); + + assertNotNull($submitButton, 'Submit button on logout form not found'); + assertNotNull($securityID, 'CSRF token not found'); + + $submitButton->press(); } /**