Merge "Clean up database cloning for tests."
[lhc/web/wiklou.git] / tests / selenium / suites / PageSearchTestCase.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 PageSearchTestCase extends SeleniumTestCase {
31
32 // Verify the functionality of the 'Go' button
33 public function testPageSearchBtnGo() {
34
35 $this->open( $this->getUrl() .
36 '/index.php?title=Main_Page&action=edit' );
37 $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "calcey qa" );
38 $this->click( "searchGoButton" );
39 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
40
41 // Verify no page matched with the entered search text
42 $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p/b" );
43 $correct = strstr ( $source, "Create the page \"Calcey qa\" on this wiki!" );
44 $this->assertEquals( $correct, true );
45
46 $this->click( "link=Calcey qa" );
47 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
48
49 $this->type( SeleniumTestConstants::TEXT_EDITOR , "Calcey QA team" );
50 $this->click( "wpSave" );
51 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
52
53 }
54
55 // Verify the functionality of the 'Search' button
56 public function testPageSearchBtnSearch() {
57
58 $this->open( $this->getUrl() .
59 '/index.php?title=Main_Page&action=edit' );
60 $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey web" );
61 $this->click( SeleniumTestConstants::BUTTON_SEARCH );
62 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
63
64 // Verify no page is available as the search text
65 $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p[2]/b" );
66 $correct = strstr ( $source, "Create the page \"Calcey web\" on this wiki!" );
67 $this->assertEquals( $correct, true );
68
69 $this->click( "link=Calcey web" );
70 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
71
72 $this->type( SeleniumTestConstants::TEXT_EDITOR, "Calcey web team" );
73 $this->click( SeleniumTestConstants::BUTTON_SAVE );
74 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
75
76 // Verify saved page is opened when the exact page name is given
77 $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey web" );
78 $this->click( SeleniumTestConstants::BUTTON_SEARCH );
79 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
80
81 // Verify exact page matched with the entered search text using 'Search' button
82 $source = $this->getText( "//*[@id='bodyContent']/div[4]/p/b" );
83 $correct = strstr( $source, "There is a page named \"Calcey web\" on this wiki." );
84 $this->assertEquals( $correct, true );
85
86 // Verify resutls available when partial page name is entered as the search text
87 $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey" );
88 $this->click( SeleniumTestConstants::BUTTON_SEARCH );
89 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
90
91 // Verify text avaialble in the search result under the page titles
92 if($this->isElementPresent( "Page_title_matches" )) {
93 $textPageTitle = $this->getText( "//*[@id='bodyContent']/div[4]/ul[1]/li[1]/div[1]/a" );
94 $this->assertContains( 'Calcey', $textPageTitle );
95 }
96
97 // Verify text avaialble in the search result under the page text
98 if($this->isElementPresent( "Page_text_matches" )) {
99 $textPageText = $this->getText( "//*[@id='bodyContent']/div[4]/ul[2]/li[2]/div[2]/span" );
100 $this->assertContains( 'Calcey', $textPageText );
101 }
102 $this->deletePage("Calcey QA");
103 $this->deletePage("Calcey web");
104 }
105 }