Skip to content

Commit 39db7d4

Browse files
author
Andreas Frömer
committed
Remove systemd from travis; Adjust listUnit tests
1 parent 8499b70 commit 39db7d4

3 files changed

Lines changed: 39 additions & 11 deletions

File tree

.travis.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,3 @@ before_script:
1818
script:
1919
- composer cs
2020
- composer test -- --coverage-clover=build/logs/clover.xml --coverage-text
21-
22-
addons:
23-
apt:
24-
packages:
25-
- systemd

src/SystemCtl.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function unitFromSuffix(string $unitSuffix, string $unitName): Uni
7272
* @param string[] $unitTypes
7373
* @return array|\string[]
7474
*/
75-
public function listUnits(array $unitTypes = self::AVAILABLE_UNITS): array
75+
public function listUnits(array $unitTypes = self::SUPPORTED_UNITS): array
7676
{
7777
$process = $this->getProcessBuilder()
7878
->add('list-units')
@@ -82,8 +82,8 @@ public function listUnits(array $unitTypes = self::AVAILABLE_UNITS): array
8282
$output = $process->getOutput();
8383

8484
return array_reduce($unitTypes, function ($carry, $unitSuffix) use ($output) {
85-
$carry += Utils\OutputFetcher::fetchUnitNames($unitSuffix, $output);
86-
return $carry;
85+
$result = Utils\OutputFetcher::fetchUnitNames($unitSuffix, $output);
86+
return array_merge($carry, $result);
8787
}, []);
8888
}
8989

tests/SystemCtlTest.php

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,44 @@ private function buildSystemCtlMock($output)
4343
return $systemctl;
4444
}
4545

46-
public function testListUnits()
46+
public function testListUnitsWithAvailableUnits()
4747
{
48-
$systemctl = new SystemCtl();
48+
$output = <<<EOT
49+
proc-sys-fs-binfmt_misc.timer loaded active mounted Arbitrary Executable File Formats File System
50+
run-rpc_pipefs.mount loaded active mounted /run/rpc_pipefs
51+
sys-fs-fuse-connections.mount loaded active mounted FUSE Control File System
52+
sys-kernel-debug.mount loaded active mounted Debug File System
53+
acpid.path loaded active running ACPI Events Check
54+
systemd-ask-password-console.path loaded active waiting Dispatch Password Requests to Console Directory Wa
55+
systemd-ask-password-wall.path loaded active waiting Forward Password Requests to Wall Directory Watch
56+
acpid.service loaded active running ACPI event daemon
57+
beanstalkd.service loaded active running Simple, fast work queue
58+
console-setup.service loaded active exited LSB: Set console font and keymap
59+
cron.service loaded active running Regular background program processing daemon
60+
EOT;
61+
$systemctl = $this->buildSystemCtlMock($output);
62+
$units = $systemctl->listUnits(SystemCtl::AVAILABLE_UNITS);
63+
$this->assertCount(11, $units);
64+
}
65+
66+
public function testListUnitsWithSupportedUnits()
67+
{
68+
$output = <<<EOT
69+
proc-sys-fs-binfmt_misc.timer loaded active mounted Arbitrary Executable File Formats File System
70+
run-rpc_pipefs.mount loaded active mounted /run/rpc_pipefs
71+
sys-fs-fuse-connections.mount loaded active mounted FUSE Control File System
72+
sys-kernel-debug.mount loaded active mounted Debug File System
73+
acpid.path loaded active running ACPI Events Check
74+
systemd-ask-password-console.path loaded active waiting Dispatch Password Requests to Console Directory Wa
75+
systemd-ask-password-wall.path loaded active waiting Forward Password Requests to Wall Directory Watch
76+
acpid.service loaded active running ACPI event daemon
77+
beanstalkd.service loaded active running Simple, fast work queue
78+
console-setup.service loaded active exited LSB: Set console font and keymap
79+
cron.service loaded active running Regular background program processing daemon
80+
EOT;
81+
$systemctl = $this->buildSystemCtlMock($output);
4982
$units = $systemctl->listUnits();
50-
$this->assertTrue(count($units) > 0);
83+
$this->assertCount(5, $units);
5184
}
5285

5386
public function testCreateUnitFromSupportedSuffixShouldWord()

0 commit comments

Comments
 (0)