SleeperTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace League\CLImate\Tests;
  3. use League\CLImate\TerminalObject\Helper\Sleeper;
  4. require_once 'SleeperGlobalMock.php';
  5. class SleeperTest extends TestBase
  6. {
  7. /**
  8. * @test
  9. * @doesNotPerformAssertions
  10. */
  11. public function it_can_slow_down_the_sleeper_speed()
  12. {
  13. $sleeper = new Sleeper;
  14. $sleeper->speed(50);
  15. self::$functions->shouldReceive('usleep')
  16. ->once()
  17. ->with(100000);
  18. $sleeper->sleep();
  19. }
  20. /**
  21. * @test
  22. * @doesNotPerformAssertions
  23. */
  24. public function it_can_speed_up_the_sleeper_speed()
  25. {
  26. $sleeper = new Sleeper;
  27. $sleeper->speed(200);
  28. self::$functions->shouldReceive('usleep')
  29. ->once()
  30. ->with(25000);
  31. $sleeper->sleep();
  32. }
  33. /**
  34. * @test
  35. * @doesNotPerformAssertions
  36. */
  37. public function it_will_ignore_zero_percentages()
  38. {
  39. $sleeper = new Sleeper;
  40. $sleeper->speed(0);
  41. self::$functions->shouldReceive('usleep')
  42. ->once()
  43. ->with(50000);
  44. $sleeper->sleep();
  45. }
  46. }