Selenium.php

From Organic Design wiki
Revision as of 10:25, 1 August 2008 by Nad (talk | contribs)

<?php /**

* Selenium extension
* Template:Php
* See http://www.mediawiki.org/Extension:Selenium for installation and usage details
* See http://www.organicdesign.co.nz/Extension_talk:Selenium.php for development notes and disucssion
* 
* @package MediaWiki
* @subpackage Extensions
* @author Marcus Davy User:Sven
* @copyright © 2007 Marcus Davy
* @licence GNU General Public Licence 2.0 or later
*/

if (!defined('MEDIAWIKI')) die('Not an entry point.');

define('SELENIUM_VERSION', '0.8.0, 2008-08-01');

$dir = dirname(__FILE__); $egSeleniumPath = preg_replace('|^.+(?=[/\\\\]extensions)|', $wgScriptPath, dirname(__FILE__)) . 'selenium-core'; $egResultsUrlPath = "../../tmp/results.php"; $egSeleniumCategory = "Selenium";

$wgSpecialPages['Selenium'] = 'SpecialSelenium'; $wgAutoloadClasses['SpecialSelenium'] = "$dir/SpecialSelenium.php"; $wgAutoloadClasses['Selenium'] = "$dir/Selenium.class.php"; $wgExtensionFunctions[] = 'efSetupSelenium'; $wgHooks['LanguageGetMagic'][] = 'efSeleniumLanguageGetMagic'; $wgExtensionCredits['specialpage'][] = array( 'name' => 'Selenium', 'author' => 'Sven (M Davy)', 'description' => 'Incorporating Selenium tests into the MediaWiki environment', 'url' => 'http://www.organicdesign.co.nz/Extension:Selenium.php', 'version' => SELENIUM_VERSION );


/**

* Called from $wgExtensionFunctions array when initialising extensions
*/

function efSetupSelenium() { global $wgRequest, $wgOut, $egSelenium, $wgLanguageCode, $wgMessageCache;

# Process suite or test if ?suite=article_name in query string if ($wgRequest->getText('suite')) SpecialSelenium::disableHTML($wgOut);

$egSelenium = new Selenium();

# Add the messages used by the specialpage if ($wgLanguageCode == 'en') { $wgMessageCache->addMessages(array('selenium' => 'Selenium testing environment')); }

# Add the specialpage to the environment SpecialPage::addPage(new SpecialSelenium()); }

/**

* Needed in MediaWiki >1.8.0 for magic word hooks to work properly
*/

function efSeleniumLanguageGetMagic(&$magicWords, $langCode = 0) { global $egSeleniumMagic; $magicWords[$egSeleniumMagic] = array($langCode, $egSeleniumMagic); return true; }