Test file deleted from Calcey
[lhc/web/wiklou.git] / maintenance / tests / selenium / suites / AddContentToNewPageTestCase.php
1 <?php
2 /*
3 * This test case is part of the SimpleSeleniumTestSuite.
4 * Configuration for these tests are dosumented as part of SimpleSeleniumTestSuite.php
5 */
6 class AddContentToNewPageTestCase extends SeleniumTestCase{
7
8 // Add bold text and verify output
9 public function testAddBoldText(){
10 $blnElementPresent = False;
11 $blnTextPresent = False;
12 $this->getExistingPage();
13 $this->clickEditLink();
14 $this->loadWikiEditor();
15 $this->clearWikiEditor();
16 $this->click( "//*[@id='mw-editbutton-bold']" );
17 $this->clickShowPreviewBtn();
18 $this->waitForPageToLoad( "600000" );
19
20 try{
21 $this->assertTrue($this->isElementPresent("//div[@id='wikiPreview']/p/b"));
22 $blnElementPresent = True;
23 } catch ( PHPUnit_Framework_AssertionFailedError $e ){
24 $blnElementPresent = False;
25 }
26
27 try{
28 $this->assertTrue($this->isTextPresent( "Bold text" ));
29 $blnTextPresent = True;
30
31 } catch ( PHPUnit_Framework_AssertionFailedError $e ){
32 $blnTextPresent = False;
33 }
34
35 // Verify bold text displayed on mediawiki preview
36 if (( $blnElementPresent = True ) && ( $blnTextPresent = True )){
37 echo "\n Pass : Bold text displayed in the preview \n";
38 }
39 else{
40 echo "\n Fail : Bold text displayed in the preview \n";
41 }
42 }
43
44 // Add italic text and verify output
45 public function testAddItalicText(){
46 $this->getExistingPage();
47 $this->clickEditLink();
48 $this->loadWikiEditor();
49 $this->clearWikiEditor();
50 $this->click( "//*[@id='mw-editbutton-italic']" );
51 $this->clickShowPreviewBtn();
52 $this->waitForPageToLoad( "600000" );
53
54 // Verify italic text displayed on mediawiki preview
55 try{
56 $this->assertTrue($this->isElementPresent("//div[@id='wikiPreview']/p/i"));
57 $blnElementPresent = True;
58 } catch ( PHPUnit_Framework_AssertionFailedError $e ){
59 $blnElementPresent = False;
60 }
61
62 try{
63 $this->assertTrue($this->isTextPresent( "Italic text" ));
64 $blnTextPresent = True;
65
66 } catch ( PHPUnit_Framework_AssertionFailedError $e ){
67 $blnTextPresent = False;
68 }
69
70 // Verify italic text displayed on mediawiki preview
71 if (( $blnElementPresent = True ) && ( $blnTextPresent = True )){
72 echo "\n Pass : Italic text displayed in the preview \n";
73 }
74 else{
75 echo "\n Fail : Italic text displayed in the preview \n";
76 }
77
78 }
79
80 // Add internal link for a new page and verify output in the preview
81 public function testAddInternalLinkNewPage(){
82 $this->getExistingPage();
83 $this->clickEditLink();
84 $this->loadWikiEditor();
85 $this->clearWikiEditor();
86 $this->click( "//*[@id='mw-editbutton-link']" );
87 $this->clickShowPreviewBtn();
88 $this->waitForPageToLoad( "600000" );
89
90 // Verify internal link displayed on mediawiki preview
91 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
92 $correct = strstr( $source, "Link title" );
93 try{
94 $this->assertEquals( $correct, true );
95 echo "\n Pass : Internal link displayed in the preview \n";
96
97 } catch ( PHPUnit_Framework_AssertionFailedError $e ){
98 echo "\n Pass : Internal link displayed in the preview \n";
99 }
100
101 $this->click( "link=Link title" );
102 $this->waitForPageToLoad( "600000" );
103
104 // Verify internal link open as a new page - editing mode
105 $source = $this->getText( "firstHeading" );
106 $correct = strstr( $source, "Editing Link title" );
107 try{
108 $this->assertEquals( $correct, true );
109 echo "\n Pass : Internal link opened as a new page in the editing mode \n";
110
111 } catch ( PHPUnit_Framework_AssertionFailedError $e ){
112 echo "\n Fail : Internal link opened as a new page in the editing mode \n";
113 }
114 }
115
116 // Add external link and verify output in the preview
117 public function testAddExternalLink(){
118 $this->getExistingPage();
119 $this->clickEditLink();
120 $this->loadWikiEditor();
121 $this->clearWikiEditor();
122 $this->click( "//*[@id='mw-editbutton-extlink']" );
123 $this->type( "wpTextbox1", "[http://www.google.com Google]" );
124 $this->clickShowPreviewBtn();
125 $this->waitForPageToLoad( "600000" );
126
127 // Verify external links displayed on mediawiki preview
128 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
129 $correct = strstr( $source, "Google" );
130
131 try{
132 $this->assertEquals( $correct, true );
133 echo "\n Pass : External link displayed in the preview \n";
134
135 } catch ( PHPUnit_Framework_AssertionFailedError $e ){
136 echo "\n Fail : External link displayed in thw preview \n";
137 }
138
139 $this->click( "link=Google" );
140 $this->waitForPageToLoad( "600000" );
141
142 // Verify external link opens
143 $source = $this->getTitle();
144 $correct = strstr( $source, "Google" );
145 try{
146 $this->assertEquals( $correct, true);
147 echo "\n Pass : External link opened \n";
148
149 } catch (PHPUnit_Framework_AssertionFailedError $e){
150 echo "\n Fail : External link opened \n";
151 }
152
153 }
154
155 // Add level 2 headline and verify output in the preview
156 public function testAddLevel2HeadLine(){
157 $blnElementPresent = False;
158 $blnTextPresent = False;
159 $this->getExistingPage();
160 $this->clickEditLink();
161 $this->loadWikiEditor();
162 $this->clearWikiEditor();
163 $this->click( "mw-editbutton-headline" );
164 $this->clickShowPreviewBtn();
165 $this->waitForPageToLoad( "600000" );
166
167 try {
168 $this->assertTrue($this->isElementPresent("//div[@id='wikiPreview']/h2"));
169 $blnElementPresent = True;
170 } catch ( PHPUnit_Framework_AssertionFailedError $e ){
171 $blnElementPresent = False;
172 }
173
174 try{
175 $source = $this->getText( "//*[@id='Headline_text']" );
176 $correct = strstr( $source, "Headline text" );
177 $this->assertEquals( $correct, true );
178 $blnTextPresent = True;
179 } catch ( PHPUnit_Framework_AssertionFailedError $e ){
180 $blnTextPresent = False;
181 }
182
183 if(($blnElementPresent = True) && ($blnTextPresent = True)){
184 echo "\n Pass : Headline text displayed in the preview \n";
185 }
186 else{
187 echo "\n Fail : Headline text displayed in the preview \n";
188 }
189 }
190
191 // Add text with ignore wiki format and verify output the preview
192 public function testAddNoWikiFormat(){
193 $this->getExistingPage();
194 $this->clickEditLink();
195 $this->loadWikiEditor();
196 $this->clearWikiEditor();
197 $this->click( "//*[@id='mw-editbutton-nowiki']" );
198 $this->clickShowPreviewBtn();
199 $this->waitForPageToLoad( "600000" );
200
201 // Verify ignore wiki format text displayed on mediawiki preview
202 $source = $this->getText( "//div[@id='wikiPreview']/p" );
203 $correct = strstr( $source, "Insert non-formatted text here" );
204 try{
205 $this->assertEquals( $correct, true );
206 echo "\n Pass : Text available without wiki formats in the preview \n ";
207
208 } catch (PHPUnit_Framework_AssertionFailedError $e){
209 echo "\n Fail : Text available without wiki formats in the preview\n ";
210 }
211 }
212
213 // Add signature and verify output in the preview
214 public function testAddUserSignature(){
215 $this->getExistingPage();
216 $this->clickEditLink();
217 $this->loadWikiEditor();
218 $this->clearWikiEditor();
219 $this->click( "mw-editbutton-signature" );
220 $this->clickShowPreviewBtn();
221 $this->waitForPageToLoad( "600000" );
222
223 // Verify signature displayed on mediawiki preview
224 $source = $this->getText( "//*[@id='wikiPreview']/p/a" );
225 $username = $this->getText( "//*[@id='pt-userpage']/a" );
226 $correct = strstr( $source, $username );
227
228 try{
229 $this->assertEquals( $correct, true);
230 echo "\n Pass : Correct name displayed in the preview \n ";
231
232 } catch (PHPUnit_Framework_AssertionFailedError $e){
233 echo "\n Fail : Correct name displayed in the preview \n ";
234 }
235 }
236
237 // Add horizontal line and verify output in the preview
238 public function testHorizontalLine(){
239 $this->getExistingPage();
240 $this->clickEditLink();
241 $this->loadWikiEditor();
242 $this->clearWikiEditor();
243 $this->click( "mw-editbutton-hr" );
244
245 $this->clickShowPreviewBtn();
246 $this->waitForPageToLoad( "600000" );
247
248 // Verify horizontal line displayed on mediawiki preview
249 try{
250 $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/hr" ));
251 echo "\n Pass: Horizontal line displayed in the preview \n";
252 } catch (PHPUnit_Framework_AssertionFailedError $e){
253 echo "\n Fail : Horizontal line displayed in the preview \n ";
254 }
255 }
256
257
258 }