|
18 | 18 | use icanhazstring\SystemCtl\Unit\Slice; |
19 | 19 | use icanhazstring\SystemCtl\Unit\Swap; |
20 | 20 | use icanhazstring\SystemCtl\Unit\Target; |
| 21 | +use icanhazstring\SystemCtl\Unit\Automount; |
21 | 22 |
|
22 | 23 | /** |
23 | 24 | * Class SystemCtlTest |
@@ -238,6 +239,25 @@ public function itShouldCallCommandDispatcherWithListUnitsAndUnitPrefixOnSwapGet |
238 | 239 | $this->assertEquals($unitName, $swap->getName()); |
239 | 240 | } |
240 | 241 |
|
| 242 | + /** |
| 243 | + * @test |
| 244 | + */ |
| 245 | + public function itShouldCallCommandDispatcherWithListUnitsAndUnitPrefixOnAutomountGetting() |
| 246 | + { |
| 247 | + $unitName = 'testAutomount'; |
| 248 | + $output = ' testAutomount.automount Active running'; |
| 249 | + $commandDispatcherStub = $this->buildCommandDispatcherStub(); |
| 250 | + $commandDispatcherStub |
| 251 | + ->dispatch(...['list-units', $unitName . '*']) |
| 252 | + ->willReturn($this->buildCommandStub($output)); |
| 253 | + |
| 254 | + $systemctl = (new SystemCtl())->setCommandDispatcher($commandDispatcherStub->reveal()); |
| 255 | + |
| 256 | + $automount = $systemctl->getAutomount($unitName); |
| 257 | + $this->assertInstanceOf(Automount::class, $automount); |
| 258 | + $this->assertEquals($unitName, $automount->getName()); |
| 259 | + } |
| 260 | + |
241 | 261 | /** |
242 | 262 | * @test |
243 | 263 | */ |
@@ -411,4 +431,21 @@ public function itShouldThrowAnExceptionIfNoDeviceCouldBeFound() |
411 | 431 | $this->expectException(UnitNotFoundException::class); |
412 | 432 | $systemctl->getSocket($unitName); |
413 | 433 | } |
| 434 | + |
| 435 | + /** |
| 436 | + * @test |
| 437 | + */ |
| 438 | + public function itShouldThrowAnExceptionIfNoAutomountCouldBeFound() |
| 439 | + { |
| 440 | + $unitName = 'testAutomount'; |
| 441 | + $commandDispatcherStub = $this->buildCommandDispatcherStub(); |
| 442 | + $commandDispatcherStub |
| 443 | + ->dispatch(...['list-units', $unitName . '*']) |
| 444 | + ->willReturn($this->buildCommandStub('')); |
| 445 | + |
| 446 | + $systemctl = (new SystemCtl())->setCommandDispatcher($commandDispatcherStub->reveal()); |
| 447 | + |
| 448 | + $this->expectException(UnitNotFoundException::class); |
| 449 | + $systemctl->getAutomount($unitName); |
| 450 | + } |
414 | 451 | } |
0 commit comments