silverstripe-framework/testing/simpletest/selector.php
Sam Minnee b0c384d6c1 Merged revisions 53150,53681,53700,53820,54200,54459 via svnmerge from
svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/roa

........
  r53150 | ischommer | 2008-04-22 11:12:43 +1200 (Tue, 22 Apr 2008) | 1 line
  
  FEATURE Added a "test mode" for /db/build which allows mock-DataObject-subclasses which are just built in a test run
........
  r53681 | mrickerby | 2008-04-29 15:26:52 +1200 (Tue, 29 Apr 2008) | 1 line
  
  adding default wrapping header and footer methods, and configurable reporting to the TestRunner
........
  r53700 | mrickerby | 2008-04-29 16:41:57 +1200 (Tue, 29 Apr 2008) | 1 line
  
  FEATURE: adding support for /dev/tests --> DevelopmentAdmin-->tests() --> TestRunner, /dev/tasks --> DevelopmentAdmin-->tasks() --> TaskRunner
........
  r53820 | mrickerby | 2008-04-30 19:27:52 +1200 (Wed, 30 Apr 2008) | 1 line
  
  BUGFIX fixing up BuildTask interface and task runner action
........
  r54200 | sminnee | 2008-05-09 00:28:44 +1200 (Fri, 09 May 2008) | 1 line
  
  Added TestSession object to help with the testing of forms
........
  r54459 | sminnee | 2008-05-13 17:28:25 +1200 (Tue, 13 May 2008) | 1 line
  
  Added a basic menu of options to /dev
........


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@54456 467b73ca-7a2a-4603-9d3b-597d59a354a9
2008-05-13 05:57:09 +00:00

137 lines
3.2 KiB
PHP

<?php
/**
* Base include file for SimpleTest.
* @package SimpleTest
* @subpackage WebTester
* @version $Id: selector.php 1723 2008-04-08 00:34:10Z lastcraft $
*/
/**#@+
* include SimpleTest files
*/
require_once(dirname(__FILE__) . '/tag.php');
require_once(dirname(__FILE__) . '/encoding.php');
/**#@-*/
/**
* Used to extract form elements for testing against.
* Searches by name attribute.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleByName {
var $_name;
/**
* Stashes the name for later comparison.
* @param string $name Name attribute to match.
*/
function SimpleByName($name) {
$this->_name = $name;
}
function getName() {
return $this->_name;
}
/**
* Compares with name attribute of widget.
* @param SimpleWidget $widget Control to compare.
* @access public
*/
function isMatch($widget) {
return ($widget->getName() == $this->_name);
}
}
/**
* Used to extract form elements for testing against.
* Searches by visible label or alt text.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleByLabel {
var $_label;
/**
* Stashes the name for later comparison.
* @param string $label Visible text to match.
*/
function SimpleByLabel($label) {
$this->_label = $label;
}
/**
* Comparison. Compares visible text of widget or
* related label.
* @param SimpleWidget $widget Control to compare.
* @access public
*/
function isMatch($widget) {
if (! method_exists($widget, 'isLabel')) {
return false;
}
return $widget->isLabel($this->_label);
}
}
/**
* Used to extract form elements for testing against.
* Searches dy id attribute.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleById {
var $_id;
/**
* Stashes the name for later comparison.
* @param string $id ID atribute to match.
*/
function SimpleById($id) {
$this->_id = $id;
}
/**
* Comparison. Compares id attribute of widget.
* @param SimpleWidget $widget Control to compare.
* @access public
*/
function isMatch($widget) {
return $widget->isId($this->_id);
}
}
/**
* Used to extract form elements for testing against.
* Searches by visible label, name or alt text.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleByLabelOrName {
var $_label;
/**
* Stashes the name/label for later comparison.
* @param string $label Visible text to match.
*/
function SimpleByLabelOrName($label) {
$this->_label = $label;
}
/**
* Comparison. Compares visible text of widget or
* related label or name.
* @param SimpleWidget $widget Control to compare.
* @access public
*/
function isMatch($widget) {
if (method_exists($widget, 'isLabel')) {
if ($widget->isLabel($this->_label)) {
return true;
}
}
return ($widget->getName() == $this->_label);
}
}
?>