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

« back to all changes in this revision

Viewing changes to tests/selenium/suites/MovePageTestCase.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 MovePageTestCase extends SeleniumTestCase {
 
31
 
 
32
    // Verify move(rename) wiki page
 
33
    public function testMovePage() {
 
34
 
 
35
        $newPage = "mypage99";
 
36
        $displayName = "Mypage99";
 
37
 
 
38
        $this->open( $this->getUrl() .
 
39
                '/index.php?title=Main_Page&action=edit' );
 
40
        $this->type( "searchInput", $newPage );
 
41
        $this->click( "searchGoButton" );
 
42
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
43
        $this->click( "link=".$displayName );
 
44
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
45
        $this->type( SeleniumTestConstants::TEXT_EDITOR, $newPage." text" );
 
46
        $this->click( SeleniumTestConstants::BUTTON_SAVE );
 
47
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
48
 
 
49
        // Verify link 'Move' available
 
50
        $this->assertTrue($this->isElementPresent( "link=Move" ));
 
51
 
 
52
        $this->click( "link=Move" );
 
53
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
54
 
 
55
        // Verify correct page name displayed under 'Move Page' field
 
56
        $this->assertEquals($displayName,
 
57
                $this->getText("//table[@id='mw-movepage-table']/tbody/tr[1]/td[2]/strong/a"));
 
58
        $movePageName = $this->getText( "//table[@id='mw-movepage-table']/tbody/tr[1]/td[2]/strong/a" );
 
59
 
 
60
        // Verify 'To new title' field has current page name as the default name
 
61
        $newTitle =  $this->getValue( "wpNewTitle" );
 
62
        $correct = strstr( $movePageName , $newTitle  );
 
63
        $this->assertEquals( $correct, true );
 
64
 
 
65
        $this->type( "wpNewTitle", $displayName );
 
66
        $this->click( "wpMove" );
 
67
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
68
 
 
69
        // Verify warning message for the same source and destination titles
 
70
        $this->assertEquals( "Source and destination titles are the same; cannot move a page over itself.",
 
71
                $this->getText("//div[@id='bodyContent']/p[4]/strong" ));
 
72
 
 
73
        // Verify warning message for the blank title
 
74
        $this->type( "wpNewTitle", "" );
 
75
        $this->click( "wpMove" );
 
76
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
77
 
 
78
        // Verify warning message for the blank title
 
79
        $this->assertEquals( "The requested page title was invalid, empty, or an incorrectly linked inter-language or inter-wiki title. It may contain one or more characters which cannot be used in titles.",
 
80
                $this->getText( "//div[@id='bodyContent']/p[4]/strong" ));
 
81
 
 
82
        //  Verify warning messages for the invalid titles
 
83
        $this->type( "wpNewTitle", "# < > [ ] | { }" );
 
84
        $this->click( "wpMove" );
 
85
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
86
        $this->assertEquals( "The requested page title was invalid, empty, or an incorrectly linked inter-language or inter-wiki title. It may contain one or more characters which cannot be used in titles.",
 
87
                $this->getText( "//div[@id='bodyContent']/p[4]/strong" ));
 
88
 
 
89
        $this->type( "wpNewTitle", $displayName."move" );
 
90
        $this->click( "wpMove" );
 
91
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
92
 
 
93
        // Verify move success message displayed correctly
 
94
        $this->assertEquals( "\"".$displayName."\" has been moved to \"".$displayName."move"."\"",
 
95
                $this->getText( "//div[@id='bodyContent']/p[1]/b" ));
 
96
 
 
97
        $this->type( "searchInput", $newPage."move" );
 
98
        $this->click( "searchGoButton" );
 
99
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
100
 
 
101
        // Verify search using new page name
 
102
        $this->assertEquals( $displayName."move", $this->getText( "firstHeading" ));
 
103
 
 
104
        $this->type( "searchInput", $newPage );
 
105
        $this->click( "searchGoButton" );
 
106
        $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
 
107
 
 
108
        // Verify search using old page name
 
109
        $redirectPageName = $this->getText( "//*[@id='contentSub']" );
 
110
        $this->assertEquals( "(Redirected from ".$displayName.")" , $redirectPageName );
 
111
 
 
112
        // newpage delete
 
113
        $this->deletePage( $newPage."move" );
 
114
        $this->deletePage( $newPage );
 
115
    }
 
116
}
 
117