Source for file selector.php

Documentation is available at selector.php

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

Documentation generated on Sun, 04 May 2008 09:22:05 -0500 by phpDocumentor 1.3.0