QUnit: Re-enable config.requireExpects and add missing numbers.
[lhc/web/wiklou.git] / tests / selenium / suites / AddContentToNewPageTestCase.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 AddContentToNewPageTestCase extends SeleniumTestCase {
31 // Add bold text and verify output
32 public function testAddBoldText() {
33 $this->getExistingPage();
34 $this->clickEditLink();
35 $this->loadWikiEditor();
36 $this->clearWikiEditor();
37 $this->click( "//*[@id='mw-editbutton-bold']" );
38 $this->clickShowPreviewBtn();
39 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
40
41 // Verify bold text displayed on mediawiki preview
42 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/p/b" ) );
43 $this->assertTrue( $this->isTextPresent( "Bold text" ) );
44 }
45
46 // Add italic text and verify output
47 public function testAddItalicText() {
48 $this->getExistingPage();
49 $this->clickEditLink();
50 $this->loadWikiEditor();
51 $this->clearWikiEditor();
52 $this->click( "//*[@id='mw-editbutton-italic']" );
53 $this->clickShowPreviewBtn();
54 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
55
56 // Verify italic text displayed on mediawiki preview
57 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/p/i" ) );
58 $this->assertTrue( $this->isTextPresent( "Italic text" ) );
59 }
60
61 // Add internal link for a new page and verify output in the preview
62 public function testAddInternalLinkNewPage() {
63 $this->getExistingPage();
64 $this->clickEditLink();
65 $this->loadWikiEditor();
66 $this->clearWikiEditor();
67 $this->click( "//*[@id='mw-editbutton-link']" );
68 $this->clickShowPreviewBtn();
69 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
70
71 // Verify internal link displayed on mediawiki preview
72 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
73 $correct = strstr( $source, "Link title" );
74 $this->assertEquals( $correct, true );
75
76 $this->click( SeleniumTestConstants::LINK_START . "Link title" );
77 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
78
79 // Verify internal link open as a new page - editing mode
80 $source = $this->getText( "firstHeading" );
81 $correct = strstr( $source, "Editing Link title" );
82 $this->assertEquals( $correct, true );
83 }
84
85 // Add external link and verify output in the preview
86 public function testAddExternalLink() {
87 $this->getExistingPage();
88 $this->clickEditLink();
89 $this->loadWikiEditor();
90 $this->clearWikiEditor();
91 $this->click( "//*[@id='mw-editbutton-extlink']" );
92 $this->type( SeleniumTestConstants::TEXT_EDITOR, "[http://www.google.com Google]" );
93 $this->clickShowPreviewBtn();
94 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
95
96 // Verify external links displayed on mediawiki preview
97 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
98 $correct = strstr( $source, "Google" );
99 $this->assertEquals( $correct, true );
100
101 $this->click( SeleniumTestConstants::LINK_START . "Google" );
102 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
103
104 // Verify external link opens
105 $source = $this->getTitle();
106 $correct = strstr( $source, "Google" );
107 $this->assertEquals( $correct, true );
108 }
109
110 // Add level 2 headline and verify output in the preview
111 public function testAddLevel2HeadLine() {
112 $blnElementPresent = false;
113 $blnTextPresent = false;
114 $this->getExistingPage();
115 $this->clickEditLink();
116 $this->loadWikiEditor();
117 $this->clearWikiEditor();
118 $this->click( "mw-editbutton-headline" );
119 $this->clickShowPreviewBtn();
120 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
121 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/h2" ) );
122
123 // Verify level 2 headline displayed on mediawiki preview
124 $source = $this->getText( "//*[@id='Headline_text']" );
125 $correct = strstr( $source, "Headline text" );
126 $this->assertEquals( $correct, true );
127 }
128
129 // Add text with ignore wiki format and verify output the preview
130 public function testAddNoWikiFormat() {
131 $this->getExistingPage();
132 $this->clickEditLink();
133 $this->loadWikiEditor();
134 $this->clearWikiEditor();
135 $this->click( "//*[@id='mw-editbutton-nowiki']" );
136 $this->clickShowPreviewBtn();
137 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
138
139 // Verify ignore wiki format text displayed on mediawiki preview
140 $source = $this->getText( "//div[@id='wikiPreview']/p" );
141 $correct = strstr( $source, "Insert non-formatted text here" );
142 $this->assertEquals( $correct, true );
143 }
144
145 // Add signature and verify output in the preview
146 public function testAddUserSignature() {
147 $this->getExistingPage();
148 $this->clickEditLink();
149 $this->loadWikiEditor();
150 $this->clearWikiEditor();
151 $this->click( "mw-editbutton-signature" );
152 $this->clickShowPreviewBtn();
153 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
154
155 // Verify signature displayed on mediawiki preview
156 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
157 $username = $this->getText( "//*[@id='pt-userpage']/a" );
158 $correct = strstr( $source, $username );
159 $this->assertEquals( $correct, true );
160 }
161
162 // Add horizontal line and verify output in the preview
163 public function testHorizontalLine() {
164 $this->getExistingPage();
165 $this->clickEditLink();
166 $this->loadWikiEditor();
167 $this->clearWikiEditor();
168 $this->click( "mw-editbutton-hr" );
169
170 $this->clickShowPreviewBtn();
171 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
172
173 // Verify horizontal line displayed on mediawiki preview
174 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/hr" ) );
175 $this->deletePage( "new" );
176 }
177 }