Source for file Action.php

Documentation is available at Action.php

  1. <?php
  2. /**
  3. * FIT Fixture: ActionFixture
  4. *
  5. * $Id$
  6. *
  7. * @author Luis A. Floreani <luis.floreani@gmail.com>
  8. * @author gERD Schaufelberger <gerd@php-tools.net>
  9. * @package FIT
  10. * @subpackage Fixture
  11. * @license LGPL http://www.gnu.org/copyleft/lesser.html
  12. * @copyright Copyright (c) 2002-2005 Cunningham & Cunningham, Inc.
  13. */
  14.  
  15. /**
  16. * load class TypeAdapter
  17. */
  18. include_once 'PHPFIT/TypeAdapter.php';
  19.  
  20. /**
  21. * FIT Fixture: ActionFixture
  22. *
  23. * An action fixture interprets rows as a sequence of commands to be performed
  24. * in order. It interprets tables for which the first column contains one of a
  25. * small number of commands. Subsequent columns contain values interpreted by
  26. * the particular command. The generic action fixture offers only four commands,
  27. * but subclasses may extend this set.
  28. *
  29. * @version 0.1.0
  30. * @package FIT
  31. * @subpackage Fixture
  32. */
  33. class PHPFIT_Fixture_Action extends PHPFIT_Fixture {
  34.  
  35. /**
  36. * dictionary of variable types
  37. * @var int
  38. * @see getType()
  39. */
  40. protected $typeDict = array();
  41. /**
  42. * @var Parse
  43. */
  44. protected $cells;
  45.  
  46. /**
  47. * actor that has been startet
  48. * @var Fixture
  49. * @see start()
  50. */
  51. private $actor = null;
  52. /**
  53. * Implements start fixture
  54. *
  55. * Start aClass - Subsequent commands are directed to an instance of
  56. * aClass. This is similar to navigating to a particular GUI screen.
  57. *
  58. * @return void
  59. */
  60. public function start() {
  61. $aClass = $this->cells->more->text();
  62. $this->actor = $this->loadFixture( $aClass );
  63. }
  64. /**
  65. * Implements enter fixture
  66. *
  67. * Enter aMethod anArgument - Invoke aMethod with anArgument (of type
  68. * determined by aMethod.) This is similar to entering values into GUI fields.
  69. *
  70. * @return void
  71. */
  72. public function enter() {
  73. $aMethod = $this->camel( $this->cells->more->text() );
  74. $anArgument = $this->cells->more->more->text();
  75. $this->actor->$aMethod( $anArgument );
  76. }
  77. /**
  78. * Implements press fixture
  79. *
  80. * Press aMethod - Invoke aMethod with no arguments. This is
  81. * similar to pressing a GUI button.
  82. *
  83. * @return void
  84. */
  85. public function press() {
  86. $aMethod = $this->camel( $this->cells->more->text() );
  87. $this->actor->$aMethod();
  88. }
  89.  
  90. /**
  91. * Implements check fixture
  92. *
  93. * Check aMethod aValue - Invoke aMethod with no arguments.
  94. * Compare the returned value with aValue. This is similar to reading
  95. * values from a GUI screen.
  96. *
  97. * @return void
  98. */
  99. public function check() {
  100. $aMethod = $this->camel( $this->cells->more->text() );
  101. $aValue = $this->cells->more->more;
  102. $adapter = PHPFIT_TypeAdapter::onMethod( $this->actor, $aMethod );
  103. $this->checkCell( $aValue, $adapter );
  104. }
  105. /**
  106. * process cells
  107. *
  108. * In case of ActionFixture each row has to be interpreted as a command
  109. * Processing cells means to execute one command.
  110. *
  111. * An action fixture interprets tables for which the first column contains
  112. * one of a small number of commands. Subsequent columns contain values
  113. * interpreted by the particular command. The generic action fixture offers
  114. * only four commands, but subclasses may extend this set.
  115. *
  116. * @param object $cells A parse object
  117. * @return void
  118. */
  119. public function doCells( $cells ) {
  120. try {
  121. $this->cells = $cells;
  122. $method = $cells->text();
  123. if( !method_exists( $this, $method ) ) {
  124. throw new Exception( 'Action fixture cannot call the request command. Method '
  125. . get_class( $this ) . '->' . $method . ' does not exist' );
  126. }
  127. $this->$method();
  128. }
  129. catch( Exception $e ) {
  130. $this->exception( $cells, $e );
  131. }
  132. }
  133. }
  134. ?>

Documentation generated on Sun, 02 Apr 2006 23:20:49 +0000 by phpDocumentor 1.3.0RC5