LimeMockInterface.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. * This interface is implemented by all mock objects.
  13. *
  14. * @package Lime
  15. * @author Bernhard Schussek <bernhard.schussek@symfony-project.com>
  16. * @version SVN: $Id: LimeMockInterface.php 23701 2009-11-08 21:23:40Z bschussek $
  17. * @see LimeMock
  18. */
  19. interface LimeMockInterface
  20. {
  21. /**
  22. * Constructor.
  23. *
  24. * @param string $class The name of the mocked class
  25. * @param LimeMockBehaviourInterface $behaviour The behaviour for invocation
  26. * comparisons.
  27. * @param LimeOutputInterface $output The output for displaying
  28. * the comparison results.
  29. */
  30. public function __construct($class, LimeMockBehaviourInterface $behaviour, LimeOutputInterface $output);
  31. /**
  32. * Invokes the given method.
  33. *
  34. * The mock reacts accordingly depending on whether it is in record or in
  35. * replay mode. In record mode, mocks return an instance of
  36. * LimeMockInvocationExpectation, which you can use to further configure
  37. * the expected invocation. In replay mode, the configured return value
  38. * is returned. If you configured the method to throw an exception, this
  39. * exception will be thrown here.
  40. *
  41. * @param string $method The method
  42. * @param array $parameters The method parameters
  43. * @return LimeMockInvocationExpectation|mixed
  44. * @throws LimeMockException If the method should not have been invoked
  45. * @throws Exception If you configured the mock to throw an exception
  46. */
  47. public function __call($method, $parameters);
  48. /**
  49. * Switches the mock object into replay mode.
  50. *
  51. * @throws BadMethodCallException If the object already is in replay mode
  52. */
  53. public function __lime_replay();
  54. /**
  55. * Resets all expected invocations in the mock and switches it into record
  56. * mode.
  57. *
  58. * @see LimeMockBehaviourInterface#reset()
  59. */
  60. public function __lime_reset();
  61. /**
  62. * Returns the object representing the current state of the mock.
  63. *
  64. * @return LimeMockStateInterface
  65. */
  66. public function __lime_getState();
  67. }