eb25f8baa651543aeb23c9ea3fc9de2a1fb18ca7
[lhc/web/wiklou.git] / tests / selenium / suites / DeletePageAdminTestCase.php
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 DeletePageAdminTestCase extends SeleniumTestCase {
31 // Verify adding a new page
32 public function testDeletePage() {
33
34 $newPage = "new";
35 $displayName = "New";
36
37 $this->open( $this->getUrl() . '/index.php?title=Main_Page' );
38
39 $this->type( "searchInput", $newPage );
40 $this->click( "searchGoButton" );
41 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
42 $this->click( SeleniumTestConstants::LINK_START . $displayName );
43 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
44 $this->type( SeleniumTestConstants::TEXT_EDITOR, $newPage . " text" );
45 $this->click( SeleniumTestConstants::BUTTON_SAVE );
46
47 $this->open( $this->getUrl() .
48 '/index.php?title=Main_Page&action=edit' );
49 $this->click( SeleniumTestConstants::LINK_START . "Log out" );
50 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
51 $this->click( SeleniumTestConstants::LINK_START . "Log in / create account" );
52 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
53
54 $this->type( "wpName1", $this->selenium->getUser() );
55 $this->type( "wpPassword1", $this->selenium->getPass() );
56 $this->click( "wpLoginAttempt" );
57 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
58 $this->type( "searchInput", "new" );
59 $this->click( "searchGoButton" );
60 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
61
62 // Verify 'Delete' link displayed
63 $source = $this->gettext( SeleniumTestConstants::LINK_START . "Delete" );
64 $correct = strstr( $source, "Delete" );
65 $this->assertEquals( $correct, true );
66
67 $this->click( SeleniumTestConstants::LINK_START . "Delete" );
68 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
69
70 // Verify 'Delete' button available
71 $this->assertTrue( $this->isElementPresent( "wpConfirmB" ) );
72
73 $this->click( "wpConfirmB" );
74 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
75
76 // Verify 'Action complete' text displayed
77 $source = $this->gettext( "firstHeading" );
78 $correct = strstr( $source, "Action complete" );
79 $this->assertEquals( $correct, true );
80
81 // Verify '<Page Name> has been deleted. See deletion log for a record of recent deletions.' text displayed
82 $source = $this->gettext( "//div[@id='bodyContent']/p[1]" );
83 $correct = strstr( $source, "\"New\" has been deleted. See deletion log for a record of recent deletions." );
84 $this->assertEquals( $correct, true );
85 }
86 }