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