LimeMockInvocationMatcherInterface.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. * Verifies whether some criteria has been fulfilled for a method invocation.
  13. *
  14. * You can configure a number of matchers for a method invocation in class
  15. * LimeExpectedInvocation. If a method is invoked and the method
  16. * signature and parameters match the expected invocation, the method call
  17. * is passed to the invoke() method of all associated matchers. This method
  18. * decides whether the invocation is valid and throws a
  19. * LimeMockInvocationMatcherException if it is not.
  20. *
  21. * When the mock object is verified, the method isSatisfied() is queried on all
  22. * matchers of every method. If all matchers are satisfied, the invocation
  23. * expectation is considered to be fulfilled.
  24. *
  25. * The method isInvokable() returns whether the matcher accepts any more
  26. * invocations. For example, if a matcher only accepts 3 invocation and throws
  27. * exceptions after that, isInvokable() should return false as soon as these
  28. * three invocations have been made.
  29. *
  30. * @package Lime
  31. * @author Bernhard Schussek <bernhard.schussek@symfony-project.com>
  32. * @version SVN: $Id: LimeMockInvocationMatcherInterface.php 23701 2009-11-08 21:23:40Z bschussek $
  33. */
  34. interface LimeMockInvocationMatcherInterface
  35. {
  36. /**
  37. * Notifies the matcher of a given method invocation.
  38. *
  39. * If the matcher decides that the method should not have been invoked, it
  40. * must throw an exception in this method.
  41. *
  42. * @param LimeMockInvocation $invocation The method invocation
  43. * @throws LimeMockInvocationMatcherException If the invocation was not valid
  44. */
  45. public function invoke(LimeMockInvocation $invocation);
  46. /**
  47. * Returns whether the matcher accepts any more invokations.
  48. *
  49. * @return boolean
  50. */
  51. public function isInvokable();
  52. /**
  53. * Returns whether the matcher's criteria is fulfilled.
  54. *
  55. * The matcher's criteria could be, for instance, that a method must be
  56. * invoked at least 3 times. As soon as this is the case, isSatisfied()
  57. * returns TRUE.
  58. *
  59. * @return boolean
  60. */
  61. public function isSatisfied();
  62. /**
  63. * The message describing the purpose of the matcher that is appended to
  64. * the method name in the test output.
  65. *
  66. * If this message returns "with any parameters", the resulting output is
  67. * "doSomething(x) was called with any parameters".
  68. *
  69. * @return string
  70. */
  71. public function getMessage();
  72. }