Fixed spacing in actions/cache/filebackend/filerepo/job folder
[mediawiki.git] / tests / selenium / SeleniumTestCase.php
blob5346b1be80f0c6c0cf21e8c740d03d77df1d6485
1 <?php
2 include( "SeleniumTestConstants.php" );
4 class SeleniumTestCase extends PHPUnit_Framework_TestCase { // PHPUnit_Extensions_SeleniumTestCase
5 protected $selenium;
7 public function setUp() {
8 set_time_limit( 60 );
9 $this->selenium = Selenium::getInstance();
12 public function tearDown() {
16 public function __call( $method, $args ) {
17 return call_user_func_array( array( $this->selenium, $method ), $args );
20 public function assertSeleniumAttributeEquals( $attribute, $value ) {
21 $attr = $this->getAttribute( $attribute );
22 $this->assertEquals( $attr, $value );
25 public function assertSeleniumHTMLContains( $element, $text ) {
26 $innerHTML = $this->getText( $element );
27 // or assertContains
28 $this->assertRegExp( "/$text/", $innerHTML );
32 /**
33 * Create a test fixture page if one does not exist
34 * @param $pageName The fixture page name. If none is supplied, it uses SeleniumTestConstants::WIKI_INTERNAL_LINK
36 function createTestPageIfMissing( $pageName = null ) {
37 if ( $pageName == null ) {
38 $pageName = SeleniumTestConstants::WIKI_INTERNAL_LINK;
40 $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, $pageName );
41 $this->click( SeleniumTestConstants::BUTTON_SEARCH );
42 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
43 $this->click( SeleniumTestConstants::LINK_START . $pageName );
44 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
45 $location = $this->getLocation() . "\n";
46 if ( strpos( $location, '&redlink=1' ) !== false ) {
47 $this->type( SeleniumTestConstants::TEXT_EDITOR, "Test fixture page. No real content here" );
48 $this->click( SeleniumTestConstants::BUTTON_SAVE );
49 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
50 $this->assertTrue( $this->isTextPresent( $pageName ),
51 $this->getText( SeleniumTestConstants::TEXT_PAGE_HEADING ) );
55 /**
56 * Create a test page using date as part of the name so that it is unique
57 * @param $pagePrefix The prefix to use for the page name. The current date will be appended to this to make it unique
58 * @param $watchThis Whether to add the page to my watchlist. Defaults to false.
60 function createNewTestPage( $pagePrefix, $watchThis = false ) {
61 $pageName = $pagePrefix . date( "Ymd-His" );
62 $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, $pageName );
63 $this->click( SeleniumTestConstants::BUTTON_SEARCH );
64 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
65 $this->click( SeleniumTestConstants::LINK_START . $pageName );
66 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
67 $location = $this->getLocation() . "\n";
68 $this->assertContains( '&redlink=1', $location ) .
69 $this->type( SeleniumTestConstants::TEXT_EDITOR, "Test fixture page. No real content here" );
70 if ( $watchThis ) {
71 $this->click( "wpWatchthis" );
73 $this->click( SeleniumTestConstants::BUTTON_SAVE );
74 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
75 $this->assertTrue( $this->isTextPresent( $pageName ),
76 $this->getText( SeleniumTestConstants::TEXT_PAGE_HEADING ) );
77 return $pageName;
80 public function getExistingPage() {
81 $this->open( $this->getUrl() .
82 '/index.php?title=Main_Page&action=edit' );
83 $this->type( "searchInput", "new" );
84 $this->click( "searchGoButton" );
85 $this->waitForPageToLoad( "30000" );
88 public function getNewPage( $pageName ) {
90 $this->open( $this->getUrl() .
91 '/index.php?title=Main_Page&action=edit' );
92 $this->type( "searchInput", $pageName );
93 $this->click( "searchGoButton" );
94 $this->waitForPageToLoad( "30000" );
95 $this->click( "link=" . $pageName );
96 $this->waitForPageToLoad( "600000" );
101 // Loading the mediawiki editor
102 public function loadWikiEditor() {
103 $this->open( $this->getUrl() .
104 '/index.php?title=Main_Page&action=edit' );
107 // Clear the content of the mediawiki editor
108 public function clearWikiEditor() {
109 $this->type( "wpTextbox1", "" );
112 // Click on the 'Show preview' button of the mediawiki editor
113 public function clickShowPreviewBtn() {
114 $this->click( "wpPreview" );
117 // Click on the 'Save Page' button of the mediawiki editor
118 public function clickSavePageBtn() {
119 $this->click( "wpSave" );
122 // Click on the 'Edit' link
123 public function clickEditLink() {
124 $this->click( "link=Edit" );
125 $this->waitForPageToLoad( "30000" );