TestCase.php 895 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace React\Promise;
  3. class TestCase extends \PHPUnit_Framework_TestCase
  4. {
  5. public function expectCallableExactly($amount)
  6. {
  7. $mock = $this->createCallableMock();
  8. $mock
  9. ->expects($this->exactly($amount))
  10. ->method('__invoke');
  11. return $mock;
  12. }
  13. public function expectCallableOnce()
  14. {
  15. $mock = $this->createCallableMock();
  16. $mock
  17. ->expects($this->once())
  18. ->method('__invoke');
  19. return $mock;
  20. }
  21. public function expectCallableNever()
  22. {
  23. $mock = $this->createCallableMock();
  24. $mock
  25. ->expects($this->never())
  26. ->method('__invoke');
  27. return $mock;
  28. }
  29. public function createCallableMock()
  30. {
  31. return $this
  32. ->getMockBuilder('React\\Promise\Stub\CallableStub')
  33. ->getMock();
  34. }
  35. }