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