Selenium.class.php

From Organic Design wiki
Revision as of 23:14, 1 August 2008 by Nad (talk | contribs) (do need to wrap in selenium tags afterall)

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

class Selenium {

function __construct() { global $wgParser, $egSeleniumTag;

# Add the tag hook $wgParser->setHook('selenium', array($this, 'tagSelenium'));

# Check the schedule and see if any test-runs should be spawned $this->checkSchedule(); }

/** * Process a selenium tag with test syntax in it * - this tag also handles the categorisation of the article into Category:Selenium */ public function tagSelenium($text, &$argv, &$parser) { global $egSeleniumCategory;

# Get rid of unwanted tags $text = preg_replace("#\\s*<head>.+?</head>\\s*#is", "", $text); $text = preg_replace("#\\s*</?t?(html|head|body)>\\s*#i", "", $text);

# Categorise the article into Selenium tests category $text .= "";

# Parse the content normally and return wrapped in a div of class selenium $text = $parser->parse($text, $parser->mTitle, $parser->mOptions, false, false)->getText();

return "

$text

";

}

/** * Check whether any tests should run and spawn them if so */ public function checkSchedule() { }

/** * Spawn a thread to run a test suite and report if failure */ public function spawnTestRunner() { }

/** * Notify a user about a test failure */ public function failureNotification() { }

/** * Needed in some versions to prevent Special:Version from breaking */ private function __toString() { return __CLASS__; } }