WindowsTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace League\CLImate\Tests;
  3. use Mockery;
  4. class WindowsTest extends TestBase
  5. {
  6. /** @test */
  7. public function it_can_get_the_width()
  8. {
  9. $system = Mockery::mock('League\CLImate\Util\System\Windows')
  10. ->makePartial()
  11. ->shouldAllowMockingProtectedMethods();
  12. $system->shouldReceive('exec')->with('mode CON', true)->andReturn(['Height: 100', 'Width: 50']);
  13. $this->assertEquals(50, $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\Windows')
  19. ->makePartial()
  20. ->shouldAllowMockingProtectedMethods();
  21. $system->shouldReceive('exec')->with('mode CON', true)->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\Windows')
  28. ->makePartial()
  29. ->shouldAllowMockingProtectedMethods();
  30. $system->shouldReceive('exec')->with('mode CON', true)->andReturn(['Height: 100', 'Width: 50']);
  31. $this->assertEquals(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\Windows')
  37. ->makePartial()
  38. ->shouldAllowMockingProtectedMethods();
  39. $system->shouldReceive('exec')->with('mode CON', true)->andReturn('error');
  40. $this->assertNull($system->height());
  41. }
  42. }