summaryrefslogtreecommitdiff
path: root/tests/test_tools/simpletest/frames.php
diff options
context:
space:
mode:
authorxue <>2006-07-16 01:50:23 +0000
committerxue <>2006-07-16 01:50:23 +0000
commitaf68030fcf0c266300feb2c100149ecadef7d364 (patch)
tree76b7c8ad5d8227870b9ef10c3e7b92a36336b320 /tests/test_tools/simpletest/frames.php
parent4b78404c20490a615459267426ce9e6737bf4485 (diff)
Merge from 3.0 branch till 1264.
Diffstat (limited to 'tests/test_tools/simpletest/frames.php')
-rw-r--r--tests/test_tools/simpletest/frames.php241
1 files changed, 78 insertions, 163 deletions
diff --git a/tests/test_tools/simpletest/frames.php b/tests/test_tools/simpletest/frames.php
index 75951476..8eefbe8d 100644
--- a/tests/test_tools/simpletest/frames.php
+++ b/tests/test_tools/simpletest/frames.php
@@ -3,7 +3,7 @@
* Base include file for SimpleTest
* @package SimpleTest
* @subpackage WebTester
- * @version $Id: frames.php,v 1.29 2004/11/30 05:33:56 lastcraft Exp $
+ * @version $Id: frames.php,v 1.39 2005/09/09 01:42:29 lastcraft Exp $
*/
/**#@+
@@ -12,7 +12,7 @@
require_once(dirname(__FILE__) . '/page.php');
require_once(dirname(__FILE__) . '/user_agent.php');
/**#@-*/
-
+
/**
* A composite page. Wraps a frameset page and
* adds subframes. The original page will be
@@ -26,7 +26,7 @@
protected $_frames;
protected $_focus;
protected $_names;
-
+
/**
* Stashes the frameset page. Will make use of the
* browser to fetch the sub frames recursively.
@@ -38,7 +38,7 @@
$this->_focus = false;
$this->_names = array();
}
-
+
/**
* Adds a parsed page to the frameset.
* @param SimplePage $page Frame page.
@@ -51,7 +51,7 @@
$this->_names[$name] = count($this->_frames) - 1;
}
}
-
+
/**
* Replaces existing frame with another. If the
* frame is nested, then the call is passed down
@@ -73,7 +73,7 @@
}
$this->_frames[$index]->setFrame($path, $page);
}
-
+
/**
* Accessor for current frame focus. Will be
* false if no frame has focus. Will have the nested
@@ -89,7 +89,7 @@
array($this->_getPublicNameFromIndex($this->_focus)),
$this->_frames[$this->_focus]->getFrameFocus());
}
-
+
/**
* Turns an internal array index into the frames list
* into a public name, or if none, then a one offset
@@ -106,7 +106,7 @@
}
return $subject + 1;
}
-
+
/**
* Sets the focus by index. The integer index starts from 1.
* If already focused and the target frame also has frames,
@@ -127,7 +127,7 @@
$this->_focus = $choice - 1;
return true;
}
-
+
/**
* Sets the focus by name. If already focused and the
* target frame also has frames, then the nested frame
@@ -148,7 +148,7 @@
}
return false;
}
-
+
/**
* Clears the frame focus.
* @access public
@@ -157,7 +157,7 @@
$this->_focus = false;
$this->_clearNestedFramesFocus();
}
-
+
/**
* Clears the frame focus for any nested frames.
* @access private
@@ -167,7 +167,7 @@
$this->_frames[$i]->clearFrameFocus();
}
}
-
+
/**
* Test for the presence of a frameset.
* @return boolean Always true.
@@ -176,7 +176,7 @@
function hasFrames() {
return true;
}
-
+
/**
* Accessor for frames information.
* @return array/string Recursive hash of frame URL strings.
@@ -192,7 +192,7 @@
}
return $report;
}
-
+
/**
* Accessor for raw text of either all the pages or
* the frame in focus.
@@ -209,7 +209,7 @@
}
return $raw;
}
-
+
/**
* Accessor for plain text of either all the pages or
* the frame in focus.
@@ -226,7 +226,7 @@
}
return trim($raw);
}
-
+
/**
* Accessor for last error.
* @return string Error from last response.
@@ -238,7 +238,7 @@
}
return $this->_frameset->getTransportError();
}
-
+
/**
* Request method used to fetch this frame.
* @return string GET, POST or HEAD.
@@ -250,7 +250,7 @@
}
return $this->_frameset->getMethod();
}
-
+
/**
* Original resource name.
* @return SimpleUrl Current url.
@@ -265,7 +265,7 @@
}
return $url;
}
-
+
/**
* Original request data.
* @return mixed Sent content.
@@ -277,7 +277,7 @@
}
return $this->_frameset->getRequestData();
}
-
+
/**
* Accessor for current MIME type.
* @return string MIME type as string; e.g. 'text/html'
@@ -289,7 +289,7 @@
}
return $this->_frameset->getMimeType();
}
-
+
/**
* Accessor for last response code.
* @return integer Last HTTP response code received.
@@ -301,7 +301,7 @@
}
return $this->_frameset->getResponseCode();
}
-
+
/**
* Accessor for last Authentication type. Only valid
* straight after a challenge (401).
@@ -314,7 +314,7 @@
}
return $this->_frameset->getAuthentication();
}
-
+
/**
* Accessor for last Authentication realm. Only valid
* straight after a challenge (401).
@@ -327,7 +327,7 @@
}
return $this->_frameset->getRealm();
}
-
+
/**
* Accessor for outgoing header information.
* @return string Header block.
@@ -339,7 +339,7 @@
}
return $this->_frameset->getRequest();
}
-
+
/**
* Accessor for raw header information.
* @return string Header block.
@@ -351,7 +351,7 @@
}
return $this->_frameset->getHeaders();
}
-
+
/**
* Accessor for parsed title.
* @return string Title or false if no title is present.
@@ -360,7 +360,7 @@
function getTitle() {
return $this->_frameset->getTitle();
}
-
+
/**
* Accessor for a list of all fixed links.
* @return array List of urls with scheme of
@@ -377,7 +377,7 @@
}
return array_values(array_unique($urls));
}
-
+
/**
* Accessor for a list of all relative links.
* @return array List of urls without hostname.
@@ -393,7 +393,7 @@
}
return array_values(array_unique($urls));
}
-
+
/**
* Accessor for URLs by the link label. Label will match
* regardess of whitespace issues and case.
@@ -417,7 +417,7 @@
}
return $urls;
}
-
+
/**
* Accessor for a URL by the id attribute. If in a frameset
* then the first link found with that ID attribute is
@@ -438,7 +438,7 @@
}
return false;
}
-
+
/**
* Attaches the intended frame index to a list of URLs.
* @param array $urls List of SimpleUrls.
@@ -456,85 +456,35 @@
}
return $tagged;
}
-
- /**
- * Finds a held form by button label. Will only
- * search correctly built forms. The first form found
- * either within the focused frame, or across frames,
- * will be the one returned.
- * @param string $label Button label, default 'Submit'.
- * @return SimpleForm Form object containing the button.
- * @access public
- */
- function getFormBySubmitLabel($label) {
- return $this->_findForm('getFormBySubmitLabel', $label);
- }
-
+
/**
* Finds a held form by button label. Will only
- * search correctly built forms. The first form found
- * either within the focused frame, or across frames,
- * will be the one returned.
- * @param string $name Button name attribute.
- * @return SimpleForm Form object containing the button.
+ * search correctly built forms.
+ * @param SimpleSelector $selector Button finder.
+ * @return SimpleForm Form object containing
+ * the button.
* @access public
*/
- function getFormBySubmitName($name) {
- return $this->_findForm('getFormBySubmitName', $name);
- }
-
- /**
- * Finds a held form by button id. Will only
- * search correctly built forms. The first form found
- * either within the focused frame, or across frames,
- * will be the one returned.
- * @param string $id Button ID attribute.
- * @return SimpleForm Form object containing the button.
- * @access public
- */
- function getFormBySubmitId($id) {
- return $this->_findForm('getFormBySubmitId', $id);
- }
-
- /**
- * Finds a held form by image label. Will only
- * search correctly built forms. The first form found
- * either within the focused frame, or across frames,
- * will be the one returned.
- * @param string $label Usually the alt attribute.
- * @return SimpleForm Form object containing the image.
- * @access public
- */
- function getFormByImageLabel($label) {
- return $this->_findForm('getFormByImageLabel', $label);
- }
-
- /**
- * Finds a held form by image button id. Will only
- * search correctly built forms. The first form found
- * either within the focused frame, or across frames,
- * will be the one returned.
- * @param string $name Image name.
- * @return SimpleForm Form object containing the image.
- * @access public
- */
- function getFormByImageName($name) {
- return $this->_findForm('getFormByImageName', $name);
+ function &getFormBySubmit($selector) {
+ $form = $this->_findForm('getFormBySubmit', $selector);
+ return $form;
}
-
+
/**
- * Finds a held form by image button id. Will only
- * search correctly built forms. The first form found
- * either within the focused frame, or across frames,
- * will be the one returned.
- * @param string $id Image ID attribute.
- * @return SimpleForm Form object containing the image.
+ * Finds a held form by image using a selector.
+ * Will only search correctly built forms. The first
+ * form found either within the focused frame, or
+ * across frames, will be the one returned.
+ * @param SimpleSelector $selector Image finder.
+ * @return SimpleForm Form object containing
+ * the image.
* @access public
*/
- function getFormByImageId($id) {
- return $this->_findForm('getFormByImageId', $id);
+ function &getFormByImage($selector) {
+ $form = $this->_findForm('getFormByImage', $selector);
+ return $form;
}
-
+
/**
* Finds a held form by the form ID. A way of
* identifying a specific form when we have control
@@ -545,25 +495,27 @@
* @return SimpleForm Form object containing the matching ID.
* @access public
*/
- function getFormById($id) {
- return $this->_findForm('getFormById', $id);
+ function &getFormById($id) {
+ $form = $this->_findForm('getFormById', $id);
+ return $form;
}
-
+
/**
* General form finder. Will search all the frames or
* just the one in focus.
* @param string $method Method to use to find in a page.
* @param string $attribute Label, name or ID.
* @return SimpleForm Form object containing the matching ID.
- * @access protected
+ * @access private
*/
- function _findForm($method, $attribute) {
+ function &_findForm($method, $attribute) {
if (is_integer($this->_focus)) {
- return $this->_findFormInFrame(
+ $form = $this->_findFormInFrame(
$this->_frames[$this->_focus],
$this->_focus,
$method,
$attribute);
+ return $form;
}
for ($i = 0; $i < count($this->_frames); $i++) {
$form = $this->_findFormInFrame(
@@ -575,9 +527,10 @@
return $form;
}
}
- return null;
+ $null = null;
+ return $null;
}
-
+
/**
* Finds a form in a page using a form finding method. Will
* also tag the form with the frame name it belongs in.
@@ -586,83 +539,45 @@
* @param string $method Method to use to find in a page.
* @param string $attribute Label, name or ID.
* @return SimpleForm Form object containing the matching ID.
- * @access protected
+ * @access private
*/
- function _findFormInFrame($page, $index, $method, $attribute) {
+ function &_findFormInFrame($page, $index, $method, $attribute) {
$form = $this->_frames[$index]->$method($attribute);
if (isset($form)) {
$form->setDefaultTarget($this->_getPublicNameFromIndex($index));
}
return $form;
}
-
+
/**
* Sets a field on each form in which the field is
* available.
- * @param string $name Field name.
- * @param string $value Value to set field to.
- * @return boolean True if value is valid.
- * @access public
- */
- function setField($name, $value) {
- if (is_integer($this->_focus)) {
- $this->_frames[$this->_focus]->setField($name, $value);
- } else {
- for ($i = 0; $i < count($this->_frames); $i++) {
- $this->_frames[$i]->setField($name, $value);
- }
- }
- }
-
- /**
- * Sets a field on the form in which the unique field is
- * available.
- * @param string/integer $id Field ID attribute.
- * @param string $value Value to set field to.
- * @return boolean True if value is valid.
+ * @param SimpleSelector $selector Field finder.
+ * @param string $value Value to set field to.
+ * @return boolean True if value is valid.
* @access public
*/
- function setFieldById($id, $value) {
+ function setField($selector, $value) {
if (is_integer($this->_focus)) {
- $this->_frames[$this->_focus]->setFieldById($id, $value);
+ $this->_frames[$this->_focus]->setField($selector, $value);
} else {
for ($i = 0; $i < count($this->_frames); $i++) {
- $this->_frames[$i]->setFieldById($id, $value);
+ $this->_frames[$i]->setField($selector, $value);
}
}
}
-
- /**
- * Accessor for a form element value within a frameset.
- * Finds the first match amongst the frames.
- * @param string $name Field name.
- * @return string/boolean A string if the field is
- * present, false if unchecked
- * and null if missing.
- * @access public
- */
- function getField($name) {
- for ($i = 0; $i < count($this->_frames); $i++) {
- $value = $this->_frames[$i]->getField($name);
- if (isset($value)) {
- return $value;
- }
- }
- return null;
- }
-
+
/**
* Accessor for a form element value within a page.
- * Finds the first match.
- * @param string/integer $id Field ID attribute.
- * @return string/boolean A string if the field is
- * present, false if unchecked
- * and null if missing.
+ * @param SimpleSelector $selector Field finder.
+ * @return string/boolean A string if the field is
+ * present, false if unchecked
+ * and null if missing.
* @access public
*/
- function getFieldById($id) {
+ function getField($selector) {
for ($i = 0; $i < count($this->_frames); $i++) {
- $value = $this->_frames[$i]->getFieldById($id);
+ $value = $this->_frames[$i]->getField($selector);
if (isset($value)) {
return $value;
}