Expectation.php 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /*
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. //require 'Yay/MockObject.php';
  15. //require 'Yay/Invocation.php';
  16. //require 'Yay/Action.php';
  17. //require 'Yay/SelfDescribing.php';
  18. //require 'Yay/State.php';
  19. //require 'Yay/StatePredicate.php';
  20. //require 'Yay/Sequence.php';
  21. /**
  22. * An Invocation expectation.
  23. * @author Chris Corbyn <chris@w3style.co.uk>
  24. * @package Yay
  25. */
  26. interface Yay_Expectation extends Yay_SelfDescribing
  27. {
  28. /**
  29. * Specify the MockObject which the Invocation will occur.
  30. * This method should return the mock object in record mode.
  31. * @param Yay_MockObject $mock
  32. * @return Yay_MockObject
  33. */
  34. public function of(Yay_MockObject $mock);
  35. /**
  36. * Notify the Expectation of an Invocation and check if it matches.
  37. * @param Yay_Invocation $invocation
  38. * @return boolean
  39. */
  40. public function isExpected(Yay_Invocation $invocation);
  41. /**
  42. * Specify the Action to run if a match occurs.
  43. * @param Yay_Action $action
  44. */
  45. public function will(Yay_Action $action);
  46. /**
  47. * Only be expected when in the given State predicate.
  48. * @param Yay_StatePredicate $predicate
  49. */
  50. public function when(Yay_StatePredicate $predicate);
  51. /**
  52. * Activate the given $state if a match occurs.
  53. * @param Yay_State $state
  54. */
  55. public function then(Yay_State $state);
  56. /**
  57. * Constrain this expectation to be valid only if invoked in the given sequence.
  58. * @param Yay_Sequence $sequence
  59. */
  60. public function inSequence(Yay_Sequence $sequence);
  61. /**
  62. * Test if all conditions of the Invocation are satisfied.
  63. * @return boolean
  64. */
  65. public function isSatisfied();
  66. /**
  67. * Get the Action for the given Invocation.
  68. * This may have been specified by a will() clause.
  69. * @param Yay_Invocation $invocation
  70. * @return Yay_Action
  71. */
  72. public function getAction(Yay_Invocation $invocation);
  73. }