@@ -61,6 +61,7 @@ private function buildCommandDispatcherStub(): ObjectProphecy
6161 $ commandDispatcherStub = $ this ->prophesize (CommandDispatcherInterface::class);
6262 $ commandDispatcherStub ->setTimeout (Argument::type ('int ' ))->willReturn ($ commandDispatcherStub );
6363 $ commandDispatcherStub ->setBinary (Argument::type ('string ' ))->willReturn ($ commandDispatcherStub );
64+ $ commandDispatcherStub ->setArguments (Argument::type ('array ' ))->willReturn ($ commandDispatcherStub );
6465
6566 return $ commandDispatcherStub ;
6667 }
@@ -105,7 +106,7 @@ public function testListUnitsWithAvailableUnits()
105106 $ systemctl ->setCommandDispatcher ($ dispatcherStub ->reveal ());
106107
107108 $ units = $ systemctl ->listUnits (null , SystemCtl::AVAILABLE_UNITS );
108- $ this -> assertCount (11 , $ units );
109+ self :: assertCount (11 , $ units );
109110 }
110111
111112 public function testListUnitsWithSupportedUnits ()
@@ -134,7 +135,7 @@ public function testListUnitsWithSupportedUnits()
134135 $ systemctl ->setCommandDispatcher ($ dispatcherStub ->reveal ());
135136
136137 $ units = $ systemctl ->listUnits ();
137- $ this -> assertCount (5 , $ units );
138+ self :: assertCount (5 , $ units );
138139 }
139140
140141 public function testGetServices ()
@@ -159,7 +160,7 @@ public function testGetServices()
159160
160161 $ services = $ systemctl ->getServices ();
161162
162- $ this -> assertCount (2 , $ services );
163+ self :: assertCount (2 , $ services );
163164 }
164165
165166 public function testGetTimers ()
@@ -183,7 +184,7 @@ public function testGetTimers()
183184 $ systemctl ->setCommandDispatcher ($ dispatcherStub ->reveal ());
184185 $ timers = $ systemctl ->getTimers ();
185186
186- $ this -> assertCount (2 , $ timers );
187+ self :: assertCount (2 , $ timers );
187188 }
188189
189190 /**
@@ -195,12 +196,12 @@ public function itShouldReturnTrueOnSuccessfulDaemonReload()
195196 $ command ->isSuccessful ()->willReturn (true );
196197
197198 $ dispatcher = $ this ->buildCommandDispatcherStub ();
198- $ dispatcher ->dispatch (Argument:: exact ( 'daemon-reload ' ) )->willReturn ($ command );
199+ $ dispatcher ->dispatch ('daemon-reload ' )->willReturn ($ command );
199200
200201 $ systemCtl = new SystemCtl ();
201202 $ systemCtl ->setCommandDispatcher ($ dispatcher ->reveal ());
202203
203- $ this -> assertTrue ($ systemCtl ->daemonReload ());
204+ self :: assertTrue ($ systemCtl ->daemonReload ());
204205 }
205206
206207 /**
@@ -239,7 +240,7 @@ public function itShouldReturnUnitAfterInstall()
239240
240241 $ unit = $ systemctl ->install ($ unitTemplate );
241242
242- $ this -> assertEquals ($ unitName , $ unit ->getName ());
243+ self :: assertEquals ($ unitName , $ unit ->getName ());
243244 }
244245
245246 /**
@@ -250,6 +251,28 @@ public function itShouldReturnDefaultInstallerIfReceived()
250251 SystemCtl::setAssetPath ('vfs:// ' );
251252
252253 $ systemCtl = new SystemCtl ;
253- $ this ->assertInstanceOf (UnitInstaller::class, $ systemCtl ->getUnitInstaller ());
254+ self ::assertInstanceOf (UnitInstaller::class, $ systemCtl ->getUnitInstaller ());
255+ }
256+
257+ /**
258+ * @test
259+ */
260+ public function itShouldAddScopeArgumentToDispatcher ()
261+ {
262+ $ output = 'testService.service Active ' ;
263+
264+ $ dispatcher = $ this ->buildCommandDispatcherStub ();
265+ $ dispatcher ->setArguments (['--system ' ])->shouldBeCalled ()->willReturn ($ dispatcher ->reveal ());
266+ $ dispatcher ->dispatch ('list-units ' , 'testService ' )
267+ ->shouldBeCalled ()
268+ ->willReturn ($ this ->buildCommandStub ($ output ));
269+
270+ $ systemCtl = new SystemCtl ;
271+ $ systemCtl ->setCommandDispatcher ($ dispatcher ->reveal ());
272+
273+ $ systemCtl ->getService ('testService ' );
274+
275+ $ dispatcher ->setArguments (['--user ' ])->shouldBeCalled ()->willReturn ($ dispatcher ->reveal ());
276+ $ systemCtl ->user ()->getService ('testService ' );
254277 }
255278}
0 commit comments