sfTester.class.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * sfTester is the base class for all tester classes.
  11. *
  12. * @package symfony
  13. * @subpackage test
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfTester.class.php 13691 2008-12-03 22:17:01Z Kris.Wallsmith $
  16. */
  17. abstract class sfTester
  18. {
  19. protected
  20. $inABlock = false,
  21. $browser = null,
  22. $tester = null;
  23. /**
  24. * Constructor.
  25. *
  26. * @param sfTestFunctionalBase $browser A browser
  27. * @param lime_test $tester A tester object
  28. */
  29. public function __construct(sfTestFunctionalBase $browser, $tester)
  30. {
  31. $this->browser = $browser;
  32. $this->tester = $tester;
  33. }
  34. /**
  35. * Prepares the tester.
  36. */
  37. abstract public function prepare();
  38. /**
  39. * Initializes the tester.
  40. */
  41. abstract public function initialize();
  42. /**
  43. * Begins a block.
  44. *
  45. * @return sfTester This sfTester instance
  46. */
  47. public function begin()
  48. {
  49. $this->inABlock = true;
  50. return $this->browser->begin();
  51. }
  52. /**
  53. * Ends a block.
  54. *
  55. * @param sfTestFunctionalBase
  56. */
  57. public function end()
  58. {
  59. $this->inABlock = false;
  60. return $this->browser->end();
  61. }
  62. /**
  63. * Returns the object that each test method must return.
  64. *
  65. * @return sfTestFunctionalBase|sfTester
  66. */
  67. public function getObjectToReturn()
  68. {
  69. return $this->inABlock ? $this : $this->browser;
  70. }
  71. public function __call($method, $arguments)
  72. {
  73. call_user_func_array(array($this->browser, $method), $arguments);
  74. return $this->getObjectToReturn();
  75. }
  76. }