FunctionRejectTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace React\Promise;
  3. class FunctionRejectTest extends TestCase
  4. {
  5. /** @test */
  6. public function shouldRejectAnImmediateValue()
  7. {
  8. $expected = 123;
  9. $mock = $this->createCallableMock();
  10. $mock
  11. ->expects($this->once())
  12. ->method('__invoke')
  13. ->with($this->identicalTo($expected));
  14. reject($expected)
  15. ->then(
  16. $this->expectCallableNever(),
  17. $mock
  18. );
  19. }
  20. /** @test */
  21. public function shouldRejectAFulfilledPromise()
  22. {
  23. $expected = 123;
  24. $resolved = new FulfilledPromise($expected);
  25. $mock = $this->createCallableMock();
  26. $mock
  27. ->expects($this->once())
  28. ->method('__invoke')
  29. ->with($this->identicalTo($expected));
  30. reject($resolved)
  31. ->then(
  32. $this->expectCallableNever(),
  33. $mock
  34. );
  35. }
  36. /** @test */
  37. public function shouldRejectARejectedPromise()
  38. {
  39. $expected = 123;
  40. $resolved = new RejectedPromise($expected);
  41. $mock = $this->createCallableMock();
  42. $mock
  43. ->expects($this->once())
  44. ->method('__invoke')
  45. ->with($this->identicalTo($expected));
  46. reject($resolved)
  47. ->then(
  48. $this->expectCallableNever(),
  49. $mock
  50. );
  51. }
  52. }