1 | <?php |
||
24 | class ServiceTest extends \PHPUnit_Framework_TestCase |
||
25 | { |
||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $commandFilename; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $callCountFilename; |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | private $callCount = 1; |
||
40 | |||
41 | protected function setUp() |
||
45 | |||
46 | protected function tearDown() |
||
57 | |||
58 | /** |
||
59 | * @covers SystemCtl\Service::__toString |
||
60 | */ |
||
61 | public function testServiceName() |
||
69 | |||
70 | /** |
||
71 | * @covers SystemCtl\Service::isRunning |
||
72 | */ |
||
73 | public function testIsRunning() |
||
82 | |||
83 | /** |
||
84 | * @covers SystemCtl\Service::isRunning |
||
85 | */ |
||
86 | public function testIsNotRunning() |
||
95 | |||
96 | /** |
||
97 | * @covers SystemCtl\Service::isRunning |
||
98 | * @covers SystemCtl\CommandFailedException |
||
99 | */ |
||
100 | public function testCheckInvalidServiceThrowsException() |
||
110 | |||
111 | /** |
||
112 | * @covers SystemCtl\Service::isRunning |
||
113 | * @covers SystemCtl\Service::start |
||
114 | */ |
||
115 | public function testStart() |
||
127 | |||
128 | /** |
||
129 | * @covers SystemCtl\Service::isRunning |
||
130 | * @covers SystemCtl\Service::start |
||
131 | */ |
||
132 | public function testStartAlreadyRunning() |
||
143 | |||
144 | /** |
||
145 | * @covers SystemCtl\Service::isRunning |
||
146 | * @covers SystemCtl\Service::start |
||
147 | * @covers SystemCtl\CommandFailedException |
||
148 | */ |
||
149 | public function testStartInvalidServiceThrowsException() |
||
160 | |||
161 | /** |
||
162 | * @covers SystemCtl\Service::isRunning |
||
163 | * @covers SystemCtl\Service::stop |
||
164 | */ |
||
165 | public function testStop() |
||
177 | |||
178 | /** |
||
179 | * @covers SystemCtl\Service::isRunning |
||
180 | * @covers SystemCtl\Service::stop |
||
181 | */ |
||
182 | public function testStopWhenNotRunning() |
||
193 | |||
194 | /** |
||
195 | * @covers SystemCtl\Service::isRunning |
||
196 | * @covers SystemCtl\Service::stop |
||
197 | * @covers SystemCtl\CommandFailedException |
||
198 | */ |
||
199 | public function testStopInvalidServiceThrowsException() |
||
210 | |||
211 | /** |
||
212 | * @covers SystemCtl\Service::restart |
||
213 | */ |
||
214 | public function testRestart() |
||
225 | |||
226 | /** |
||
227 | * @covers SystemCtl\Service::isRunning |
||
228 | * @covers SystemCtl\Service::restart |
||
229 | * @covers SystemCtl\CommandFailedException |
||
230 | */ |
||
231 | public function testRestartInvalidServiceThrowsException() |
||
241 | |||
242 | /** |
||
243 | * @covers SystemCtl\Service::isRunning |
||
244 | * @covers SystemCtl\Service::restart |
||
245 | * @covers SystemCtl\CommandFailedException |
||
246 | */ |
||
247 | public function testExceptionHasProcess() |
||
262 | |||
263 | /** |
||
264 | * Returns a service instance with a mocked systemctl command. |
||
265 | * |
||
266 | * @param string $name Service name |
||
267 | * |
||
268 | * @return Service |
||
269 | */ |
||
270 | private function getMockedService($name) |
||
292 | |||
293 | /** |
||
294 | * Adds an expected call to the systemctl command. |
||
295 | * |
||
296 | * @param string[] $arguments List of expected arguments |
||
297 | * @param int $exitCode Exit code which the command should return |
||
298 | */ |
||
299 | private function expectCall(array $arguments, $exitCode) |
||
320 | |||
321 | /** |
||
322 | * Sets no more expected calls to the systemctl command. |
||
323 | */ |
||
324 | private function expectNoOtherCalls() |
||
330 | } |
||
331 |