1 | <?php |
---|
2 | /** |
---|
3 | * Base include file for SimpleTest. |
---|
4 | * @package SimpleTest |
---|
5 | * @subpackage WebTester |
---|
6 | * @version $Id: selector.php 1723 2008-04-08 00:34:10Z lastcraft $ |
---|
7 | */ |
---|
8 | |
---|
9 | /**#@+ |
---|
10 | * include SimpleTest files |
---|
11 | */ |
---|
12 | require_once(dirname(__FILE__) . '/tag.php'); |
---|
13 | require_once(dirname(__FILE__) . '/encoding.php'); |
---|
14 | /**#@-*/ |
---|
15 | |
---|
16 | /** |
---|
17 | * Used to extract form elements for testing against. |
---|
18 | * Searches by name attribute. |
---|
19 | * @package SimpleTest |
---|
20 | * @subpackage WebTester |
---|
21 | */ |
---|
22 | class SimpleByName { |
---|
23 | var $_name; |
---|
24 | |
---|
25 | /** |
---|
26 | * Stashes the name for later comparison. |
---|
27 | * @param string $name Name attribute to match. |
---|
28 | */ |
---|
29 | function SimpleByName($name) { |
---|
30 | $this->_name = $name; |
---|
31 | } |
---|
32 | |
---|
33 | function getName() { |
---|
34 | return $this->_name; |
---|
35 | } |
---|
36 | |
---|
37 | /** |
---|
38 | * Compares with name attribute of widget. |
---|
39 | * @param SimpleWidget $widget Control to compare. |
---|
40 | * @access public |
---|
41 | */ |
---|
42 | function isMatch($widget) { |
---|
43 | return ($widget->getName() == $this->_name); |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | /** |
---|
48 | * Used to extract form elements for testing against. |
---|
49 | * Searches by visible label or alt text. |
---|
50 | * @package SimpleTest |
---|
51 | * @subpackage WebTester |
---|
52 | */ |
---|
53 | class SimpleByLabel { |
---|
54 | var $_label; |
---|
55 | |
---|
56 | /** |
---|
57 | * Stashes the name for later comparison. |
---|
58 | * @param string $label Visible text to match. |
---|
59 | */ |
---|
60 | function SimpleByLabel($label) { |
---|
61 | $this->_label = $label; |
---|
62 | } |
---|
63 | |
---|
64 | /** |
---|
65 | * Comparison. Compares visible text of widget or |
---|
66 | * related label. |
---|
67 | * @param SimpleWidget $widget Control to compare. |
---|
68 | * @access public |
---|
69 | */ |
---|
70 | function isMatch($widget) { |
---|
71 | if (! method_exists($widget, 'isLabel')) { |
---|
72 | return false; |
---|
73 | } |
---|
74 | return $widget->isLabel($this->_label); |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | /** |
---|
79 | * Used to extract form elements for testing against. |
---|
80 | * Searches dy id attribute. |
---|
81 | * @package SimpleTest |
---|
82 | * @subpackage WebTester |
---|
83 | */ |
---|
84 | class SimpleById { |
---|
85 | var $_id; |
---|
86 | |
---|
87 | /** |
---|
88 | * Stashes the name for later comparison. |
---|
89 | * @param string $id ID atribute to match. |
---|
90 | */ |
---|
91 | function SimpleById($id) { |
---|
92 | $this->_id = $id; |
---|
93 | } |
---|
94 | |
---|
95 | /** |
---|
96 | * Comparison. Compares id attribute of widget. |
---|
97 | * @param SimpleWidget $widget Control to compare. |
---|
98 | * @access public |
---|
99 | */ |
---|
100 | function isMatch($widget) { |
---|
101 | return $widget->isId($this->_id); |
---|
102 | } |
---|
103 | } |
---|
104 | |
---|
105 | /** |
---|
106 | * Used to extract form elements for testing against. |
---|
107 | * Searches by visible label, name or alt text. |
---|
108 | * @package SimpleTest |
---|
109 | * @subpackage WebTester |
---|
110 | */ |
---|
111 | class SimpleByLabelOrName { |
---|
112 | var $_label; |
---|
113 | |
---|
114 | /** |
---|
115 | * Stashes the name/label for later comparison. |
---|
116 | * @param string $label Visible text to match. |
---|
117 | */ |
---|
118 | function SimpleByLabelOrName($label) { |
---|
119 | $this->_label = $label; |
---|
120 | } |
---|
121 | |
---|
122 | /** |
---|
123 | * Comparison. Compares visible text of widget or |
---|
124 | * related label or name. |
---|
125 | * @param SimpleWidget $widget Control to compare. |
---|
126 | * @access public |
---|
127 | */ |
---|
128 | function isMatch($widget) { |
---|
129 | if (method_exists($widget, 'isLabel')) { |
---|
130 | if ($widget->isLabel($this->_label)) { |
---|
131 | return true; |
---|
132 | } |
---|
133 | } |
---|
134 | return ($widget->getName() == $this->_label); |
---|
135 | } |
---|
136 | } |
---|
137 | ?> |
---|