From 240142eb4217675007422d33f6558f1298bef940 Mon Sep 17 00:00:00 2001 From: Paurakh Sharma Humagain Date: Mon, 23 Apr 2018 12:08:32 +0545 Subject: [PATCH] UI test to disable user --- .../features/lib/DisabledUserPage.php | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/acceptance/features/lib/DisabledUserPage.php diff --git a/tests/acceptance/features/lib/DisabledUserPage.php b/tests/acceptance/features/lib/DisabledUserPage.php new file mode 100644 index 000000000000..f6c6d4c12a31 --- /dev/null +++ b/tests/acceptance/features/lib/DisabledUserPage.php @@ -0,0 +1,69 @@ + + * @copyright Copyright (c) 2018 Paurakh Sharma Humagain paurakh@jankaritech.com + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, + * as published by the Free Software Foundation; + * either version 3 of the License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + */ + +namespace Page; + +use Behat\Mink\Session; + +/** + * Disabled page. + */ +class DisabledUserPage extends OwncloudPage { + + /** + * @var string $path + */ + protected $path = '/index.php/login'; + protected $userDisabledXpath = ".//li[@class='error']"; + + /** + * + * @param Session $session + * @param int $timeout_msec + * + * @return void + * @throws \Exception + */ + public function waitTillPageIsLoaded( + Session $session, + $timeout_msec = STANDARDUIWAITTIMEOUTMILLISEC + ) { + $currentTime = \microtime(true); + $end = $currentTime + ($timeout_msec / 1000); + while ($currentTime <= $end) { + if ($this->findAll("xpath", $this->userDisabledXpath)) { + break; + } + \usleep(STANDARDSLEEPTIMEMICROSEC); + $currentTime = \microtime(true); + } + + if ($currentTime > $end) { + throw new \Exception( + __METHOD__ . " timeout waiting for page to load" + ); + } + + $this->waitForOutstandingAjaxCalls($session); + } +} + \ No newline at end of file