Merge branch 'MDL-29201_20' of git://github.com/timhunt/moodle into MOODLE_20_STABLE
[moodle.git] / lib / simpletestlib / selector.php
blob7c5962e1a132f3b1765f467ab57ef8b6bd44ab61
1 <?php
2 /**
3 * Base include file for SimpleTest.
4 * @package SimpleTest
5 * @subpackage WebTester
6 * @version $Id$
7 */
9 /**#@+
10 * include SimpleTest files
12 require_once(dirname(__FILE__) . '/tag.php');
13 require_once(dirname(__FILE__) . '/encoding.php');
14 /**#@-*/
16 /**
17 * Used to extract form elements for testing against.
18 * Searches by name attribute.
19 * @package SimpleTest
20 * @subpackage WebTester
22 class SimpleByName {
23 var $_name;
25 /**
26 * Stashes the name for later comparison.
27 * @param string $name Name attribute to match.
29 function SimpleByName($name) {
30 $this->_name = $name;
33 function getName() {
34 return $this->_name;
37 /**
38 * Compares with name attribute of widget.
39 * @param SimpleWidget $widget Control to compare.
40 * @access public
42 function isMatch($widget) {
43 return ($widget->getName() == $this->_name);
47 /**
48 * Used to extract form elements for testing against.
49 * Searches by visible label or alt text.
50 * @package SimpleTest
51 * @subpackage WebTester
53 class SimpleByLabel {
54 var $_label;
56 /**
57 * Stashes the name for later comparison.
58 * @param string $label Visible text to match.
60 function SimpleByLabel($label) {
61 $this->_label = $label;
64 /**
65 * Comparison. Compares visible text of widget or
66 * related label.
67 * @param SimpleWidget $widget Control to compare.
68 * @access public
70 function isMatch($widget) {
71 if (! method_exists($widget, 'isLabel')) {
72 return false;
74 return $widget->isLabel($this->_label);
78 /**
79 * Used to extract form elements for testing against.
80 * Searches dy id attribute.
81 * @package SimpleTest
82 * @subpackage WebTester
84 class SimpleById {
85 var $_id;
87 /**
88 * Stashes the name for later comparison.
89 * @param string $id ID atribute to match.
91 function SimpleById($id) {
92 $this->_id = $id;
95 /**
96 * Comparison. Compares id attribute of widget.
97 * @param SimpleWidget $widget Control to compare.
98 * @access public
100 function isMatch($widget) {
101 return $widget->isId($this->_id);
106 * Used to extract form elements for testing against.
107 * Searches by visible label, name or alt text.
108 * @package SimpleTest
109 * @subpackage WebTester
111 class SimpleByLabelOrName {
112 var $_label;
115 * Stashes the name/label for later comparison.
116 * @param string $label Visible text to match.
118 function SimpleByLabelOrName($label) {
119 $this->_label = $label;
123 * Comparison. Compares visible text of widget or
124 * related label or name.
125 * @param SimpleWidget $widget Control to compare.
126 * @access public
128 function isMatch($widget) {
129 if (method_exists($widget, 'isLabel')) {
130 if ($widget->isLabel($this->_label)) {
131 return true;
134 return ($widget->getName() == $this->_label);