MediaWiki  REL1_21
AddContentToNewPageTestCase.php
Go to the documentation of this file.
00001 <?php
00026 class AddContentToNewPageTestCase extends SeleniumTestCase {
00027         // Add bold text and verify output
00028         public function testAddBoldText() {
00029                 $this->getExistingPage();
00030                 $this->clickEditLink();
00031                 $this->loadWikiEditor();
00032                 $this->clearWikiEditor();
00033                 $this->click( "//*[@id='mw-editbutton-bold']" );
00034                 $this->clickShowPreviewBtn();
00035                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00036 
00037                 // Verify bold text displayed on mediawiki preview
00038                 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/p/b" ) );
00039                 $this->assertTrue( $this->isTextPresent( "Bold text" ) );
00040         }
00041 
00042         // Add italic text and verify output
00043         public function testAddItalicText() {
00044                 $this->getExistingPage();
00045                 $this->clickEditLink();
00046                 $this->loadWikiEditor();
00047                 $this->clearWikiEditor();
00048                 $this->click( "//*[@id='mw-editbutton-italic']" );
00049                 $this->clickShowPreviewBtn();
00050                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00051 
00052                 // Verify italic text displayed on mediawiki preview
00053                 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/p/i" ) );
00054                 $this->assertTrue( $this->isTextPresent( "Italic text" ) );
00055         }
00056 
00057         // Add internal link for a new page and verify output in the preview
00058         public function testAddInternalLinkNewPage() {
00059                 $this->getExistingPage();
00060                 $this->clickEditLink();
00061                 $this->loadWikiEditor();
00062                 $this->clearWikiEditor();
00063                 $this->click( "//*[@id='mw-editbutton-link']" );
00064                 $this->clickShowPreviewBtn();
00065                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00066 
00067                 // Verify internal link displayed on mediawiki preview
00068                 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
00069                 $correct = strstr( $source, "Link title" );
00070                 $this->assertEquals( $correct, true );
00071 
00072                 $this->click( SeleniumTestConstants::LINK_START . "Link title" );
00073                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00074 
00075                 // Verify internal link open as a new page - editing mode
00076                 $source = $this->getText( "firstHeading" );
00077                 $correct = strstr( $source, "Editing Link title" );
00078                 $this->assertEquals( $correct, true );
00079         }
00080 
00081         // Add external link and verify output in the preview
00082         public function testAddExternalLink() {
00083                 $this->getExistingPage();
00084                 $this->clickEditLink();
00085                 $this->loadWikiEditor();
00086                 $this->clearWikiEditor();
00087                 $this->click( "//*[@id='mw-editbutton-extlink']" );
00088                 $this->type( SeleniumTestConstants::TEXT_EDITOR, "[http://www.google.com Google]" );
00089                 $this->clickShowPreviewBtn();
00090                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00091 
00092                 // Verify external links displayed on mediawiki preview
00093                 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
00094                 $correct = strstr( $source, "Google" );
00095                 $this->assertEquals( $correct, true );
00096 
00097                 $this->click( SeleniumTestConstants::LINK_START . "Google" );
00098                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00099 
00100                 // Verify external link opens
00101                 $source = $this->getTitle();
00102                 $correct = strstr( $source, "Google" );
00103                 $this->assertEquals( $correct, true );
00104         }
00105 
00106         // Add level 2 headline and verify output in the preview
00107         public function testAddLevel2HeadLine() {
00108                 $blnElementPresent = false;
00109                 $blnTextPresent = false;
00110                 $this->getExistingPage();
00111                 $this->clickEditLink();
00112                 $this->loadWikiEditor();
00113                 $this->clearWikiEditor();
00114                 $this->click( "mw-editbutton-headline" );
00115                 $this->clickShowPreviewBtn();
00116                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00117                 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/h2" ) );
00118 
00119                 // Verify level 2 headline displayed on mediawiki preview
00120                 $source = $this->getText( "//*[@id='Headline_text']" );
00121                 $correct = strstr( $source, "Headline text" );
00122                 $this->assertEquals( $correct, true );
00123         }
00124 
00125         // Add text with ignore wiki format and verify output the preview
00126         public function testAddNoWikiFormat() {
00127                 $this->getExistingPage();
00128                 $this->clickEditLink();
00129                 $this->loadWikiEditor();
00130                 $this->clearWikiEditor();
00131                 $this->click( "//*[@id='mw-editbutton-nowiki']" );
00132                 $this->clickShowPreviewBtn();
00133                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00134 
00135                 // Verify ignore wiki format text displayed on mediawiki preview
00136                 $source = $this->getText( "//div[@id='wikiPreview']/p" );
00137                 $correct = strstr( $source, "Insert non-formatted text here" );
00138                 $this->assertEquals( $correct, true );
00139         }
00140 
00141         // Add signature and verify output in the preview
00142         public function testAddUserSignature() {
00143                 $this->getExistingPage();
00144                 $this->clickEditLink();
00145                 $this->loadWikiEditor();
00146                 $this->clearWikiEditor();
00147                 $this->click( "mw-editbutton-signature" );
00148                 $this->clickShowPreviewBtn();
00149                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00150 
00151                 // Verify signature displayed on mediawiki preview
00152                 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
00153                 $username = $this->getText( "//*[@id='pt-userpage']/a" );
00154                 $correct = strstr( $source, $username );
00155                 $this->assertEquals( $correct, true );
00156         }
00157 
00158         // Add horizontal line and verify output in the preview
00159         public function testHorizontalLine() {
00160                 $this->getExistingPage();
00161                 $this->clickEditLink();
00162                 $this->loadWikiEditor();
00163                 $this->clearWikiEditor();
00164                 $this->click( "mw-editbutton-hr" );
00165 
00166                 $this->clickShowPreviewBtn();
00167                 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00168 
00169                 // Verify horizontal line displayed on mediawiki preview
00170                 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/hr" ) );
00171                 $this->deletePage( "new" );
00172         }
00173 }