]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - maintenance/tests/selenium/suites/CreateAccountTestCase.php
MediaWiki 1.17.0
[autoinstalls/mediawiki.git] / maintenance / tests / selenium / suites / CreateAccountTestCase.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 CreateAccountTestCase extends SeleniumTestCase {
31
32     // Change these values before run the test
33     private $userName = "yourname4000";
34     private $password = "yourpass4000";
35
36     // Verify 'Log in/create account' link existance in Main page.
37     public function testMainPageLink() {
38
39         $this->click( "link=Log out" );
40         $this->waitForPageToLoad( "30000" );
41
42         $this->open( $this->getUrl().'/index.php?title=Main_Page' );
43         $this->assertTrue($this->isElementPresent( "link=Log in / create account" ));
44     }
45
46     // Verify 'Create an account' link existance in 'Log in / create account' Page.
47     public function testCreateAccountPageLink() {
48
49         $this->click( "link=Log out" );
50         $this->waitForPageToLoad( "30000" );
51
52         $this->open( $this->getUrl().'/index.php?title=Main_Page' );
53
54         // click Log in / create account link to open Log in / create account' page
55         $this->click( "link=Log in / create account" );
56         $this->waitForPageToLoad( "30000" );
57         $this->assertTrue($this->isElementPresent( "link=Create an account" ));
58     }
59
60     // Verify Create account
61     public function testCreateAccount() {
62
63         $this->click( "link=Log out" );
64         $this->waitForPageToLoad( "30000" );
65
66         $this->open( $this->getUrl().'/index.php?title=Main_Page' );
67
68         $this->click( "link=Log in / create account" );
69         $this->waitForPageToLoad( "30000" );
70
71         $this->click( "link=Create an account" );
72         $this->waitForPageToLoad( "30000" );
73
74         // Verify for blank user name
75         $this->type( "wpName2", "" );
76         $this->click( "wpCreateaccount" );
77         $this->waitForPageToLoad( "30000" );
78         $this->assertEquals( "Login error\n You have not specified a valid user name.",
79                 $this->getText( "//div[@id='bodyContent']/div[4]" ));
80
81         // Verify for invalid user name
82         $this->type( "wpName2", "@" );
83         $this->click("wpCreateaccount" );
84         $this->waitForPageToLoad( "30000" );
85         $this->assertEquals( "Login error\n You have not specified a valid user name.",
86                 $this->getText( "//div[@id='bodyContent']/div[4]" ));
87
88         // start of test for blank password
89         $this->type( "wpName2", $this->userName);
90         $this->type( "wpPassword2", "" );
91         $this->click( "wpCreateaccount" );
92         $this->waitForPageToLoad( "30000" );
93         $this->assertEquals( "Login error\n Passwords must be at least 1 character.",
94                 $this->getText("//div[@id='bodyContent']/div[4]" ));
95
96         $this->type( "wpName2", $this->userName );
97         $this->type( "wpPassword2", $this->password );
98         $this->click( "wpCreateaccount" );
99         $this->waitForPageToLoad( "30000" );
100         $this->assertEquals( "Login error\n The passwords you entered do not match.",
101                 $this->getText( "//div[@id='bodyContent']/div[4]" ));
102
103         $this->type( "wpName2", $this->userName );
104         $this->type( "wpPassword2", $this->password );
105         $this->type( "wpRetype", $this->password );
106         $this->click( "wpCreateaccount" );
107         $this->waitForPageToLoad( "30000 ");
108
109         // Verify successful account creation for valid combination of 'Username', 'Password', 'Retype password'
110         $this->assertEquals( "Welcome, ".ucfirst( $this->userName )."!",
111                 $this->getText( "Welcome,_".ucfirst( $this->userName )."!" ));
112     }
113 }
114