Difference between revisions of "Selenium.php"

From Organic Design wiki
m
m
Line 15: Line 15:
 
if (!defined('MEDIAWIKI')) die('Not an entry point.');
 
if (!defined('MEDIAWIKI')) die('Not an entry point.');
  
define('SELENIUM_VERSION', '0.8.0, 2008-08-01');
+
define('SELENIUM_VERSION', '0.8.0, 2008-08-02');
  
$dir                   = dirname(__FILE__);
+
$dir               = dirname(__FILE__);
$egSeleniumPath         = preg_replace('|^.+(?=[/\\\\]extensions)|', $wgScriptPath, dirname(__FILE__)) . 'selenium-core';
+
$egSeleniumPath     = preg_replace('|^.+(?=[/\\\\]extensions)|', $wgScriptPath, dirname(__FILE__)).'/selenium-core';
$egResultsUrlPath       = "../../tmp/results.php";
+
$egResultsUrlPath   = "../../tmp/results.php";
$egSeleniumCategory     = "Selenium";
+
$egSeleniumCategory = "Selenium";               # Category that selenium tests will automatically be categorised in
 +
$egSeleniumTag      = "selenium";              # Name of tags to wrap selenium tests in
  
 
$wgSpecialPages['Selenium']          = 'SpecialSelenium';
 
$wgSpecialPages['Selenium']          = 'SpecialSelenium';
Line 29: Line 30:
 
$wgExtensionCredits['specialpage'][]  = array(
 
$wgExtensionCredits['specialpage'][]  = array(
 
'name'        => 'Selenium',
 
'name'        => 'Selenium',
'author'      => '[http://www.organicdesign.co.nz/User:Sven Sven (M Davy)]',
+
'author'      => '[http://www.organicdesign.co.nz/User:Sven Sven], [http://www.organicdesign.co.nz/User:Nad Nad]',
'description' => 'Incorporating Selenium tests into the MediaWiki environment',
+
'description' => 'Incorporating [http://selenium-core.openqa.org Selenium tests] into the MediaWiki environment',
'url'        => 'http://www.organicdesign.co.nz/Extension:Selenium.php',
+
'url'        => 'http://www.mediawiki.org/Extension:Selenium',
 
'version'    => SELENIUM_VERSION
 
'version'    => SELENIUM_VERSION
 
);
 
);
  
 
 
/**
 
* Called from $wgExtensionFunctions array when initialising extensions
 
*/
 
 
function efSetupSelenium() {
 
function efSetupSelenium() {
 
global $wgRequest, $wgOut, $egSelenium, $wgLanguageCode, $wgMessageCache;
 
global $wgRequest, $wgOut, $egSelenium, $wgLanguageCode, $wgMessageCache;
  
# Process suite or test if ?suite=article_name in query string
+
# If requesting a suite or inidividual test, then output will be raw
if ($wgRequest->getText('suite')) SpecialSelenium::disableHTML($wgOut);
+
if ($wgRequest->getText('suite')) {
 
+
$wgOut->disable();
$egSelenium = new Selenium();
+
wfResetOutputBuffers();
 +
}
  
 
# Add the messages used by the specialpage
 
# Add the messages used by the specialpage
 
if ($wgLanguageCode == 'en') {
 
if ($wgLanguageCode == 'en') {
$wgMessageCache->addMessages(array('selenium' => 'Selenium testing environment'));
+
$wgMessageCache->addMessages(array(
 +
'selenium'           => "Selenium tests",
 +
'selenium-no-tests'  => "Specified suite contains no selenium tests",
 +
'selenium-runcore'    => "Click link to run Selenium core",
 +
'selenium-nosuchtest' => "Test \"$1\" not found in suite \"$2\"",
 +
'selenium-select'    => "Select a test suite to run",
 +
'selenium-autorun'    => "Run automatically",
 +
'selenium-runmanual'  => "Run tests manually",
 +
'selenium-manage'    => "Manage automatic testing schedule",
 +
'selenium-create'    => "Create new tests"
 +
));
 
}
 
}
  
# Add the specialpage to the environment
+
# Add specialpage and create an instance of the class
 
SpecialPage::addPage(new SpecialSelenium());
 
SpecialPage::addPage(new SpecialSelenium());
 +
$egSelenium = new Selenium();
 
}
 
}
  

Revision as of 04:14, 2 August 2008

<?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-02');

$dir = dirname(__FILE__); $egSeleniumPath = preg_replace('|^.+(?=[/\\\\]extensions)|', $wgScriptPath, dirname(__FILE__)).'/selenium-core'; $egResultsUrlPath = "../../tmp/results.php"; $egSeleniumCategory = "Selenium"; # Category that selenium tests will automatically be categorised in $egSeleniumTag = "selenium"; # Name of tags to wrap selenium tests in

$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, Nad', 'description' => 'Incorporating Selenium tests into the MediaWiki environment', 'url' => 'http://www.mediawiki.org/Extension:Selenium', 'version' => SELENIUM_VERSION );

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

# If requesting a suite or inidividual test, then output will be raw if ($wgRequest->getText('suite')) { $wgOut->disable(); wfResetOutputBuffers(); }

# Add the messages used by the specialpage if ($wgLanguageCode == 'en') { $wgMessageCache->addMessages(array( 'selenium' => "Selenium tests", 'selenium-no-tests' => "Specified suite contains no selenium tests", 'selenium-runcore' => "Click link to run Selenium core", 'selenium-nosuchtest' => "Test \"$1\" not found in suite \"$2\"", 'selenium-select' => "Select a test suite to run", 'selenium-autorun' => "Run automatically", 'selenium-runmanual' => "Run tests manually", 'selenium-manage' => "Manage automatic testing schedule", 'selenium-create' => "Create new tests" )); }

# Add specialpage and create an instance of the class SpecialPage::addPage(new SpecialSelenium()); $egSelenium = new Selenium(); }

/**

* 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; }