LimeMockBehaviourInterface.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /*
  3. * This file is part of the Lime test framework.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. * (c) Bernhard Schussek <bernhard.schussek@symfony-project.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. /**
  12. * A behaviour specifies how the mock compares expected method invocations with
  13. * actual method invocations.
  14. *
  15. * The behaviour is fed with different invocation expectations by calling the
  16. * method expect(). Later, the method invoke() is called for all actual
  17. * invocations. The behaviour has to decide which expectations to compare
  18. * with incoming actual invocations. One behaviour implementation may, for
  19. * example, decide to accept invoked invocations only if they are called
  20. * in the same order as the invocation expectations.
  21. *
  22. * In the end, verify() can be called on the behaviour to verify whether all
  23. * expectations have been met.
  24. *
  25. * The behaviour should pass the matching of methods and method verification
  26. * to LimeMockInvocationExpectation.
  27. *
  28. * @package Lime
  29. * @author Bernhard Schussek <bernhard.schussek@symfony-project.com>
  30. * @version SVN: $Id: LimeMockBehaviourInterface.php 23880 2009-11-14 10:14:34Z bschussek $
  31. */
  32. interface LimeMockBehaviourInterface
  33. {
  34. /**
  35. * Adds the following invocation expectation.
  36. *
  37. * @param LimeMockInvocationExpectation $invocation
  38. */
  39. public function expect(LimeMockInvocationExpectation $invocation);
  40. /**
  41. * Invokes the given method invocation.
  42. *
  43. * If the method invocation is not expected, this method should throw a
  44. * LimeMockInvocationException. Otherwise the call should be passed to
  45. * the method invoke() of LimeMockInvocationExpectation, its return value
  46. * should be returned.
  47. *
  48. * @param LimeMockInvocation $invocation The invoked method
  49. * @return mixed The return value of
  50. * LimeMockInvocationExpectation#invoke()
  51. * @throws LimeMockInvocationException If the method should not have been
  52. * invoked
  53. */
  54. public function invoke(LimeMockInvocation $invocation);
  55. /**
  56. * Returns whether the given method is invokable.
  57. *
  58. * @param LimeMockMethod $method The method
  59. * @return boolean TRUE if the method is invokable
  60. */
  61. public function isInvokable(LimeMockMethod $method);
  62. /**
  63. * Verifies whether all expectations have been fulfilled.
  64. *
  65. * You should call LimeMockInvocationExpectation#verify() to implement this
  66. * method.
  67. */
  68. public function verify();
  69. /**
  70. * Configures the behaviour to expect no method to be invoked.
  71. */
  72. public function setExpectNothing();
  73. /**
  74. * Clears all invocation expectations in the behaviour.
  75. */
  76. public function reset();
  77. }