Skip to content

Commit 2930482

Browse files
author
Andreas Frömer
committed
Update with master
2 parents 0be6e58 + d98ca38 commit 2930482

File tree

8 files changed

+21
-16
lines changed

8 files changed

+21
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# systemctl-php
2-
[![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)
2+
[![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)
33

44
PHP wrapper for systemctl
55

src/SystemCtl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function listUnits(?string $unitPrefix = null, array $unitTypes = self::S
155155
public function getScope(): ScopeInterface
156156
{
157157
if ($this->scope === null) {
158-
$this->scope = $this->system();
158+
$this->scope = $this->systemScope = new SystemScope;
159159
}
160160

161161
return $this->scope;

src/Template/ServiceUnitTemplate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @package SystemCtl\Template
1414
* @author icanhazstring <[email protected]>
1515
*/
16-
class ServiceUnitTemplate extends AbstractUnitTemplate
16+
class ServiceUnitTemplate extends AbstractUnitTemplate implements UnitTemplateInterface
1717
{
1818
/** @var ServiceSection */
1919
protected $serviceSection;

src/Template/TimerUnitTemplate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @package SystemCtl\Template
1414
* @author icanhazstring <[email protected]>
1515
*/
16-
class TimerUnitTemplate extends AbstractUnitTemplate
16+
class TimerUnitTemplate extends AbstractUnitTemplate implements UnitTemplateInterface
1717
{
1818
/** @var TimerSection */
1919
protected $timerSection;

src/Utils/OutputFetcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class OutputFetcher
2020
*/
2121
public static function fetchUnitNames(string $suffix, string $output): array
2222
{
23-
preg_match_all('/^\s*(?<unit>.*)\.' . $suffix . '\s.*$/m', $output, $matches);
23+
preg_match_all('/^[^[:alnum:]-_\.@]*(?<unit>.*)\.' . $suffix . '\s.*$/m', $output, $matches);
2424
return $matches['unit'] ?? [];
2525
}
2626
}

tests/Integration/SystemCtlTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public function testListUnitsWithAvailableUnits(): void
9595
console-setup.service loaded active exited
9696
cron.service loaded active running
9797
test.service loaded inactive dead
98+
[email protected] loaded failed failed
9899
EOT;
99100

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

109110
$units = $systemctl->listUnits(null, SystemCtl::AVAILABLE_UNITS);
110-
self::assertCount(12, $units);
111+
self::assertCount(13, $units);
111112
}
112113

113114
public function testListUnitsWithSupportedUnits(): void

tests/Unit/SystemCtlTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use SystemCtl\Exception\UnitTypeNotSupportedException;
1414
use SystemCtl\SystemCtl;
1515
use SystemCtl\Template\AbstractUnitTemplate;
16+
use SystemCtl\Template\UnitTemplateInterface;
1617
use SystemCtl\Unit\Service;
1718
use SystemCtl\Unit\Timer;
1819

@@ -232,7 +233,7 @@ public function itShouldReturnATimerWithTheCorrectNameOnTimerGetting(): void
232233
*/
233234
public function itShouldRaiseAnExceptionWhenAttemptingToInstallUnsupportedUnit(): void
234235
{
235-
$template = $this->prophesize(AbstractUnitTemplate::class);
236+
$template = $this->prophesize(UnitTemplateInterface::class);
236237
$template->getUnitName()->willReturn('test');
237238
$template->getUnitSuffix()->willReturn('fubar');
238239

tests/Unit/Utils/OutputFetcherTest.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,22 @@ public function itDeterminesTheCorrectAmountOfUnits(
3737
public function itDeterminesTheCorrectAmountOfUnitsDataProvider(): array
3838
{
3939
$output = <<<OUTPUT
40-
superservice.service Active running
41-
awesomeservice.service Active running
42-
nonservice.timer Active running
43-
superservice.mount Active running
44-
awesomeservice.mount Active running
45-
nonservice.timer Active running
46-
superservice.service Active running
47-
awesomeservice.service Active running
40+
superservice.service active running
41+
awesomeservice.service active running
42+
nonservice.timer active running
43+
superservice.mount active running
44+
awesomeservice.mount active running
45+
nonservice.timer active running
46+
superservice.service active running
47+
awesomeservice.service active running
48+
[email protected] loaded failed failed
4849
OUTPUT;
4950

5051
return [
5152
[
5253
'output' => $output,
5354
'suffix' => 'service',
54-
'amount' => 4,
55+
'amount' => 5,
5556
],
5657
[
5758
'output' => $output,
@@ -99,6 +100,7 @@ public function itOnlyExtractsTheUnitNamesDataProvider(): array
99100
nonservice.timer Active running
100101
[email protected] Active running
101102
[email protected] Active running
103+
[email protected] loaded failed failed
102104
OUTPUT;
103105

104106
return [
@@ -110,6 +112,7 @@ public function itOnlyExtractsTheUnitNamesDataProvider(): array
110112
'foo-bar',
111113
'instance-service@1',
112114
'instance-service@foo',
115+
'failed-service@foo'
113116
],
114117
],
115118
[

0 commit comments

Comments
 (0)