adding some strings
[moodle-linuxchix.git] / lib / simpletestlib / selector.php
blobec8f354f1e7be308dbeceec4a0d8e6eada6dc511
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 /**
34 * Compares with name attribute of widget.
35 * @param SimpleWidget $widget Control to compare.
36 * @access public
38 function isMatch($widget) {
39 return ($widget->getName() == $this->_name);
43 /**
44 * Used to extract form elements for testing against.
45 * Searches by visible label or alt text.
46 * @package SimpleTest
47 * @subpackage WebTester
49 class SimpleByLabel {
50 var $_label;
52 /**
53 * Stashes the name for later comparison.
54 * @param string $label Visible text to match.
56 function SimpleByLabel($label) {
57 $this->_label = $label;
60 /**
61 * Comparison. Compares visible text of widget or
62 * related label.
63 * @param SimpleWidget $widget Control to compare.
64 * @access public
66 function isMatch($widget) {
67 if (! method_exists($widget, 'isLabel')) {
68 return false;
70 return $widget->isLabel($this->_label);
74 /**
75 * Used to extract form elements for testing against.
76 * Searches dy id attribute.
77 * @package SimpleTest
78 * @subpackage WebTester
80 class SimpleById {
81 var $_id;
83 /**
84 * Stashes the name for later comparison.
85 * @param string $id ID atribute to match.
87 function SimpleById($id) {
88 $this->_id = $id;
91 /**
92 * Comparison. Compares id attribute of widget.
93 * @param SimpleWidget $widget Control to compare.
94 * @access public
96 function isMatch($widget) {
97 return $widget->isId($this->_id);
102 * Used to extract form elements for testing against.
103 * Searches by visible label, name or alt text.
104 * @package SimpleTest
105 * @subpackage WebTester
107 class SimpleByLabelOrName {
108 var $_label;
111 * Stashes the name/label for later comparison.
112 * @param string $label Visible text to match.
114 function SimpleByLabelOrName($label) {
115 $this->_label = $label;
119 * Comparison. Compares visible text of widget or
120 * related label or name.
121 * @param SimpleWidget $widget Control to compare.
122 * @access public
124 function isMatch($widget) {
125 if (method_exists($widget, 'isLabel')) {
126 if ($widget->isLabel($this->_label)) {
127 return true;
130 return ($widget->getName() == $this->_label);