Skip to content

Commit

Permalink
Update with master
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Frömer committed Mar 19, 2019
2 parents 0be6e58 + d98ca38 commit 2930482
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# systemctl-php
[![Build Status](https://api.travis-ci.org/icanhazstring/systemctl-php.svg?branch=master)](https://travis-ci.org/icanhazstring/systemctl-php) [![Code Climate](https://codeclimate.com/github/icanhazstring/systemctl-php/badges/gpa.svg)](https://codeclimate.com/github/icanhazstring/systemctl-php) [![Test Coverage](https://codeclimate.com/github/icanhazstring/systemctl-php/badges/coverage.svg)](https://codeclimate.com/github/icanhazstring/systemctl-php/coverage)
[![Build Status](https://api.travis-ci.org/icanhazstring/systemctl-php.svg?branch=master)](https://travis-ci.org/icanhazstring/systemctl-php) [![Code Climate](https://codeclimate.com/github/icanhazstring/systemctl-php/badges/gpa.svg)](https://codeclimate.com/github/icanhazstring/systemctl-php) [![Test Coverage](https://codeclimate.com/github/icanhazstring/systemctl-php/badges/coverage.svg)](https://codeclimate.com/github/icanhazstring/systemctl-php/coverage) [![Join the chat at https://gitter.im/icanhazstring/systemctl-php](https://badges.gitter.im/icanhazstring/systemctl-php.svg)](https://gitter.im/icanhazstring/systemctl-php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

PHP wrapper for systemctl

Expand Down
2 changes: 1 addition & 1 deletion src/SystemCtl.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function listUnits(?string $unitPrefix = null, array $unitTypes = self::S
public function getScope(): ScopeInterface
{
if ($this->scope === null) {
$this->scope = $this->system();
$this->scope = $this->systemScope = new SystemScope;
}

return $this->scope;
Expand Down
2 changes: 1 addition & 1 deletion src/Template/ServiceUnitTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @package SystemCtl\Template
* @author icanhazstring <[email protected]>
*/
class ServiceUnitTemplate extends AbstractUnitTemplate
class ServiceUnitTemplate extends AbstractUnitTemplate implements UnitTemplateInterface
{
/** @var ServiceSection */
protected $serviceSection;
Expand Down
2 changes: 1 addition & 1 deletion src/Template/TimerUnitTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @package SystemCtl\Template
* @author icanhazstring <[email protected]>
*/
class TimerUnitTemplate extends AbstractUnitTemplate
class TimerUnitTemplate extends AbstractUnitTemplate implements UnitTemplateInterface
{
/** @var TimerSection */
protected $timerSection;
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/OutputFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class OutputFetcher
*/
public static function fetchUnitNames(string $suffix, string $output): array
{
preg_match_all('/^\s*(?<unit>.*)\.' . $suffix . '\s.*$/m', $output, $matches);
preg_match_all('/^[^[:alnum:]-_\.@]*(?<unit>.*)\.' . $suffix . '\s.*$/m', $output, $matches);
return $matches['unit'] ?? [];
}
}
3 changes: 2 additions & 1 deletion tests/Integration/SystemCtlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function testListUnitsWithAvailableUnits(): void
console-setup.service loaded active exited
cron.service loaded active running
test.service loaded inactive dead
[email protected] loaded failed failed
EOT;

$command = $this->prophesize(CommandInterface::class);
Expand All @@ -107,7 +108,7 @@ public function testListUnitsWithAvailableUnits(): void
$systemctl->setCommandDispatcher($dispatcherStub->reveal());

$units = $systemctl->listUnits(null, SystemCtl::AVAILABLE_UNITS);
self::assertCount(12, $units);
self::assertCount(13, $units);
}

public function testListUnitsWithSupportedUnits(): void
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/SystemCtlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use SystemCtl\Exception\UnitTypeNotSupportedException;
use SystemCtl\SystemCtl;
use SystemCtl\Template\AbstractUnitTemplate;
use SystemCtl\Template\UnitTemplateInterface;
use SystemCtl\Unit\Service;
use SystemCtl\Unit\Timer;

Expand Down Expand Up @@ -232,7 +233,7 @@ public function itShouldReturnATimerWithTheCorrectNameOnTimerGetting(): void
*/
public function itShouldRaiseAnExceptionWhenAttemptingToInstallUnsupportedUnit(): void
{
$template = $this->prophesize(AbstractUnitTemplate::class);
$template = $this->prophesize(UnitTemplateInterface::class);
$template->getUnitName()->willReturn('test');
$template->getUnitSuffix()->willReturn('fubar');

Expand Down
21 changes: 12 additions & 9 deletions tests/Unit/Utils/OutputFetcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,22 @@ public function itDeterminesTheCorrectAmountOfUnits(
public function itDeterminesTheCorrectAmountOfUnitsDataProvider(): array
{
$output = <<<OUTPUT
superservice.service Active running
awesomeservice.service Active running
nonservice.timer Active running
superservice.mount Active running
awesomeservice.mount Active running
nonservice.timer Active running
superservice.service Active running
awesomeservice.service Active running
superservice.service active running
awesomeservice.service active running
nonservice.timer active running
superservice.mount active running
awesomeservice.mount active running
nonservice.timer active running
superservice.service active running
awesomeservice.service active running
[email protected] loaded failed failed
OUTPUT;

return [
[
'output' => $output,
'suffix' => 'service',
'amount' => 4,
'amount' => 5,
],
[
'output' => $output,
Expand Down Expand Up @@ -99,6 +100,7 @@ public function itOnlyExtractsTheUnitNamesDataProvider(): array
nonservice.timer Active running
[email protected] Active running
[email protected] Active running
[email protected] loaded failed failed
OUTPUT;

return [
Expand All @@ -110,6 +112,7 @@ public function itOnlyExtractsTheUnitNamesDataProvider(): array
'foo-bar',
'instance-service@1',
'instance-service@foo',
'failed-service@foo'
],
],
[
Expand Down

0 comments on commit 2930482

Please sign in to comment.