MediaWiki  REL1_21
PageSearchTestCase.php
Go to the documentation of this file.
00001 <?php
00026 class PageSearchTestCase extends SeleniumTestCase {
00027         // Verify the functionality of the 'Go' button
00028         public function testPageSearchBtnGo() {
00029 
00030                 $this->open( $this->getUrl() .
00031                         '/index.php?title=Main_Page&action=edit' );
00032                 $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "calcey qa" );
00033                 $this->click( "searchGoButton" );
00034                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00035 
00036                 // Verify  no page matched with the entered search text
00037                 $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p/b" );
00038                 $correct = strstr( $source, "Create the page \"Calcey qa\" on this wiki!" );
00039                 $this->assertEquals( $correct, true );
00040 
00041                 $this->click( "link=Calcey qa" );
00042                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00043 
00044                 $this->type( SeleniumTestConstants::TEXT_EDITOR, "Calcey QA team" );
00045                 $this->click( "wpSave" );
00046                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00047         }
00048 
00049         // Verify the functionality of the 'Search' button
00050         public function testPageSearchBtnSearch() {
00051                 $this->open( $this->getUrl() .
00052                         '/index.php?title=Main_Page&action=edit' );
00053                 $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey web" );
00054                 $this->click( SeleniumTestConstants::BUTTON_SEARCH );
00055                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00056 
00057                 // Verify  no page is available as the search text
00058                 $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p[2]/b" );
00059                 $correct = strstr( $source, "Create the page \"Calcey web\" on this wiki!" );
00060                 $this->assertEquals( $correct, true );
00061 
00062                 $this->click( "link=Calcey web" );
00063                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00064 
00065                 $this->type( SeleniumTestConstants::TEXT_EDITOR, "Calcey web team" );
00066                 $this->click( SeleniumTestConstants::BUTTON_SAVE );
00067                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00068 
00069                 // Verify saved page is opened  when the exact page name is given
00070                 $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey web" );
00071                 $this->click( SeleniumTestConstants::BUTTON_SEARCH );
00072                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00073 
00074                 // Verify exact page matched with the entered search text using 'Search' button
00075                 $source = $this->getText( "//*[@id='bodyContent']/div[4]/p/b" );
00076                 $correct = strstr( $source, "There is a page named \"Calcey web\" on this wiki." );
00077                 $this->assertEquals( $correct, true );
00078 
00079                 // Verify resutls available when partial page name is entered as the search text
00080                 $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey" );
00081                 $this->click( SeleniumTestConstants::BUTTON_SEARCH );
00082                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00083 
00084                 //  Verify text avaialble in the search result under the page titles
00085                 if ( $this->isElementPresent( "Page_title_matches" ) ) {
00086                         $textPageTitle = $this->getText( "//*[@id='bodyContent']/div[4]/ul[1]/li[1]/div[1]/a" );
00087                         $this->assertContains( 'Calcey', $textPageTitle );
00088                 }
00089 
00090                 //  Verify text avaialble in the search result under the page text
00091                 if ( $this->isElementPresent( "Page_text_matches" ) ) {
00092                         $textPageText = $this->getText( "//*[@id='bodyContent']/div[4]/ul[2]/li[2]/div[2]/span" );
00093                         $this->assertContains( 'Calcey', $textPageText );
00094                 }
00095                 $this->deletePage( "Calcey QA" );
00096                 $this->deletePage( "Calcey web" );
00097         }
00098 }