PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/demos/phpdemo/application/libraries/simpletest/selector.php

https://github.com/cccarey/demisauce
PHP | 137 lines | 51 code | 14 blank | 72 comment | 5 complexity | 3bfc4aec63b1f95bb9b2a7317fc9e2e3 MD5 | raw file
Possible License(s): MIT, LGPL-2.1
  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. * include SimpleTest files
  10. */
  11. require_once(dirname(__FILE__) . '/tag.php');
  12. require_once(dirname(__FILE__) . '/encoding.php');
  13. /**#@-*/
  14. /**
  15. * Used to extract form elements for testing against.
  16. * Searches by name attribute.
  17. * @package SimpleTest
  18. * @subpackage WebTester
  19. */
  20. class SimpleByName {
  21. var $_name;
  22. /**
  23. * Stashes the name for later comparison.
  24. * @param string $name Name attribute to match.
  25. */
  26. function SimpleByName($name) {
  27. $this->_name = $name;
  28. }
  29. function getName() {
  30. return $this->_name;
  31. }
  32. /**
  33. * Compares with name attribute of widget.
  34. * @param SimpleWidget $widget Control to compare.
  35. * @access public
  36. */
  37. function isMatch($widget) {
  38. return ($widget->getName() == $this->_name);
  39. }
  40. }
  41. /**
  42. * Used to extract form elements for testing against.
  43. * Searches by visible label or alt text.
  44. * @package SimpleTest
  45. * @subpackage WebTester
  46. */
  47. class SimpleByLabel {
  48. var $_label;
  49. /**
  50. * Stashes the name for later comparison.
  51. * @param string $label Visible text to match.
  52. */
  53. function SimpleByLabel($label) {
  54. $this->_label = $label;
  55. }
  56. /**
  57. * Comparison. Compares visible text of widget or
  58. * related label.
  59. * @param SimpleWidget $widget Control to compare.
  60. * @access public
  61. */
  62. function isMatch($widget) {
  63. if (! method_exists($widget, 'isLabel')) {
  64. return false;
  65. }
  66. return $widget->isLabel($this->_label);
  67. }
  68. }
  69. /**
  70. * Used to extract form elements for testing against.
  71. * Searches dy id attribute.
  72. * @package SimpleTest
  73. * @subpackage WebTester
  74. */
  75. class SimpleById {
  76. var $_id;
  77. /**
  78. * Stashes the name for later comparison.
  79. * @param string $id ID atribute to match.
  80. */
  81. function SimpleById($id) {
  82. $this->_id = $id;
  83. }
  84. /**
  85. * Comparison. Compares id attribute of widget.
  86. * @param SimpleWidget $widget Control to compare.
  87. * @access public
  88. */
  89. function isMatch($widget) {
  90. return $widget->isId($this->_id);
  91. }
  92. }
  93. /**
  94. * Used to extract form elements for testing against.
  95. * Searches by visible label, name or alt text.
  96. * @package SimpleTest
  97. * @subpackage WebTester
  98. */
  99. class SimpleByLabelOrName {
  100. var $_label;
  101. /**
  102. * Stashes the name/label for later comparison.
  103. * @param string $label Visible text to match.
  104. */
  105. function SimpleByLabelOrName($label) {
  106. $this->_label = $label;
  107. }
  108. /**
  109. * Comparison. Compares visible text of widget or
  110. * related label or name.
  111. * @param SimpleWidget $widget Control to compare.
  112. * @access public
  113. */
  114. function isMatch($widget) {
  115. if (method_exists($widget, 'isLabel')) {
  116. if ($widget->isLabel($this->_label)) {
  117. return true;
  118. }
  119. }
  120. return ($widget->getName() == $this->_label);
  121. }
  122. }
  123. ?>