File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+
3
+ namespace ApiClients \Tests \Supervisord \CommandBus \Handler ;
4
+
5
+ use ApiClients \Client \Supervisord \CommandBus \Command \ProgramsCommand ;
6
+ use ApiClients \Client \Supervisord \CommandBus \Handler \ProgramsHandler ;
7
+ use ApiClients \Client \Supervisord \Resource \ProgramInterface ;
8
+ use ApiClients \Client \Supervisord \Resource \StateInterface ;
9
+ use ApiClients \Foundation \Hydrator \Hydrator ;
10
+ use ApiClients \Tools \Services \XmlRpc \XmlRpcService ;
11
+ use ApiClients \Tools \TestUtilities \TestCase ;
12
+ use Rx \React \Promise ;
13
+ use function ApiClients \Tools \Rx \unwrapObservableFromPromise ;
14
+ use function React \Promise \resolve ;
15
+
16
+ final class ProgramsHandlerTest extends TestCase
17
+ {
18
+ public function testCommand ()
19
+ {
20
+ $ program = [
21
+ 'name ' => 'ping ' ,
22
+ ];
23
+
24
+ $ resource = $ this ->prophesize (StateInterface::class)->reveal ();
25
+
26
+ $ service = $ this ->prophesize (XmlRpcService::class);
27
+ $ service ->call ('supervisor.getAllProcessInfo ' )->shouldBeCalled ()->willReturn (resolve ([$ program ]));
28
+
29
+ $ hydrator = $ this ->prophesize (Hydrator::class);
30
+ $ hydrator ->hydrate (ProgramInterface::HYDRATE_CLASS , $ program )->shouldBeCalled ()->willReturn ($ resource );
31
+
32
+ $ handler = new ProgramsHandler ($ service ->reveal (), $ hydrator ->reveal ());
33
+ $ program = current ($ this ->await (Promise::fromObservable (unwrapObservableFromPromise ($ handler ->handle (new ProgramsCommand ()))->toArray ())));
34
+
35
+ self ::assertSame ($ resource , $ program );
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments