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