summaryrefslogtreecommitdiff
path: root/tests/test_tools/simpletest/tag.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_tools/simpletest/tag.php')
-rw-r--r--tests/test_tools/simpletest/tag.php235
1 files changed, 117 insertions, 118 deletions
diff --git a/tests/test_tools/simpletest/tag.php b/tests/test_tools/simpletest/tag.php
index 5d8de890..46fb740a 100644
--- a/tests/test_tools/simpletest/tag.php
+++ b/tests/test_tools/simpletest/tag.php
@@ -5,14 +5,14 @@
* @subpackage WebTester
* @version $Id: tag.php 1398 2006-09-08 19:31:03Z xue $
*/
-
+
/**#@+
* include SimpleTest files
*/
require_once(dirname(__FILE__) . '/parser.php');
require_once(dirname(__FILE__) . '/encoding.php');
/**#@-*/
-
+
/**
* HTML or XML tag.
* @package SimpleTest
@@ -22,7 +22,7 @@
protected $_name;
protected $_attributes;
protected $_content;
-
+
/**
* Starts with a named tag with attributes only.
* @param string $name Tag name.
@@ -36,7 +36,7 @@
$this->_attributes = $attributes;
$this->_content = '';
}
-
+
/**
* Check to see if the tag can have both start and
* end tags with content in between.
@@ -46,7 +46,7 @@
function expectEndTag() {
return true;
}
-
+
/**
* The current tag should not swallow all content for
* itself as it's searchable page content. Private
@@ -68,7 +68,7 @@
function addContent($content) {
$this->_content .= (string)$content;
}
-
+
/**
* Adds an enclosed tag to the content.
* @param SimpleTag $tag New tag.
@@ -76,7 +76,7 @@
*/
function addTag($tag) {
}
-
+
/**
* Accessor for tag name.
* @return string Name of tag.
@@ -85,7 +85,7 @@
function getTagName() {
return $this->_name;
}
-
+
/**
* List of legal child elements.
* @return array List of element names.
@@ -94,7 +94,7 @@
function getChildElements() {
return array();
}
-
+
/**
* Accessor for an attribute.
* @param string $label Attribute name.
@@ -108,7 +108,7 @@
}
return (string)$this->_attributes[$label];
}
-
+
/**
* Sets an attribute.
* @param string $label Attribute name.
@@ -118,7 +118,7 @@
function _setAttribute($label, $value) {
$this->_attributes[strtolower($label)] = $value;
}
-
+
/**
* Accessor for the whole content so far.
* @return string Content as big raw string.
@@ -127,7 +127,7 @@
function getContent() {
return $this->_content;
}
-
+
/**
* Accessor for content reduced to visible text. Acts
* like a text mode browser, normalising space and
@@ -138,7 +138,7 @@
function getText() {
return SimpleHtmlSaxParser::normalise($this->_content);
}
-
+
/**
* Test to see if id attribute matches.
* @param string $id ID to test against.
@@ -149,14 +149,14 @@
return ($this->getAttribute('id') == $id);
}
}
-
+
/**
* Page title.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleTitleTag extends SimpleTag {
-
+
/**
* Starts with a named tag with attributes only.
* @param hash $attributes Attribute names and
@@ -166,14 +166,14 @@
$this->SimpleTag('title', $attributes);
}
}
-
+
/**
* Link.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleAnchorTag extends SimpleTag {
-
+
/**
* Starts with a named tag with attributes only.
* @param hash $attributes Attribute names and
@@ -182,7 +182,7 @@
function SimpleAnchorTag($attributes) {
$this->SimpleTag('a', $attributes);
}
-
+
/**
* Accessor for URL as string.
* @return string Coerced as string.
@@ -196,7 +196,7 @@
return $url;
}
}
-
+
/**
* Form element.
* @package SimpleTest
@@ -206,7 +206,7 @@
protected $_value;
protected $_label;
protected $_is_set;
-
+
/**
* Starts with a named tag with attributes only.
* @param string $name Tag name.
@@ -219,7 +219,7 @@
$this->_label = false;
$this->_is_set = false;
}
-
+
/**
* Accessor for name submitted as the key in
* GET/POST variables hash.
@@ -229,7 +229,7 @@
function getName() {
return $this->getAttribute('name');
}
-
+
/**
* Accessor for default value parsed with the tag.
* @return string Parsed value.
@@ -238,7 +238,7 @@
function getDefault() {
return $this->getAttribute('value');
}
-
+
/**
* Accessor for currently set value or default if
* none.
@@ -252,7 +252,7 @@
}
return $this->_value;
}
-
+
/**
* Sets the current form element value.
* @param string $value New value.
@@ -264,7 +264,7 @@
$this->_is_set = true;
return true;
}
-
+
/**
* Resets the form element value back to the
* default.
@@ -273,7 +273,7 @@
function resetValue() {
$this->_is_set = false;
}
-
+
/**
* Allows setting of a label externally, say by a
* label tag.
@@ -283,7 +283,7 @@
function setLabel($label) {
$this->_label = trim($label);
}
-
+
/**
* Reads external or internal label.
* @param string $label Label to test.
@@ -293,7 +293,7 @@
function isLabel($label) {
return $this->_label == trim($label);
}
-
+
/**
* Dispatches the value into the form encoded packet.
* @param SimpleEncoding $encoding Form packet.
@@ -305,14 +305,14 @@
}
}
}
-
+
/**
* Text, password and hidden field.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleTextTag extends SimpleWidget {
-
+
/**
* Starts with a named tag with attributes only.
* @param hash $attributes Attribute names and
@@ -324,7 +324,7 @@
$this->_setAttribute('value', '');
}
}
-
+
/**
* Tag contains no content.
* @return boolean False.
@@ -333,7 +333,7 @@
function expectEndTag() {
return false;
}
-
+
/**
* Sets the current form element value. Cannot
* change the value of a hidden field.
@@ -348,14 +348,14 @@
return parent::setValue($value);
}
}
-
+
/**
* Submit button as input tag.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleSubmitTag extends SimpleWidget {
-
+
/**
* Starts with a named tag with attributes only.
* @param hash $attributes Attribute names and
@@ -367,7 +367,7 @@
$this->_setAttribute('value', 'Submit');
}
}
-
+
/**
* Tag contains no end element.
* @return boolean False.
@@ -376,7 +376,7 @@
function expectEndTag() {
return false;
}
-
+
/**
* Disables the setting of the button value.
* @param string $value Ignored.
@@ -386,7 +386,7 @@
function setValue($value) {
return false;
}
-
+
/**
* Value of browser visible text.
* @return string Visible label.
@@ -395,7 +395,7 @@
function getLabel() {
return $this->getValue();
}
-
+
/**
* Test for a label match when searching.
* @param string $label Label to test.
@@ -406,14 +406,14 @@
return trim($label) == trim($this->getLabel());
}
}
-
+
/**
* Image button as input tag.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleImageSubmitTag extends SimpleWidget {
-
+
/**
* Starts with a named tag with attributes only.
* @param hash $attributes Attribute names and
@@ -422,7 +422,7 @@
function SimpleImageSubmitTag($attributes) {
$this->SimpleWidget('input', $attributes);
}
-
+
/**
* Tag contains no end element.
* @return boolean False.
@@ -431,7 +431,7 @@
function expectEndTag() {
return false;
}
-
+
/**
* Disables the setting of the button value.
* @param string $value Ignored.
@@ -441,7 +441,7 @@
function setValue($value) {
return false;
}
-
+
/**
* Value of browser visible text.
* @return string Visible label.
@@ -453,7 +453,7 @@
}
return $this->getAttribute('alt');
}
-
+
/**
* Test for a label match when searching.
* @param string $label Label to test.
@@ -463,7 +463,7 @@
function isLabel($label) {
return trim($label) == trim($this->getLabel());
}
-
+
/**
* Dispatches the value into the form encoded packet.
* @param SimpleEncoding $encoding Form packet.
@@ -481,14 +481,14 @@
}
}
}
-
+
/**
* Submit button as button tag.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleButtonTag extends SimpleWidget {
-
+
/**
* Starts with a named tag with attributes only.
* Defaults are very browser dependent.
@@ -498,7 +498,7 @@
function SimpleButtonTag($attributes) {
$this->SimpleWidget('button', $attributes);
}
-
+
/**
* Check to see if the tag can have both start and
* end tags with content in between.
@@ -508,7 +508,7 @@
function expectEndTag() {
return true;
}
-
+
/**
* Disables the setting of the button value.
* @param string $value Ignored.
@@ -518,7 +518,7 @@
function setValue($value) {
return false;
}
-
+
/**
* Value of browser visible text.
* @return string Visible label.
@@ -527,7 +527,7 @@
function getLabel() {
return $this->getContent();
}
-
+
/**
* Test for a label match when searching.
* @param string $label Label to test.
@@ -538,14 +538,14 @@
return trim($label) == trim($this->getLabel());
}
}
-
+
/**
* Content tag for text area.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleTextAreaTag extends SimpleWidget {
-
+
/**
* Starts with a named tag with attributes only.
* @param hash $attributes Attribute names and
@@ -554,7 +554,7 @@
function SimpleTextAreaTag($attributes) {
$this->SimpleWidget('textarea', $attributes);
}
-
+
/**
* Accessor for starting value.
* @return string Parsed value.
@@ -563,7 +563,7 @@
function getDefault() {
return $this->_wrap(SimpleHtmlSaxParser::decodeHtml($this->getContent()));
}
-
+
/**
* Applies word wrapping if needed.
* @param string $value New value.
@@ -573,7 +573,7 @@
function setValue($value) {
return parent::setValue($this->_wrap($value));
}
-
+
/**
* Test to see if text should be wrapped.
* @return boolean True if wrapping on.
@@ -588,7 +588,7 @@
}
return false;
}
-
+
/**
* Performs the formatting that is peculiar to
* this tag. There is strange behaviour in this
@@ -613,7 +613,7 @@
}
return $text;
}
-
+
/**
* The content of textarea is not part of the page.
* @return boolean True.
@@ -623,14 +623,14 @@
return true;
}
}
-
+
/**
* File upload widget.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleUploadTag extends SimpleWidget {
-
+
/**
* Starts with attributes only.
* @param hash $attributes Attribute names and
@@ -639,7 +639,7 @@
function SimpleUploadTag($attributes) {
$this->SimpleWidget('input', $attributes);
}
-
+
/**
* Tag contains no content.
* @return boolean False.
@@ -648,7 +648,7 @@
function expectEndTag() {
return false;
}
-
+
/**
* Dispatches the value into the form encoded packet.
* @param SimpleEncoding $encoding Form packet.
@@ -664,7 +664,7 @@
basename($this->getValue()));
}
}
-
+
/**
* Drop down widget.
* @package SimpleTest
@@ -673,7 +673,7 @@
class SimpleSelectionTag extends SimpleWidget {
protected $_options;
protected $_choice;
-
+
/**
* Starts with attributes only.
* @param hash $attributes Attribute names and
@@ -684,7 +684,7 @@
$this->_options = array();
$this->_choice = false;
}
-
+
/**
* Adds an option tag to a selection field.
* @param SimpleOptionTag $tag New option.
@@ -695,7 +695,7 @@
$this->_options[] = $tag;
}
}
-
+
/**
* Text within the selection element is ignored.
* @param string $content Ignored.
@@ -703,7 +703,7 @@
*/
function addContent($content) {
}
-
+
/**
* Scans options for defaults. If none, then
* the first option is selected.
@@ -721,7 +721,7 @@
}
return '';
}
-
+
/**
* Can only set allowed values.
* @param string $value New choice.
@@ -737,7 +737,7 @@
}
return false;
}
-
+
/**
* Accessor for current selection value.
* @return string Value attribute or
@@ -751,7 +751,7 @@
return $this->_options[$this->_choice]->getValue();
}
}
-
+
/**
* Drop down widget.
* @package SimpleTest
@@ -760,7 +760,7 @@
class MultipleSelectionTag extends SimpleWidget {
protected $_options;
protected $_values;
-
+
/**
* Starts with attributes only.
* @param hash $attributes Attribute names and
@@ -771,7 +771,7 @@
$this->_options = array();
$this->_values = false;
}
-
+
/**
* Adds an option tag to a selection field.
* @param SimpleOptionTag $tag New option.
@@ -782,7 +782,7 @@
$this->_options[] = $tag;
}
}
-
+
/**
* Text within the selection element is ignored.
* @param string $content Ignored.
@@ -790,7 +790,7 @@
*/
function addContent($content) {
}
-
+
/**
* Scans options for defaults to populate the
* value array().
@@ -806,7 +806,7 @@
}
return $default;
}
-
+
/**
* Can only set allowed values. Any illegal value
* will result in a failure, but all correct values
@@ -833,7 +833,7 @@
$this->_values = $achieved;
return true;
}
-
+
/**
* Accessor for current selection value.
* @return array List of currently set options.
@@ -846,21 +846,21 @@
return $this->_values;
}
}
-
+
/**
* Option for selection field.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleOptionTag extends SimpleWidget {
-
+
/**
* Stashes the attributes.
*/
function SimpleOptionTag($attributes) {
$this->SimpleWidget('option', $attributes);
}
-
+
/**
* Does nothing.
* @param string $value Ignored.
@@ -870,7 +870,7 @@
function setValue($value) {
return false;
}
-
+
/**
* Test to see if a value matches the option.
* @param string $compare Value to compare with.
@@ -884,7 +884,7 @@
}
return trim($this->getContent()) == $compare;
}
-
+
/**
* Accessor for starting value. Will be set to
* the option label if no value exists.
@@ -897,7 +897,7 @@
}
return $this->getAttribute('value');
}
-
+
/**
* The content of options is not part of the page.
* @return boolean True.
@@ -907,14 +907,14 @@
return true;
}
}
-
+
/**
* Radio button.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleRadioButtonTag extends SimpleWidget {
-
+
/**
* Stashes the attributes.
* @param array $attributes Hash of attributes.
@@ -925,7 +925,7 @@
$this->_setAttribute('value', 'on');
}
}
-
+
/**
* Tag contains no content.
* @return boolean False.
@@ -934,7 +934,7 @@
function expectEndTag() {
return false;
}
-
+
/**
* The only allowed value sn the one in the
* "value" attribute.
@@ -951,7 +951,7 @@
}
return parent::setValue($value);
}
-
+
/**
* Accessor for starting value.
* @return string Parsed value.
@@ -964,14 +964,14 @@
return false;
}
}
-
+
/**
* Checkbox widget.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleCheckboxTag extends SimpleWidget {
-
+
/**
* Starts with attributes only.
* @param hash $attributes Attribute names and
@@ -983,7 +983,7 @@
$this->_setAttribute('value', 'on');
}
}
-
+
/**
* Tag contains no content.
* @return boolean False.
@@ -992,7 +992,7 @@
function expectEndTag() {
return false;
}
-
+
/**
* The only allowed value in the one in the
* "value" attribute. The default for this
@@ -1014,7 +1014,7 @@
}
return parent::setValue($value);
}
-
+
/**
* Accessor for starting value. The default
* value is "on".
@@ -1028,7 +1028,7 @@
return false;
}
}
-
+
/**
* A group of multiple widgets with some shared behaviour.
* @package SimpleTest
@@ -1045,7 +1045,7 @@
function addWidget($widget) {
$this->_widgets[] = $widget;
}
-
+
/**
* Accessor to widget set.
* @return array All widgets.
@@ -1064,7 +1064,7 @@
function getAttribute($label) {
return false;
}
-
+
/**
* Fetches the name for the widget from the first
* member.
@@ -1076,7 +1076,7 @@
return $this->_widgets[0]->getName();
}
}
-
+
/**
* Scans the widgets for one with the appropriate
* ID field.
@@ -1092,7 +1092,7 @@
}
return false;
}
-
+
/**
* Scans the widgets for one with the appropriate
* attached label.
@@ -1108,7 +1108,7 @@
}
return false;
}
-
+
/**
* Dispatches the value into the form encoded packet.
* @param SimpleEncoding $encoding Form packet.
@@ -1125,7 +1125,7 @@
* @subpackage WebTester
*/
class SimpleCheckboxGroup extends SimpleTagGroup {
-
+
/**
* Accessor for current selected widget or false
* if none.
@@ -1142,7 +1142,7 @@
}
return $this->_coerceValues($values);
}
-
+
/**
* Accessor for starting value that is active.
* @return string/array Widget values or false if none.
@@ -1158,7 +1158,7 @@
}
return $this->_coerceValues($values);
}
-
+
/**
* Accessor for current set values.
* @param string/array/boolean $values Either a single string, a
@@ -1182,7 +1182,7 @@
}
return true;
}
-
+
/**
* Tests to see if a possible value set is legal.
* @param string/array/boolean $values Either a single string, a
@@ -1202,7 +1202,7 @@
}
return ($values == $matches);
}
-
+
/**
* Converts the output to an appropriate format. This means
* that no values is false, a single value is just that
@@ -1220,7 +1220,7 @@
return $values;
}
}
-
+
/**
* Converts false or string into array. The opposite of
* the coercian method.
@@ -1248,7 +1248,7 @@
* @subpackage WebTester
*/
class SimpleRadioGroup extends SimpleTagGroup {
-
+
/**
* Each tag is tried in turn until one is
* successfully set. The others will be
@@ -1270,7 +1270,7 @@
}
return true;
}
-
+
/**
* Tests to see if a value is allowed.
* @param string Attempted value.
@@ -1286,7 +1286,7 @@
}
return false;
}
-
+
/**
* Accessor for current selected widget or false
* if none.
@@ -1303,7 +1303,7 @@
}
return false;
}
-
+
/**
* Accessor for starting value that is active.
* @return string/boolean Value of first checked
@@ -1320,14 +1320,14 @@
return false;
}
}
-
+
/**
* Tag to keep track of labels.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleLabelTag extends SimpleTag {
-
+
/**
* Starts with a named tag with attributes only.
* @param hash $attributes Attribute names and
@@ -1336,7 +1336,7 @@
function SimpleLabelTag($attributes) {
$this->SimpleTag('label', $attributes);
}
-
+
/**
* Access for the ID to attach the label to.
* @return string For attribute.
@@ -1346,14 +1346,14 @@
return $this->getAttribute('for');
}
}
-
+
/**
* Tag to aid parsing the form.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleFormTag extends SimpleTag {
-
+
/**
* Starts with a named tag with attributes only.
* @param hash $attributes Attribute names and
@@ -1363,14 +1363,14 @@
$this->SimpleTag('form', $attributes);
}
}
-
+
/**
* Tag to aid parsing the frames in a page.
* @package SimpleTest
* @subpackage WebTester
*/
class SimpleFrameTag extends SimpleTag {
-
+
/**
* Starts with a named tag with attributes only.
* @param hash $attributes Attribute names and
@@ -1379,7 +1379,7 @@
function SimpleFrameTag($attributes) {
$this->SimpleTag('frame', $attributes);
}
-
+
/**
* Tag contains no content.
* @return boolean False.
@@ -1388,5 +1388,4 @@
function expectEndTag() {
return false;
}
- }
-?> \ No newline at end of file
+ } \ No newline at end of file