~ubuntu-branches/ubuntu/trusty/mediawiki/trusty

« back to all changes in this revision

Viewing changes to tests/selenium/suites/EmailPasswordTestCase.php

  • Committer: Package Import Robot
  • Author(s): Thorsten Glaser
  • Date: 2014-03-28 09:56:29 UTC
  • mfrom: (1.3.14)
  • Revision ID: package-import@ubuntu.com-20140328095629-1526y9tchdd507id
Tags: 1:1.19.14+dfsg-1
* New upstream security fix release (Closes: #742857):
  - (bug 62497) SECURITY: Add CSRF token on Special:ChangePassword
  - (bug 62467) Set a title for the context during import on the cli
* Use upstream-provided signing key bundle

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Selenium server manager
 
5
 *
 
6
 * @file
 
7
 * @ingroup Testing
 
8
 * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
 
9
 * http://www.calcey.com/ 
 
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 Testing
 
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( SeleniumTestConstants::LINK_START."Log out" );
 
38
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
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( SeleniumTestConstants::LINK_START."Log in / create account" );
 
44
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
45
        $this->assertTrue($this->isElementPresent( "wpMailmypassword" ));
 
46
    }
 
47
 
 
48
    // Verify Email password functionality
 
49
    public function testEmailPasswordMessages() {
 
50
 
 
51
        $this->click( SeleniumTestConstants::LINK_START."Log out" );
 
52
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
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( SeleniumTestConstants::LINK_START."Log in / create account" );
 
58
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
59
 
 
60
        $this->type( "wpName1", "" );
 
61
        $this->click( "wpMailmypassword" );
 
62
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
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