Skip to content

Commit

Permalink
Add test case for supported
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
  • Loading branch information
kesselb committed Apr 18, 2020
1 parent 8270cba commit 773ace2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
10 changes: 1 addition & 9 deletions lib/OperatingSystems/DefaultOs.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DefaultOs {
/**
* @return bool
*/
public function supported() {
public function supported(): bool {
return true;
}

Expand Down Expand Up @@ -251,12 +251,4 @@ protected function executeCommand(string $command): string {
}
return $output;
}

protected function executeCommand(string $command): string {
$output = @shell_exec(escapeshellcmd($command));
if ($output === null || $output === '') {
throw new \RuntimeException('No output for command: "' . $command . '"');
}
return $output;
}
}
5 changes: 5 additions & 0 deletions tests/lib/DefaultOsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public function testGetUptimeNoData(): void {

$this->assertEquals(-1, $this->os->getUptime());
}

public function testGetDiskInfo(): void {
$this->os->method('executeCommand')
->with('df -TP')
Expand Down Expand Up @@ -182,4 +183,8 @@ public function testGetDiskInfoInvalidCommandOutput(): void {

$this->assertSame([], $this->os->getDiskInfo());
}

public function testSupported(): void {
$this->assertTrue($this->os->supported());
}
}

0 comments on commit 773ace2

Please sign in to comment.