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