@@ -129,6 +129,35 @@ public function testPortOptionOnly()
129129 $ this ->assertEquals ('getFactory ' , $ context ['driverContainer ' ]->getDelegatedCalls ()[0 ][0 ]);
130130 }
131131
132+ /**
133+ * Test flag shutdown.
134+ */
135+ public function testShutdown ()
136+ {
137+ $ expectations = ['driver ' => 'userland ' ];
138+
139+ $ context = $ this ->createTestingContext ($ expectations );
140+
141+ $ context ['command ' ]->run (new ArrayInput ([]), new NullOutput ());
142+ $ context ['command ' ]->flagShutdown ();
143+
144+ $ this ->assertEquals ('run ' , $ context ['daemon ' ]->getDelegatedCalls ()[0 ][0 ]);
145+ $ this ->assertEquals ('flagShutdown ' , $ context ['daemon ' ]->getDelegatedCalls ()[1 ][0 ]);
146+ $ this ->assertEquals ('createDaemon ' , $ context ['daemonFactory ' ]->getDelegatedCalls ()[0 ][0 ]);
147+ $ this ->assertEquals ('getFactory ' , $ context ['driverContainer ' ]->getDelegatedCalls ()[0 ][0 ]);
148+ }
149+
150+ /**
151+ * Test flag shutdown with no daemon.
152+ *
153+ * @expectedException \RuntimeException
154+ */
155+ public function testShutdownNoDaemon ()
156+ {
157+ $ command = new DaemonRunCommand (new MockKernel (), new MockDriverContainer ());
158+ $ command ->flagShutdown ();
159+ }
160+
132161 /**
133162 * Construct mock objects set to test for expected values of different
134163 * parameters when specified.
@@ -146,7 +175,7 @@ private function createTestingContext(array $expectations)
146175 };
147176
148177 $ mockKernel = new MockKernel ();
149- $ mockDaemon = new MockDaemon (['run ' => false ]);
178+ $ mockDaemon = new MockDaemon (['run ' => false , ' flagShutdown ' => false ]);
150179
151180 $ mockDaemonFactory = new MockDaemonFactory ([
152181 'createTcpDaemon ' => function ($ kernel , $ options , $ host , $ port ) use ($ assertExpected , $ mockKernel , $ mockDaemon ) {
0 commit comments