12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace League\CLImate\Tests\Util\System;
- use League\CLImate\Tests\TestBase;
- use League\CLImate\Util\System\Linux;
- use Mockery;
- class LinuxTest extends TestBase
- {
- /** @test */
- public function it_can_get_the_width()
- {
- $system = Mockery::mock(Linux::class)
- ->makePartial()
- ->shouldAllowMockingProtectedMethods();
- $system->shouldReceive('exec')->with('tput cols 2>/dev/null')->andReturn(100);
- $this->assertSame(100, $system->width());
- }
- /** @test */
- public function it_will_return_null_if_width_is_not_numeric()
- {
- $system = Mockery::mock(Linux::class)
- ->makePartial()
- ->shouldAllowMockingProtectedMethods();
- $system->shouldReceive('exec')->with('tput cols 2>/dev/null')->andReturn('error');
- $this->assertNull($system->width());
- }
- /** @test */
- public function it_can_get_the_height()
- {
- $system = Mockery::mock(Linux::class)
- ->makePartial()
- ->shouldAllowMockingProtectedMethods();
- $system->shouldReceive('exec')->with('tput lines 2>/dev/null')->andReturn(100);
- $this->assertSame(100, $system->height());
- }
- /** @test */
- public function it_will_return_null_if_height_is_not_numeric()
- {
- $system = Mockery::mock(Linux::class)
- ->makePartial()
- ->shouldAllowMockingProtectedMethods();
- $system->shouldReceive('exec')->with('tput lines 2>/dev/null')->andReturn('error');
- $this->assertNull($system->height());
- }
- }
|