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