LinuxTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace League\CLImate\Tests;
  3. use Mockery;
  4. class LinuxTest extends TestBase
  5. {
  6. /** @test */
  7. public function it_can_get_the_width()
  8. {
  9. $system = Mockery::mock('League\CLImate\Util\System\Linux')
  10. ->makePartial()
  11. ->shouldAllowMockingProtectedMethods();
  12. $system->shouldReceive('exec')->with('tput cols')->andReturn(100);
  13. $this->assertSame(100, $system->width());
  14. }
  15. /** @test */
  16. public function it_will_return_null_if_width_is_not_numeric()
  17. {
  18. $system = Mockery::mock('League\CLImate\Util\System\Linux')
  19. ->makePartial()
  20. ->shouldAllowMockingProtectedMethods();
  21. $system->shouldReceive('exec')->with('tput cols')->andReturn('error');
  22. $this->assertNull($system->width());
  23. }
  24. /** @test */
  25. public function it_can_get_the_height()
  26. {
  27. $system = Mockery::mock('League\CLImate\Util\System\Linux')
  28. ->makePartial()
  29. ->shouldAllowMockingProtectedMethods();
  30. $system->shouldReceive('exec')->with('tput lines')->andReturn(100);
  31. $this->assertSame(100, $system->height());
  32. }
  33. /** @test */
  34. public function it_will_return_null_if_height_is_not_numeric()
  35. {
  36. $system = Mockery::mock('League\CLImate\Util\System\Linux')
  37. ->makePartial()
  38. ->shouldAllowMockingProtectedMethods();
  39. $system->shouldReceive('exec')->with('tput lines')->andReturn('error');
  40. $this->assertNull($system->height());
  41. }
  42. }