Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
    /**
3
     *	Base include file for SimpleTest.
4
     *	@package	SimpleTest
5
     *	@subpackage	WebTester
6
     *	@version	$Id: selector.php 1398 2006-09-08 19:31:03Z xue $
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
        protected $_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
        /**
34
         *    Compares with name attribute of widget.
35
         *    @param SimpleWidget $widget    Control to compare.
36
         *    @access public
37
         */
38
        function isMatch($widget) {
39
            return ($widget->getName() == $this->_name);
40
        }
41
    }
42
 
43
    /**
44
     *    Used to extract form elements for testing against.
45
     *    Searches by visible label or alt text.
46
	 *    @package SimpleTest
47
	 *    @subpackage WebTester
48
     */
49
    class SimpleByLabel {
50
        protected $_label;
51
 
52
        /**
53
         *    Stashes the name for later comparison.
54
         *    @param string $label     Visible text to match.
55
         */
56
        function SimpleByLabel($label) {
57
            $this->_label = $label;
58
        }
59
 
60
        /**
61
         *    Comparison. Compares visible text of widget or
62
         *    related label.
63
         *    @param SimpleWidget $widget    Control to compare.
64
         *    @access public
65
         */
66
        function isMatch($widget) {
67
            if (! method_exists($widget, 'isLabel')) {
68
                return false;
69
            }
70
            return $widget->isLabel($this->_label);
71
        }
72
    }
73
 
74
    /**
75
     *    Used to extract form elements for testing against.
76
     *    Searches dy id attribute.
77
	 *    @package SimpleTest
78
	 *    @subpackage WebTester
79
     */
80
    class SimpleById {
81
        protected $_id;
82
 
83
        /**
84
         *    Stashes the name for later comparison.
85
         *    @param string $id     ID atribute to match.
86
         */
87
        function SimpleById($id) {
88
            $this->_id = $id;
89
        }
90
 
91
        /**
92
         *    Comparison. Compares id attribute of widget.
93
         *    @param SimpleWidget $widget    Control to compare.
94
         *    @access public
95
         */
96
        function isMatch($widget) {
97
            return $widget->isId($this->_id);
98
        }
99
    }
100
 
101
    /**
102
     *    Used to extract form elements for testing against.
103
     *    Searches by visible label, name or alt text.
104
	 *    @package SimpleTest
105
	 *    @subpackage WebTester
106
     */
107
    class SimpleByLabelOrName {
108
        protected $_label;
109
 
110
        /**
111
         *    Stashes the name/label for later comparison.
112
         *    @param string $label     Visible text to match.
113
         */
114
        function SimpleByLabelOrName($label) {
115
            $this->_label = $label;
116
        }
117
 
118
        /**
119
         *    Comparison. Compares visible text of widget or
120
         *    related label or name.
121
         *    @param SimpleWidget $widget    Control to compare.
122
         *    @access public
123
         */
124
        function isMatch($widget) {
125
            if (method_exists($widget, 'isLabel')) {
126
                if ($widget->isLabel($this->_label)) {
127
                    return true;
128
                }
129
            }
130
            return ($widget->getName() == $this->_label);
131
        }
132
    }
133
?>