77282e4771577399529a9783aba3667d92131c5a
[lhc/web/wiklou.git] / tests / selenium / suites / EmailPasswordTestCase.php
1 <?php
2 /**
3 * Selenium server manager
4 *
5 * @file
6 * @ingroup Testing
7 * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
8 * http://www.calcey.com/
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * http://www.gnu.org/copyleft/gpl.html
24 */
25
26 class EmailPasswordTestCase extends SeleniumTestCase {
27 // change user name for each and every test (with in 24 hours)
28 private $userName = "test1";
29
30 public function testEmailPasswordButton() {
31 $this->click( SeleniumTestConstants::LINK_START . "Log out" );
32 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
33
34 $this->open( $this->getUrl() . '/index.php?title=Main_Page' );
35
36 // click Log in / create account link to open Log in / create account' page
37 $this->click( SeleniumTestConstants::LINK_START . "Log in / create account" );
38 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
39 $this->assertTrue( $this->isElementPresent( "wpMailmypassword" ) );
40 }
41
42 // Verify Email password functionality
43 public function testEmailPasswordMessages() {
44 $this->click( SeleniumTestConstants::LINK_START . "Log out" );
45 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
46
47 $this->open( $this->getUrl() . '/index.php?title=Main_Page' );
48
49 // click Log in / create account link to open Log in / create account' page
50 $this->click( SeleniumTestConstants::LINK_START . "Log in / create account" );
51 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
52
53 $this->type( "wpName1", "" );
54 $this->click( "wpMailmypassword" );
55 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
56 $this->assertEquals( "Login error\n You have not specified a valid user name.",
57 $this->getText( "//div[@id='bodyContent']/div[4]" ) );
58
59 $this->type( "wpName1", $this->userName );
60 $this->click( "wpMailmypassword" );
61 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
62
63 // Can not run on localhost
64 $this->assertEquals( "A new password has been sent to the e-mail address registered for " . ucfirst( $this->userName ) . ". Please log in again after you receive it.",
65 $this->getText( "//div[@id='bodyContent']/div[4]" ) );
66
67 $this->type( "wpName1", $this->userName );
68 $this->click( "wpMailmypassword" );
69 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
70 $this->assertEquals( "Login error\n A password reminder has already been sent, within the last 24 hours. To prevent abuse, only one password reminder will be sent per 24 hours.",
71 $this->getText( "//div[@id='bodyContent']/div[4]" ) );
72 }
73 }
74