Skip to content

Commit 065fd82

Browse files
Andreas Frömericanhazstring
authored andcommitted
Upgrade deps and move tests
1 parent 8949ff9 commit 065fd82

File tree

11 files changed

+91
-96
lines changed

11 files changed

+91
-96
lines changed

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"description": "PHP wrapper for systemctl",
44
"type": "library",
55
"require": {
6-
"php": "^7.1",
7-
"symfony/process": "^3.2 || ^4.4"
6+
"php": "^7.3",
7+
"symfony/process": "^4.4 || ^5.0"
88
},
99
"require-dev": {
10-
"phpunit/phpunit": "^6.1",
11-
"squizlabs/php_codesniffer": "^3.0",
10+
"phpunit/phpunit": "^9.0",
11+
"squizlabs/php_codesniffer": "^3.5",
1212
"codeclimate/php-test-reporter": "dev-master"
1313
},
1414
"autoload": {
@@ -20,8 +20,8 @@
2020
},
2121
"autoload-dev": {
2222
"psr-4": {
23-
"SystemCtl\\Tests\\": [
24-
"tests/"
23+
"SystemCtl\\Test\\": [
24+
"test/"
2525
]
2626
}
2727
},

phpunit.xml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false"
12-
bootstrap="./vendor/autoload.php"
13-
>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
defaultTestSuite="unit"
6+
colors="true">
147
<testsuites>
15-
<testsuite name="unit-tests">
16-
<directory>./tests/Unit</directory>
8+
<testsuite name="unit">
9+
<directory>./test/Unit</directory>
1710
</testsuite>
18-
<testsuite name="integration-tests">
19-
<directory>./tests/Integration</directory>
11+
<testsuite name="integration">
12+
<directory>./test/Integration</directory>
2013
</testsuite>
2114
</testsuites>
2215

2316
<filter>
24-
<blacklist>
25-
<directory suffix=".php">./vendor</directory>
26-
</blacklist>
2717
<whitelist processUncoveredFilesFromWhitelist="false">
2818
<directory suffix=".php">./src</directory>
2919
</whitelist>
3020
</filter>
31-
21+
<php>
22+
<ini name="date.timezone" value="Europe/Berlin"/>
23+
<ini name="display_errors" value="true" />
24+
<!-- error_reporting(E_ALL) -->
25+
<ini name="error_reporting" value="32767"/>
26+
</php>
3227
</phpunit>

src/Utils/OutputFetcher.php

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

tests/Integration/Command/SymfonyCommandDispatcherTest.php renamed to test/Integration/Command/SymfonyCommandDispatcherTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<?php
22

3-
namespace SystemCtl\Tests\Integration\Command;
3+
namespace SystemCtl\Test\Integration\Command;
44

55
use PHPUnit\Framework\TestCase;
66
use SystemCtl\Command\SymfonyCommandDispatcher;
77

88
/**
99
* Class SymfonyCommandDispatcherTest
1010
*
11-
* @package SystemCtl\Tests\Integration\Command
11+
* @package SystemCtl\Test\Integration\Command
1212
* @author icanhazstring <[email protected]>
1313
*/
1414
class SymfonyCommandDispatcherTest extends TestCase
1515
{
1616
/**
1717
* @test
1818
*/
19-
public function itShouldDispatchACorrectCommand()
19+
public function itShouldDispatchACorrectCommand(): void
2020
{
2121
$dispatcher = new SymfonyCommandDispatcher();
2222
$dispatcher->setBinary('echo');
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace SystemCtl\Tests\Integration;
3+
namespace SystemCtl\Test\Integration;
44

55
use PHPUnit\Framework\TestCase;
66
use Prophecy\Argument;
@@ -31,7 +31,7 @@ public function createCommandDispatcherStub(): ObjectProphecy
3131
return $commandDispatcher;
3232
}
3333

34-
public function testListUnitsWithAvailableUnits()
34+
public function testListUnitsWithAvailableUnits(): void
3535
{
3636
$output = <<<EOT
3737
proc-sys-fs-binfmt_misc.timer loaded active mounted
@@ -61,7 +61,7 @@ public function testListUnitsWithAvailableUnits()
6161
$this->assertCount(12, $units);
6262
}
6363

64-
public function testListUnitsWithSupportedUnits()
64+
public function testListUnitsWithSupportedUnits(): void
6565
{
6666
$output = <<<EOT
6767
proc-sys-fs-binfmt_misc.timer loaded active mounted
@@ -90,30 +90,30 @@ public function testListUnitsWithSupportedUnits()
9090
$this->assertCount(5, $units);
9191
}
9292

93-
public function testCreateUnitFromSupportedSuffixShouldWord()
93+
public function testCreateUnitFromSupportedSuffixShouldWord(): void
9494
{
9595
$unit = SystemCtl::unitFromSuffix('service', 'SuccessService');
9696
$this->assertInstanceOf(UnitInterface::class, $unit);
9797
$this->assertInstanceOf(Service::class, $unit);
9898
$this->assertEquals('SuccessService', $unit->getName());
9999
}
100100

101-
public function testCreateUnitFromUnsupportedSuffixShouldRaiseException()
101+
public function testCreateUnitFromUnsupportedSuffixShouldRaiseException(): void
102102
{
103103
$this->expectException(UnitTypeNotSupportedException::class);
104104
SystemCtl::unitFromSuffix('unsupported', 'FailUnit');
105105
}
106106

107-
public function testGetServices()
107+
public function testGetServices(): void
108108
{
109109
$output = <<<EOT
110-
PLACEHOLDER STUFF
111-
superservice.service Active running
112-
awesomeservice.service Active running
113-
nonservice.timer Active running
114-
PLACEHOLDER STUFF
115-
116-
EOT;
110+
PLACEHOLDER STUFF
111+
superservice.service Active running
112+
awesomeservice.service Active running
113+
nonservice.timer Active running
114+
PLACEHOLDER STUFF
115+
116+
EOT;
117117

118118
$command = $this->prophesize(CommandInterface::class);
119119
$command->getOutput()->willReturn($output);
@@ -129,16 +129,16 @@ public function testGetServices()
129129
$this->assertCount(2, $services);
130130
}
131131

132-
public function testGetTimers()
132+
public function testGetTimers(): void
133133
{
134134
$output = <<<EOT
135-
PLACEHOLDER STUFF
136-
superservice.service Active running
137-
awesomeservice.timer Active running
138-
nonservice.timer Active running
139-
PLACEHOLDER STUFF
140-
141-
EOT;
135+
PLACEHOLDER STUFF
136+
superservice.service Active running
137+
awesomeservice.timer Active running
138+
nonservice.timer Active running
139+
PLACEHOLDER STUFF
140+
141+
EOT;
142142

143143
$command = $this->prophesize(CommandInterface::class);
144144
$command->getOutput()->willReturn($output);
@@ -156,7 +156,7 @@ public function testGetTimers()
156156
/**
157157
* @test
158158
*/
159-
public function itShouldReturnTrueOnSuccessfulDaemonReload()
159+
public function itShouldReturnTrueOnSuccessfulDaemonReload(): void
160160
{
161161
$command = $this->prophesize(CommandInterface::class);
162162
$command->isSuccessful()->willReturn(true);
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace SystemCtl\Tests\Integration\Unit;
3+
namespace SystemCtl\Test\Integration\Unit;
44

55
use PHPUnit\Framework\TestCase;
66
use Prophecy\Argument;
@@ -19,7 +19,7 @@
1919
*/
2020
class UnitTest extends TestCase
2121
{
22-
public function testServiceCommandsIfProcessIsSuccessfulShouldReturnTrue()
22+
public function testServiceCommandsIfProcessIsSuccessfulShouldReturnTrue(): void
2323
{
2424
$command = $this->prophesize(CommandInterface::class);
2525
$command->isSuccessful()->willReturn(true);
@@ -46,7 +46,7 @@ public function createCommandDispatcherStub(): ObjectProphecy
4646
return $commandDispatcher;
4747
}
4848

49-
public function testServiceCommandsIfProcessIsUnsuccessFulShouldRaiseException()
49+
public function testServiceCommandsIfProcessIsUnsuccessFulShouldRaiseException(): void
5050
{
5151
$commandDispatcher = $this->createCommandDispatcherStub();
5252
$commandDispatcher->dispatch(Argument::cetera())->willThrow(CommandFailedException::class);
@@ -57,7 +57,7 @@ public function testServiceCommandsIfProcessIsUnsuccessFulShouldRaiseException()
5757
$service->start();
5858
}
5959

60-
public function testTimerCommandsIfProcessIsSuccessfulShouldReturnTrue()
60+
public function testTimerCommandsIfProcessIsSuccessfulShouldReturnTrue(): void
6161
{
6262
$command = $this->prophesize(CommandInterface::class);
6363
$command->isSuccessful()->willReturn(true);
@@ -75,7 +75,7 @@ public function testTimerCommandsIfProcessIsSuccessfulShouldReturnTrue()
7575
$this->assertTrue($timer->restart());
7676
}
7777

78-
public function testTimerCommandsIfProcessIsUnsuccessFulShouldRaiseException()
78+
public function testTimerCommandsIfProcessIsUnsuccessFulShouldRaiseException(): void
7979
{
8080
$commandDispatcher = $this->createCommandDispatcherStub();
8181
$commandDispatcher->dispatch(Argument::cetera())->willThrow(CommandFailedException::class);
@@ -86,7 +86,7 @@ public function testTimerCommandsIfProcessIsUnsuccessFulShouldRaiseException()
8686
$timer->start();
8787
}
8888

89-
public function testSocketCommandsIfProcessIsSuccessfulShouldReturnTrue()
89+
public function testSocketCommandsIfProcessIsSuccessfulShouldReturnTrue(): void
9090
{
9191
$command = $this->prophesize(CommandInterface::class);
9292
$command->isSuccessful()->willReturn(true);
@@ -104,7 +104,7 @@ public function testSocketCommandsIfProcessIsSuccessfulShouldReturnTrue()
104104
$this->assertTrue($socket->restart());
105105
}
106106

107-
public function testSocketCommandsIfProcessIsUnsuccessFulShouldRaiseException()
107+
public function testSocketCommandsIfProcessIsUnsuccessFulShouldRaiseException(): void
108108
{
109109
$commandDispatcher = $this->createCommandDispatcherStub();
110110
$commandDispatcher->dispatch(Argument::cetera())->willThrow(CommandFailedException::class);
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace SystemCtl\Tests\Unit\Command;
3+
namespace SystemCtl\Test\Unit\Command;
44

55
use PHPUnit\Framework\TestCase;
66
use Symfony\Component\Process\Process;
@@ -10,15 +10,15 @@
1010
/**
1111
* Class SymfonyCommandTest
1212
*
13-
* @package SystemCtl\Tests\Unit\Command
13+
* @package SystemCtl\Test\Unit\Command
1414
* @author icanhazstring <[email protected]>
1515
*/
1616
class SymfonyCommandTest extends TestCase
1717
{
1818
/**
1919
* @test
2020
*/
21-
public function itShouldCreateValidInstance()
21+
public function itShouldCreateValidInstance(): void
2222
{
2323
$process = $this->prophesize(Process::class);
2424
$command = new SymfonyCommand($process->reveal());
@@ -29,7 +29,7 @@ public function itShouldCreateValidInstance()
2929
/**
3030
* @test
3131
*/
32-
public function itShouldReturnOutputFromProcess()
32+
public function itShouldReturnOutputFromProcess(): void
3333
{
3434
$process = $this->prophesize(Process::class);
3535
$process->getOutput()->willReturn('test');
@@ -41,7 +41,7 @@ public function itShouldReturnOutputFromProcess()
4141
/**
4242
* @test
4343
*/
44-
public function itShouldReturnSuccessfulFromProcess()
44+
public function itShouldReturnSuccessfulFromProcess(): void
4545
{
4646
$process = $this->prophesize(Process::class);
4747
$process->isSuccessful()->willReturn(true);
@@ -53,7 +53,7 @@ public function itShouldReturnSuccessfulFromProcess()
5353
/**
5454
* @test
5555
*/
56-
public function itShouldReturnTheCommandIfCommandRanSuccessFul()
56+
public function itShouldReturnTheCommandIfCommandRanSuccessFul(): void
5757
{
5858
$process = $this->prophesize(Process::class);
5959
$process->run()->shouldBeCalled();
@@ -67,7 +67,7 @@ public function itShouldReturnTheCommandIfCommandRanSuccessFul()
6767
/**
6868
* @test
6969
*/
70-
public function itShouldRaiseAnExceptionIfProcessWasNotSuccessfull()
70+
public function itShouldRaiseAnExceptionIfProcessWasNotSuccessfull(): void
7171
{
7272
$process = $this->prophesize(Process::class);
7373
$process->run()->shouldBeCalled();

0 commit comments

Comments
 (0)