Selenium.class.php

From Organic Design wiki
Revision as of 10:42, 1 August 2008 by Nad (talk | contribs) (add interfaces for new functions for scheduling)

<?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;

# Add the tag hooks $wgParser->setHook('body', array($this, 'tagBody')); $wgParser->setHook('head', array($this, 'tagHead')); $wgParser->setHook('html', array($this, 'tagParseContent')); $wgParser->setHook('thead', array($this, 'tagParseContent')); $wgParser->setHook('tbody', array($this, 'tagParseContent'));

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

/** * Body tags surround the main test table and should be converted to a div of class "selenium" * - this tag also handles the categorisation of the article into Category:Selenium */ public function tagBody($text, &$argv, &$parser) { global $egSeleniumCategory; $text .= ""; $text = $parser->parse($text, $parser->mTitle, $parser->mOptions, false, false)->getText();

return "

$text

";

}

/** * The head tag of a selenium test doesn't need to be rendered, so simply returns an empty string */ public function tagHead(&$text, &$argv, &$parser) { return ; }

/** * The html, thead and tbody tags need to parse and return their content */ public function tagParseContent(&$text, &$argv, &$parser) { return $parser->parse($text, $parser->mTitle, $parser->mOptions, false, false)->getText(); }

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