SleeperTest.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. /** @test */
  8. public function it_can_slow_down_the_sleeper_speed()
  9. {
  10. $sleeper = new Sleeper;
  11. $sleeper->speed(50);
  12. self::$functions->shouldReceive('usleep')
  13. ->once()
  14. ->with(100000);
  15. $sleeper->sleep();
  16. }
  17. /** @test */
  18. public function it_can_speed_up_the_sleeper_speed()
  19. {
  20. $sleeper = new Sleeper;
  21. $sleeper->speed(200);
  22. self::$functions->shouldReceive('usleep')
  23. ->once()
  24. ->with(25000);
  25. $sleeper->sleep();
  26. }
  27. /** @test */
  28. public function it_will_ignore_zero_percentages()
  29. {
  30. $sleeper = new Sleeper;
  31. $sleeper->speed(0);
  32. self::$functions->shouldReceive('usleep')
  33. ->once()
  34. ->with(50000);
  35. $sleeper->sleep();
  36. }
  37. }